-
Hello everyone, Tools and Agentqa = RetrievalQA.from_chain_type(llm=llm, chain_type='stuff', retriever=retriever, return_source_documents=True, verbose=True)
llm_math = LLMMathChain.from_llm(OpenAI(temperature=0), verbose=True)
tools = [
Tool(
name="Search summaries",
func=qa.run,
description="useful for when you need to answer questions. Input should be a fully formed question."
),
Tool(
name="Calculator",
func=llm_math.run,
description="useful for doing calculations"
)
] And the agent is defined as agent = initialize_agent(
tools,
llm,
agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION,
verbose=True,
memory=memory,
return_intermediate_steps=True
) ProblemWhen running the agent with answer = agent({"input": query}, return_only_outputs=False) if the first tool is selected ("Search summaries") I get the following error
And when trying other solutions like calling directly the chain in the tool tools = [
Tool(
name="Search summaries",
func=qa,
description="useful for when you need to answer questions. Input should be a fully formed question."
), I get the a Expected behaviourWhen running the chain singularly (not as a Tool in an Agent) the answer works as expected. Note that when I set Is it possible to have the source_documents also while using an agent? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
EDIT: Tool(
name="Search summaries",
func=lambda query: chain({"question": query}),
description="useful for when you need to answer questions. Input should be a fully formed question."
), This new the chain is now chain = RetrievalQA.from_chain_type(llm=llm, chain_type='stuff', retriever=retriever, return_source_documents=True, verbose=True, input_key="question") |
Beta Was this translation helpful? Give feedback.
-
Does anyone have a solution for async/coroutine implementation? |
Beta Was this translation helpful? Give feedback.
-
I would like to know how can we cite sources while using an agent. |
Beta Was this translation helpful? Give feedback.
EDIT:
This new
func=lambda query: chain({"question": query})
worked for me, but it looks kinda clunky.the chain is now