-
Notifications
You must be signed in to change notification settings - Fork 52
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
[ContextAugmentedFunctionAgent] multi tool function call with retrieval #148
Conversation
erniebot-agent/erniebot_agent/agents/functional_agent_with_retrieval.py
Outdated
Show resolved
Hide resolved
erniebot-agent/erniebot_agent/agents/functional_agent_with_retrieval.py
Outdated
Show resolved
Hide resolved
# return response | ||
tool_ret_json = json.dumps({"documents": outputs}, ensure_ascii=False) | ||
# Direct Prompt | ||
next_step_input = HumanMessage(content=f"问题:{prompt},要求:请在第一步执行检索的操作,并且检索只允许调用一次") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FunctionalAgentWithRetrievalScoreTool和FunctionalAgentWithRetrievalTool 完全分不出来了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FunctionAgentWithRetrievalTool是模拟一次function call的调用
FunctionAgentWithRetrievalScoreTool是通过prompt的方式来引导function call调用检索
@@ -298,3 +385,36 @@ async def _maybe_retrieval( | |||
results = {} | |||
results["documents"] = documents | |||
return results | |||
|
|||
|
|||
class FunctionalAgentWithQueryPlanning(FunctionalAgent): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是个啥..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是把retrieval 当成tool的类,planning部分用的是functional agent默认的,可能后面会加入一些后处理
documents: List[SearchResponseDocument] = Field(description="检索结果,内容和用户输入query相关的段落") | ||
|
||
|
||
class OpenAISearchTool(Tool): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个类和OpenAI有啥关系呀?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里面的db用的是langchain 的faiss,faiss的search接口和返回的参数跟欧若拉不一样,所以重新写了一个tool
llm=llm, | ||
knowledge_base=baizhong_db, | ||
top_k=3, | ||
tools=toolkit.get_tools() + [retrieval_tool], | ||
tools=toolkit.get_tools() + [NotesTool(), retrieval_tool], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥这里还需要传入retrieval_tool这个工具呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example文件删除
tools=[NotesTool(), retrieval_tool], | ||
memory=memory, | ||
) | ||
elif args.retrieval_type == "context_aug": | ||
agent = ContextAugmentedFunctionalAgent( # type: ignore | ||
llm=llm, | ||
knowledge_base=baizhong_db, | ||
top_k=3, | ||
threshold=0.1, | ||
tools=[NotesTool(), retrieval_tool], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些agent的tools哪些应该传入retrieval_tool, 哪些不应该传入,需要想清楚
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除functional_agent_with_retrieval_example.py
…rieval.py Co-authored-by: Sijun He <[email protected]>
|
TODO:
PR会进行拆分: