Files
chatgpt-telegram-bot/bot/functions.py
2023-06-14 20:10:15 +02:00

24 lines
638 B
Python

import json
from plugins.weather import weather_function_spec, get_current_weather
def get_functions_specs():
"""
Return the list of function specs that can be called by the model
"""
return [
weather_function_spec(),
]
async def call_function(function_name, arguments):
"""
Call a function based on the name and parameters provided
"""
if function_name == "get_current_weather":
arguments = json.loads(arguments)
return await get_current_weather(arguments["latitude"], arguments["longitude"], arguments["unit"])
raise Exception(f"Function {function_name} not found")