Bug 描述
我正在使用Azure上的Open AI部署,当在OpenAIAgent
聊天引擎中运行时,它几乎每次都返回HTTP/1.1 500 model_error
。
一些观察:
- 如果直接访问OpenAI,我的代理可以成功运行。
- 如果使用
AzureOpenAI
查询我的rag,它可以正常工作。 - 如果直接从Postman访问我的Azure部署,它可以成功运行。
- 我在使用llama_index
0.10.56
和0.10.55
时也遇到了同样的问题。 - 错误是不稳定的,5%的调用是成功的,但大多数都是失败的。
版本
0.10.55
重现步骤
这是我的设置:
llm = AzureOpenAI(model=model, deployment=AZURE_DEPLOYMENT_NAME, api_key=API_KEY, azure_endpoint=AZURE_OPENAI_ENDPOINT, api_version=OPENAI_API_VERSION)
tool_service_context = ServiceContext.from_defaults(
llm=llm,
embed_model=embedding_model,
node_parser=node_parser
)
.
.
.
llm used in query engines for tools
.
.
.
top_level_sub_tools = [
QueryEngineTool(
query_engine=engine1,
metadata=ToolMetadata(
name="engine1",
description="""some description""".strip())
),
QueryEngineTool(
query_engine=engine2,
metadata=ToolMetadata(
name="engine2",
description="""\some description here""".strip())
)
]
chat_engine = AzureOpenAI(model=model, deployment=AZURE_DEPLOYMENT_NAME, api_key=API_KEY, azure_endpoint=AZURE_OPENAI_ENDPOINT, api_version=OPENAI_API_VERSION)
tools = top_level_sub_tools + some_function_call_tools
chat_engine = OpenAIAgent.from_tools(
tools=tools,
llm=chat_llm,
chat_history=chat_history,
verbose=True,
system_prompt=SYSTEM_MESSAGE_GENERIC.format(curr_date=curr_date)
)
相关日志/回溯
2024-07-23 01:42:33,006 - INFO - HTTP Request: POST https://.....openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2023-03-15-preview "HTTP/1.1 500 model_error"
2024-07-23 01:42:33,007 - INFO - Retrying request to /chat/completions in 0.980118 seconds
2024-07-23 01:42:53,728 - INFO - HTTP Request: POST https://......openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2023-03-15-preview "HTTP/1.1 500 model_error"
2024-07-23 01:42:53,729 - INFO - Retrying request to /chat/completions in 1.512375 seconds
2024-07-23 01:43:15,511 - INFO - HTTP Request: POST https://......openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2023-03-15-preview "HTTP/1.1 500 model_error"
2024-07-23 01:43:15,512 - INFO - Retrying request to /chat/completions in 3.923435 seconds
2024-07-23 01:43:34,617 - INFO - HTTP Request: POST https://......openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2023-03-15-preview "HTTP/1.1 500 model_error"
error occurred in /chat endpoint: Error code: 500 - {'error': {'message': 'The server had an error processing your request. Sorry about that! You can retry your request, or contact us through an Azure support request at: https://go.microsoft.com/fwlink/?linkid=2213926 if you keep seeing this error. (Please include the request ID 77c0d6e4-150a-4b70-a132-3dfbec165c8e in your email.)', 'type': 'server_error', 'param': None, 'code': None}}
4条答案
按热度按时间mfpqipee1#
在进行了一些更多实验后,我在我的工具中填写了更多的详细信息。我的代理有两个
QueryEngineTool
工具,我发现当代理只包含一个时,一切都能成功运行。这种设置对于其他模型来说效果很好,但只有在 Azure 上才会遇到这个错误。如果我注解掉top_level_sub_tools
中的任何一个QueryEngineTool
,一切就会按预期工作。这是我的设置:pgx2nnw82#
当使用两个
QueryEngineTool
工具时,与 Azure OpenAI 的500 model_error
可能是由于超过了该工具描述的最大字符限制(1024个字符)。当将多个QueryEngineTool
工具组合成一个QueryPlanTool
时,它们的描述会被拼接在一起,这很容易超过这个限制。要解决这个问题,您可以将工具描述移动到提示符中,而不是将其包含在工具元数据中。这种方法避免了工具描述的1024个字符限制。
以下是将工具描述移动到提示符的相关代码片段:
此解决方案确保工具描述包含在提示符中,避免了字符限制问题 1(https://github.com/run-llama/llama_index/blob/main/docs/docs/examples/agent/openai_agent_lengthy_tools.ipynb)。
如果您需要进一步的帮助,@logan-markewich 可以提供额外的指导。
jk9hmnmh3#
我认为这与OpenAI目前不稳定有关。对于这种错误,已经内置了重试机制,所以它已经通过了。
rsl1atfo4#
@logan-markewich 我也这么认为,或者至少在Azure上遇到了一些问题。但是如果我移除了
QueryEngineTool
中的任意一个,所有事情都一直正常工作。如果是OpenAI或Azure,我可能会在使用一个查询引擎工具时看到类似的错误,但只有在同时使用这两个工具时才会出现错误。当我在代理中使用一个
QueryEngineTool
时,所有11个请求在Azure OpenAI部署中成功。当我直接使用gpt-3.5与两个工具一起在代理中使用时,所有请求都成功:
非常奇怪的行为,错误仅限于多个查询引擎工具和Azure OpenAI部署。我还会查看dosubot提到的字符限制,并进行回复。
[编辑] 检查了代理中使用的查询引擎工具的描述大小,总字符数为553。