Closed uezo closed 1 year ago
Use chat_processor.add_function to use ChatGPT function calling. In this example, get_weather will be called autonomously.
chat_processor.add_function
get_weather
# Add function async def get_weather(location: str): await asyncio.sleep(1.0) return {"weather": "sunny partly cloudy", "temperature": 23.4} app.chat_processor.add_function( name="get_weather", description="Get the current weather in a given location", parameters={ "type": "object", "properties": { "location": { "type": "string" } } }, func=get_weather )
And, after get_weather called, message to get voice response will be sent to ChatGPT internally.
{ "role": "function", "content": "{\"weather\": \"sunny partly cloudy\", \"temperature\": 23.4}", "name": "get_weather" }
Use
chat_processor.add_function
to use ChatGPT function calling. In this example,get_weather
will be called autonomously.And, after
get_weather
called, message to get voice response will be sent to ChatGPT internally.