"""测试 qwen api 在 openai sdk 下,能否与 pydantic 进行协作"""importosfromopenaiimportAsyncOpenAIfrompydantic_aiimportAgent,RunContextfrompydantic_ai.models.openaiimportOpenAIModelfrompydantic_ai.providers.openaiimportOpenAIProviderdefget_agent():"""get custom client"""client=AsyncOpenAI(max_retries=3,base_url=os.getenv("OPENAPI_BASE_URL"),api_key=os.getenv("OPENAI_API_KEY"))model=OpenAIModel("qwen3-coder-plus",provider=OpenAIProvider(openai_client=client))agent=Agent(model,deps_type=int,output_type=bool,system_prompt=("Use the `roulette_wheel` function to see if the customer has won based on the number they provide."),)returnagentagent=get_agent()@agent.toolasyncdefroulette_wheel(ctx:RunContext[int],square:int)->str:"""check if the square is a winner"""return"winner"ifsquare==ctx.depselse"loser"defmain():success_number=18result=agent.run_sync("Put my money on square eighteen",deps=success_number)print(result.output)if__name__=="__main__":main()