py2gpt
1.0.0
Kürzlich hat OpenAI die GPT-Funktion API veröffentlicht, mit der Modelle wie GPT-4 Funktionen im Namen des Benutzers "aufrufen" können. Das Problem ist, dass das Format, in dem diese Funktionen angegeben sind, ein JSON -Schema ist, das relativ Nische und schwer zu arbeiten ist. Dieses Repository befasst sich mit diesem Problem. Es wandelt regelmäßige Python -Funktionserklärungen in JSON -Verbrauchsmaterial um.
Zum Beispiel dieser Python -Code:
def get_current_weather ( location : str , format : Literal [ "fahrenheit" , "celsius" ]):
"""
Get the current weather
:param location: The city and state, e.g. San Francisco, CA
:param format: The temperature unit to use. Infer this from the users location.
"""Erstellt das folgende JSON, der einem der eigenen Beispiele von OpenAI entspricht:
{
'name' : 'get_current_weather' ,
'description' : 'Get the current weather' ,
'parameters' : {
'type' : 'object' ,
'properties' : {
'location' : {
'description' : 'The city and state, e.g. San Francisco, CA' ,
'type' : 'string'
} ,
'format' : {
'description' : 'The temperature unit to use. Infer this from the
users location.' ,
'type' : 'string' ,
'enum' : ( 'fahrenheit' , 'celsius' )
}
}
} ,
'required' : [ 'location' , 'format' ]
} object s mit bestimmten "Eigenschaften" self ") Enum s