Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent Update: Fix Role Issue and Enhance KB Search #5842

Merged
merged 3 commits into from
Mar 10, 2025

Conversation

zhangcdian
Copy link
Contributor

@zhangcdian zhangcdian commented Mar 10, 2025

What problem does this PR solve?

generate.py 更新:
问题:部分模型提供商对输入对话内容的格式有严格校验,要求第一条内容的 role 不能为 assistant,否则会报错。
解决:删除了系统设置的 agent 开场白,确保传递给模型的对话内容中,第一条内容的 role 不为 assistant。

retrieval.py 更新:
问题:当前知识库检索使用全部对话内容作为输入,可能导致检索结果不准确。
解决:改为仅使用用户最后提出的一个问题进行知识库检索,提高检索的准确性。

Update generate.py:
Issue: Some model providers have strict validation rules for the format of input conversation content, requiring that the role of the first content must not be assistant. Otherwise, an error will occur.
Solution: Removed the system-set agent opening statement to ensure that the role of the first content in the conversation passed to the model is not assistant.

Update retrieval.py:
Issue: The current knowledge base retrieval uses the entire conversation content as input, which may lead to inaccurate retrieval results.
Solution: Changed the retrieval logic to use only the last question asked by the user for knowledge base retrieval, improving retrieval accuracy.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • Performance Improvement

Update retrieval: use the last question of user to search KB
Update generate: 删除系统设置的agent开场白,确保传递给模型的对话内容中,第一条内容的role不为assistant。(部分模型提供商校验严格,不允许第一条内容的role为assistant)
Delete the agent opening statement set by the system, and ensure that the role of the first content in the conversation content passed to the model is not "assistant". (Some model providers have strict verification and do not allow the "role" of the first content to be "assistant")
@KevinHuSh KevinHuSh added the ci Continue Integration label Mar 10, 2025
@KevinHuSh KevinHuSh merged commit bf0d516 into infiniflow:main Mar 10, 2025
2 checks passed
TeslaZY pushed a commit to TeslaZY/ragflow that referenced this pull request Mar 10, 2025
### What problem does this PR solve?

**generate.py 更新:**
问题:部分模型提供商对输入对话内容的格式有严格校验,要求第一条内容的 role 不能为 assistant,否则会报错。
解决:删除了系统设置的 agent 开场白,确保传递给模型的对话内容中,第一条内容的 role 不为 assistant。

**retrieval.py 更新:**
问题:当前知识库检索使用全部对话内容作为输入,可能导致检索结果不准确。
解决:改为仅使用用户最后提出的一个问题进行知识库检索,提高检索的准确性。

**Update generate.py:**
Issue: Some model providers have strict validation rules for the format
of input conversation content, requiring that the role of the first
content must not be assistant. Otherwise, an error will occur.
Solution: Removed the system-set agent opening statement to ensure that
the role of the first content in the conversation passed to the model is
not assistant.

**Update retrieval.py:**
Issue: The current knowledge base retrieval uses the entire conversation
content as input, which may lead to inaccurate retrieval results.
Solution: Changed the retrieval logic to use only the last question
asked by the user for knowledge base retrieval, improving retrieval
accuracy.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] Performance Improvement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Continue Integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants