py2gpt
1.0.0
최근 OpenAI는 GPT-4와 같은 모델이 사용자를 대신하여 "기능"기능을 "호출"할 수있는 GPT 기능 API를 출시했습니다. 문제는 이러한 기능이 지정된 형식이 JSON 스키마이며, 상대적으로 틈새 시장이며 작업하기가 어렵다는 것입니다. 이 저장소는이 문제를 해결합니다. 정기적 인 Python 함수 선언을 OpenAI API에 의해 소비 할 수있는 JSON으로 변환합니다.
예를 들어이 파이썬 코드 :
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.
"""OpenAi의 자체 예 중 하나와 일치하는 다음 JSON을 생성합니다.
{
'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 로 취급하십시오. self 매개 변수로 함수로 취급) Enum support s