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

[ContextAugmentedFunctionAgent] multi tool function call with retrieval #148

Open
wants to merge 45 commits into
base: develop
Choose a base branch
from

Conversation

w5688414
Copy link
Collaborator

@w5688414 w5688414 commented Dec 12, 2023

TODO:

@w5688414 w5688414 changed the title multi tool function call with retrieval [enhance] multi tool function call with retrieval Dec 13, 2023
@w5688414 w5688414 self-assigned this Dec 13, 2023
@w5688414 w5688414 changed the title [enhance] multi tool function call with retrieval [AutoRetrievel] multi tool function call with retrieval Dec 15, 2023
@w5688414 w5688414 changed the title [AutoRetrievel] multi tool function call with retrieval [AutoRetrievel-Context-Augmented Agent] multi tool function call with retrieval Dec 15, 2023
@w5688414 w5688414 changed the title [AutoRetrievel-Context-Augmented Agent] multi tool function call with retrieval [AutoRetrievel] multi tool function call with retrieval Dec 15, 2023
# return response
tool_ret_json = json.dumps({"documents": outputs}, ensure_ascii=False)
# Direct Prompt
next_step_input = HumanMessage(content=f"问题:{prompt},要求:请在第一步执行检索的操作,并且检索只允许调用一次")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FunctionalAgentWithRetrievalScoreTool和FunctionalAgentWithRetrievalTool 完全分不出来了

Copy link
Collaborator Author

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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是个啥..

Copy link
Collaborator Author

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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个类和OpenAI有啥关系呀?

Copy link
Collaborator Author

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],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥这里还需要传入retrieval_tool这个工具呢?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example文件删除

Comment on lines 158 to 167
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],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些agent的tools哪些应该传入retrieval_tool, 哪些不应该传入,需要想清楚

Copy link
Collaborator Author

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

@w5688414 w5688414 changed the title [AutoRetrievel] multi tool function call with retrieval [ContextAugmentedFunctionAgent] multi tool function call with retrieval Jan 19, 2024
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.

None yet

2 participants