agentscope-ai / agentscope-ai/agentscope-java
Failed to call OpenAI API: OpenAI API request failed with status 400
- 主要語言
- Java
- 星號
- 5.6k
- 分支
- 1.3k
- 平均合併
- 4 天 12 小時
- 30 天內合併 PR
- 77
描述
**AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.**
**Describe the bug**
When I try to use agent call user message with version 1.0.7, I get an error. However, it works well with version 1.0.5. And I deploy a VLLM server to provide LLM Api.
I'm not sure it's a bug. Maybe I run it in a wrong way with the newest version.
**To Reproduce**
Steps to reproduce the behavior:
1. Here is my code:
`// 1. 配置 vLLM 的 OpenAI 兼容模型
String vllmBaseUrl = "http://localhost:8000";
String modelName = "Qwen3-235B-A22B-Instruct-2507-AWQ"; // 必须与 vLLM 启动时的 --model 一致
OpenAIChatModel model = OpenAIChatModel.builder()
.baseUrl(vllmBaseUrl)
.apiKey("EMPTY")
.modelName(modelName)
.build();
// 2. 创建 ReActAgent
ReActAgent agent = ReActAgent.builder()
.name("VLLM-Agent")
.sysPrompt("You are a helpful AI assistant powered by vLLM.")
.model(model)
.build();
// 3. 构建用户消息
Msg userMsg = Msg.builder()
.role(MsgRole.USER)
.content(TextBlock.builder().text("Hello").build())
.build();
// 4. 调用模型并打印结果
try {
Msg response = agent.call(userMsg).block();
System.out.println("【模型回复】: " + response.getTextContent());
} catch (Exception e) {
System.err.println("❌ 调用失败: " + e.getMessage());
e.printStackTrace();
}
2. Just run this method.
3. See error
**Expected behavior**
I just want it work well.
**Error messages**
Failed to call OpenAI API: OpenAI API request failed with status 400 | {"error":{"message":"1 validation error:\n {'type': 'missing', 'loc': ('body',), 'msg': 'Field required', 'input': None}\n\n File \"/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/utils.py\", line 477, in create_chat_completion\n POST /v1/chat/completions [{'type': 'missing', 'loc': ('body',), 'msg': 'Field required', 'input': None}]","type":"Bad Request","param":null,"code":400}}
io.agentscope.core.model.ModelException: Failed to call OpenAI API: OpenAI API request failed with status 400 | {"error":{"message":"1 validation error:\n {'type': 'missing', 'loc': ('body',), 'msg': 'Field required', 'input': None}\n\n File \"/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/utils.py\", line 477, in create_chat_completion\n POST /v1/chat/completions [{'type': 'missing', 'loc': ('body',), 'msg': 'Field required', 'input': None}]","type":"Bad Request","param":null,"code":400}} [model=Qwen3-235B-A22B-Instruct-2507-AWQ, provider=openai]
**Environment (please complete the following information):**
- AgentScope-Java Version: 1.0.7
- Java Version: 17.0.12
- OS: windows 10
- VLLM: v0.13.0
貢獻指南
評估
這個 Issue 還沒有評估資料。