Find answers from the community

Updated 4 months ago

The Importance of Synchronizing Tool Execution in a ReAct Agent

At a glance

The community member has created a ReAct agent with two tools: a FunctionTool and a QueryEngineTool. The FunctionTool is async and works with await agent.achat(prompt), but the QueryEngineTool only works with agent.chat(prompt). When using agent.chat(), the async FunctionTool works, but the response is delivered after the chat responds since it is not async.

The community member is encountering an error when using the sync QueryEngineTool with the achat function. The error is related to the embeddings input being a coroutine object instead of a valid list.

The comments suggest that there may be a bug in the integration code for the GeminiEmbedding model, and the community members are discussing potential workarounds and solutions. However, there is no explicitly marked answer in the provided information.

Hello! Not sure if I am in the right spot but looking for some help.

I have created a ReAct agent that has two tools. One FunctionTool and one QueryEngineTool.

My function tool is async so I am using await agent.achat(prompt) to execute the operation. This works great.
My QueryEngineTool does not like this, and only works with agent.chat(prompt)

If I use agent.chat, the async function tool works, but response is delivered after the chat responds since it is not async.

Plain Text
async_tool = FunctionTool.from_defaults(
  async_fn=lambda a: execute(a, ...otherstuff),
  name="myfirsttool",
  description="calls an API async"
)
index = load_index_from_storage(storage_context=storage_context)
query_engine = index.as_query_engine()
sync_tool = QueryEngineTool.from_defaults(
  query_engine=query_engine,
  name="google gemini indexed",
  description="Indexing from google gemini seems to throw error here when doing achat"
)

agent = ReActAgent.from_tools(llm=llm, tools=[sync_tool, async_tool])


The error occurs when using the sync tool with the achat function.

Error:

Plain Text
embeddings.0 Input should be a valid list [type=list_type, input_value=<coroutine object GeminiEm...dings at 0xec57134d34c0> input_type=coroutine]


Thanks for taking a look at the psuedo code above and any guidance!
n
L
5 comments
Apppreciate your response! I will try this now and see if it results in the same error. Do you have any suggestions for work arounds?
Yup! Same problem with query_engine.aquery(...) !
I think theres a bug in the embed model here integration code. You are using GeminiEmbedding ? Something else?
Thanks for the direction to where this was going wrong and approving my PR!
Thanks for making a PR! Saved me from doing it heh
Add a reply
Sign up and join the conversation on Discord