Find answers from the community

Updated 7 months ago

Pass CallbackFn to FnTool?

Hello devs, i need to know if i can pass a function that is callback function for an event, inside FunctionTool.from_defaults(fn=callback_function)

def callback_function(request:Request): resp = request.json() print(resp)

so i need to trigger the agent when i receive the event... is it possible???
A
m
7 comments
πŸ€” wow interesting, but looks like ur tying a tool run to an external state other than the agent-state ? Not sure if thats the way FnTool is intented to be used πŸ™ˆ I maybe wrong here, but passing a callback fn fells like it would work as long as the previous component sends the correct data in the output_keys or if ur passing it in as partial_dict πŸ˜…
hmm, let me make it harder now πŸ˜‚ , i want to trigger the subagent or llm, with this function_callback. so the llm can use it only when the the callback received
Oooooo, Is this callback purely for async purposes? If so why not just pass async_fn insted of fn ?
i have an idea !!!! i just get it maybe πŸ”₯ and yes async_fn is needed
ok i will pass a query so automatically will ask the llm to use that callback when it's received. i don't know if u understand me hahahah
Ah got it, makes sense , no need of the callback then, directly using the logic u want to run as a tool would work ig πŸ™‚
yesss, i will see if it will work
Add a reply
Sign up and join the conversation on Discord