Fix embedding 400 errors#523
Merged
xerrors merged 1 commit intoxerrors:mainfrom Feb 28, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更描述
原实现使用asyncio.gather并发执行所有embedding批次请求。
在文档被切分为大量chunk入库时,会瞬间向外部embedding服务发送大量并发请求。
部分embedding服务对batch大小、token数量以及请求速率有严格限制。
在高并发场景下容易触发400错误或限流问题,导致入库流程失败。
为提高稳定性,这里改为顺序执行批次请求并且限制batch size,避免瞬时请求过多导致API拒绝。
变更类型
测试
相关日志或者截图
原错误示例:
Client error '400 Bad Request' for url 'https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings'
修复后索引流程正常完成。
说明
(可选)有什么需要特别说明的吗?
当前修改主要用于提升embedding API调用稳定性,
避免文档入库场景下的请求爆发问题。
💡 提示: 提交前可以运行
make lint和make format检查代码规范