openai.pydantic_function_tool(Query), ], ) print(completion.choices[0].message.tool_calls[0].function.parsed_arguments) 而且,本机结构化输出支持也可用于response_format 。 frompydanticimportBaseModel fromopenaiimportOpenAI class...
frompydanticimportBaseModel importopenai fromopenaiimportOpenAI client=OpenAI classGetDeliveryDate(BaseModel): order_id:str tools=[openai.pydantic_function_tool(GetDeliveryDate)] messages=[] messages.append({"role":"system","content":"Youareahelpfulcustomersupportassistant.Usethesuppliedtoolstoassisttheuse...
calling the query function.", }, { "role": "user", "content": "look up all my orders in may of last year that were fulfilled but not delivered on time", }, ], tools=[ openai.pydantic_function_tool(Query), ],) print(completion.choices[0].message.tool_...
AI代码解释 from agentsimportAgent,Runner,WebSearchTool,function_tool,guardrail @function_tool defsubmit_refund_request(item_id:str,reason:str):# Your refund logic goes herereturn"success"support_agent=Agent(name="Support & Returns",instructions="You are a support agent who can submit refunds [.....
fromenumimportEnumfromtypingimportUnionfrompydanticimportBaseModelimportopenaifromopenaiimportOpenAIclient=OpenAI()classGetDeliveryDate(BaseModel):order_id:strtools=[openai.pydantic_function_tool(GetDeliveryDate)]messages=[]messages.append({"role":"system","content":"You are a helpful custo...
openai.pydantic_function_tool(Query), ], ) print(completion.choices[0].message.tool_calls[0].function.parsed_arguments) 而且,本机结构化输出支持也可用于response_format 。 frompydanticimportBaseModel fromopenaiimportOpenAI classStep(BaseModel): ...
2024. You help users query for the data they are looking for by calling the query function.",},{"role":"user","content":"look up all my orders in may of last year that were fulfilled but not delivered on time",},],tools=[openai.pydantic_function_tool(Query),],)print(completion....
C:\Users\octop>pip show openaiName:openaiVersion:1.35.3Summary:The official Python libraryforthe openaiAPIHome-page:NoneAuthor:None Author-email:OpenAI<support@openai.com>License:NoneLocation:d:\001_develop\022_python\python37_64\lib\site-packagesRequires:pydantic,tqdm,sniffio,cached-property,httpx...
openai.pydantic_function_tool(Query), ], ) print(completion.choices[0].message.tool_calls[0].function.parsed_arguments) 二、使用场景: 1、工具调用: ●具体场景:在开发一个电商在线客服聊天机器人时,开发者需要确保机器人能够根据用户的问题提供标准化的答案,比如产品价格、服务条款等。 ●用户观点:在构建...
pydantic_function_tool(WeatherData) {'type': 'function', 'function': {'name': 'WeatherData', 'strict': True, 'parameters': {'properties': {'location': {'title': 'Location', 'type': 'string'}, 'unit': {'enum': ['celsius', 'fahrenheit'], 'title': 'Unit', 'type': 'string'...