Skip to content

为OpenAI API调用添加指数退避重试机制#71

Open
NoAmateur wants to merge 1 commit into
BAI-LAB:mainfrom
NoAmateur:fix-llm-retry
Open

为OpenAI API调用添加指数退避重试机制#71
NoAmateur wants to merge 1 commit into
BAI-LAB:mainfrom
NoAmateur:fix-llm-retry

Conversation

@NoAmateur

Copy link
Copy Markdown
Contributor

在OpenAIClient.chat_completion()中增加重试逻辑,支持指数退避:

  • 最大重试次数:3次
  • 可重试错误:429、502、503、timeout、connection
  • 退避策略:2^attempt 秒(1s, 2s, 4s)

同时清理deepseek-r1等推理模型的输出标签,
避免思考过程污染最终返回内容。

涉及文件:

  • memoryos-pypi/utils.py
  • memoryos-playground/utils.py
  • memoryos-mcp/memoryos/utils.py
  • memoryos-chromadb/utils.py

在OpenAIClient.chat_completion()中增加重试逻辑,支持指数退避:
- 最大重试次数:3次
- 可重试错误:429、502、503、timeout、connection
- 退避策略:2^attempt 秒(1s, 2s, 4s)

同时清理deepseek-r1等推理模型的<think>输出标签,
避免思考过程污染最终返回内容。

涉及文件:
- memoryos-pypi/utils.py
- memoryos-playground/utils.py
- memoryos-mcp/memoryos/utils.py
- memoryos-chromadb/utils.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant