Find answers from the community

Updated 2 months ago

[Question]: How to use async FunctionToo...

At a glance

The community member is using an async workflow and encountering an error: "coroutine '<function>' was never awaited". The error is traced back to a specific file and line number. The community member has already tried switching to a different tool, but is unsure of what else to try.

In the comments, other community members ask for more information, such as the code and the specific version of the llama-index-core library being used. The community member provides the version (0.11.8) and indicates they are willing to share sample code if needed.

Another community member notes that the version is a bit old (the current version is 0.12.10) and suggests the community member try upgrading first before providing sample code. The community member tries upgrading but still encounters the same issue, and decides to share a code example with the other community member.

The issue is eventually resolved, with the community member noting that the solution was to use async_fn instead of fn when creating the FunctionTool instances.

Useful resources
Quick Question - I am using an async workflow and getting the following error: coroutine '<function name>' was never awaited.

The traceback shows the error is coming from python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py:297. I already switched to atool after seeing this https://github.com/run-llama/llama_index/issues/17356 but not sure what else to try
W
L
m
8 comments
Can you share the code?
I think this is probably benign? Is there a full traceback or is this just something logged to the terminal?

The line number in the dispatcher doesn't match the current code on github though, which version of llama-index-core do you have?
I'm on v0.11.8 for llama-index-core
I can put together some example code to share if it'd be helpful
hmm, that is a little old (currently we are at v0.12.10) -- curious if it reproduces if you update

Sample code would be great if you want me to test on latest for you!
Let me try upgrading first, and if not I'll share some sample code
@Logan M upgraded and have the same issue. Going to DM you a code example
Closing this out, needed to use async_fn instead of fn

example:

tools = [
FunctionTool.from_defaults(async_fn=add),
FunctionTool.from_defaults(async_fn=multiply),
]

instead of

tools = [
FunctionTool.from_defaults(fn=add),
FunctionTool.from_defaults(fn=multiply),
]
Add a reply
Sign up and join the conversation on Discord