Find answers from the community

Updated 4 months ago

i am getting `error: TypeError:

At a glance

The community member is encountering a TypeError when using the FunctionTool.from_defaults() method, as the fn argument is required but not provided. The community members discuss that the fn argument is for synchronous functions, while the async_fn argument is for asynchronous functions. One community member suggests creating a synchronous wrapper function around the asynchronous flight_service.create_pickup_flight_alert() function, and passing that as the fn argument. This solution is confirmed to work by another community member.

i am getting error: TypeError: FunctionTool.from_defaults() missing 1 required positional argument: 'fn'
my methods are Async functions so they need to be await

pick_func = FunctionTool.from_defaults(async_fn=flight_service.create_pickup_flight_alert)
any idea why the error is up?
m
L
7 comments
ok, the fn argument is requered.. but how i pass my async func , now i made it work but it took 20 seconds to finish and i got this :
RuntimeWarning: coroutine 'FlightStatesAPI.create_pickup_flight_alert' was never awaited
Did you pass an actual synchronous function?
fn is sync, async_fn is async
Plain Text
def create_pickup_flight_alert(..):
  """<DOCSTRING>"""
  return asyncio.run(flight_service.create_pickup_flight_alert)

pick_func = FunctionTool.from_defaults(
  fn=create_pickup_flight_alert,
  async_fn=flight_service.create_pickup_flight_alert
)
ok i will try this,
i have done it, it's working like u said
Add a reply
Sign up and join the conversation on Discord