如何在Azure AI Chat Playground中查看GPT-4o响应生成耗时?
查看Azure AI Chat Playground中GPT-4o单次查询耗时的可行方法
目前Azure AI Chat Playground本身没有直接显示单次查询耗时的功能,你可以通过以下几种方式获取:
浏览器开发者工具抓包分析
打开浏览器的开发者工具(快捷键F12或Ctrl+Shift+I),切换到「Network」标签页。发起查询后,找到包含chat/completions的API请求,查看该请求的「Timing」面板,就能看到从请求发起至响应完成的完整耗时细节,包括总时长、服务器处理时间等。直接调用Azure OpenAI API并手动计时
绕过Playground,自己写代码调用GPT-4o的API,在代码中加入计时逻辑。以Python为例:import time from openai import AzureOpenAI # 初始化客户端 client = AzureOpenAI( azure_endpoint="你的Azure OpenAI端点地址", api_key="你的API密钥", api_version="2024-05-01-preview" ) # 计时并发起请求 start = time.time() response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "你的测试提示词"}] ) end = time.time() print(f"本次查询耗时: {end - start:.2f} 秒")通过Azure Monitor日志查询
如果你的Azure OpenAI资源已经启用了监控日志,可以在Azure门户中进入该资源的「监控」>「日志」页面,运行Kusto查询获取请求耗时:AzureDiagnostics | where OperationName == "ChatCompletions" | where ModelName_s == "gpt-4o" | project TimeGenerated, DurationMs, RequestId | order by TimeGenerated desc结果中的
DurationMs字段就是单次请求的耗时(单位:毫秒)。

内容的提问来源于stack exchange,提问作者noobmaster
相关产品推荐
相关产品推荐

