mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-21 14:44:50 +01:00
initial functions support and added weather func
This commit is contained in:
23
bot/functions.py
Normal file
23
bot/functions.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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["location"], arguments["unit"])
|
||||
|
||||
raise Exception(f"Function {function_name} not found")
|
||||
Reference in New Issue
Block a user