@function_tool
async def search_web(self, query: str, run_ctx: RunContext) -> str:
"""Called when user asks to search the web.
Args:
query: The query to search the web for.
"""
logger.info(f"Searching the web for {query}")
asyncio.ensure_future(self._a_long_running_task(query, run_ctx))
return "I am finding some results for you, continue your conversation with the user. Don't call this function again based on the user response"
async def _a_long_running_task(self, query: str, run_ctx: RunContext) -> str:
"""Simulate a long running task."""
await asyncio.sleep(15)
output = f"I got some results for {query}"
run_ctx.session.interrupt()
await run_ctx.session.say(output)