C:\Java\jdk-17\bin\java.exe "-javaagent:D:\work\IntelliJ IDEA 2024.3\lib\idea_rt.jar=62463:D:\work\IntelliJ IDEA 2024.3\bin" -Dfile.encoding=UTF-8 -classpath D:\maven_use\lingxi-lhc\lingxi-ai-extend\lingxi-ai-comparison\target\classes;D:\maven_use\repository\org\springframework\boot\spring-boot-starter-web\3.4.4\spring-boot-starter-web-3.4.4.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-starter\3.4.4\spring-boot-starter-3.4.4.jar;D:\maven_use\repository\org\springframework\boot\spring-boot\3.4.4\spring-boot-3.4.4.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-autoconfigure\3.4.4\spring-boot-autoconfigure-3.4.4.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-starter-logging\3.4.4\spring-boot-starter-logging-3.4.4.jar;D:\maven_use\repository\ch\qos\logback\logback-classic\1.5.18\logback-classic-1.5.18.jar;D:\maven_use\repository\ch\qos\logback\logback-core\1.5.18\logback-core-1.5.18.jar;D:\maven_use\repository\org\apache\logging\log4j\log4j-to-slf4j\2.24.3\log4j-to-slf4j-2.24.3.jar;D:\maven_use\repository\org\apache\logging\log4j\log4j-api\2.24.3\log4j-api-2.24.3.jar;D:\maven_use\repository\org\slf4j\jul-to-slf4j\2.0.17\jul-to-slf4j-2.0.17.jar;D:\maven_use\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;D:\maven_use\repository\org\springframework\spring-core\6.2.5\spring-core-6.2.5.jar;D:\maven_use\repository\org\springframework\spring-jcl\6.2.5\spring-jcl-6.2.5.jar;D:\maven_use\repository\org\yaml\snakeyaml\2.3\snakeyaml-2.3.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-starter-json\3.4.4\spring-boot-starter-json-3.4.4.jar;D:\maven_use\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.18.3\jackson-datatype-jdk8-2.18.3.jar;D:\maven_use\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.18.3\jackson-datatype-jsr310-2.18.3.jar;D:\maven_use\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.18.3\jackson-module-parameter-names-2.18.3.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-starter-tomcat\3.4.4\spring-boot-starter-tomcat-3.4.4.jar;D:\maven_use\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.39\tomcat-embed-core-10.1.39.jar;D:\maven_use\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.39\tomcat-embed-el-10.1.39.jar;D:\maven_use\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.39\tomcat-embed-websocket-10.1.39.jar;D:\maven_use\repository\org\springframework\spring-web\6.2.5\spring-web-6.2.5.jar;D:\maven_use\repository\org\springframework\spring-beans\6.2.5\spring-beans-6.2.5.jar;D:\maven_use\repository\io\micrometer\micrometer-observation\1.14.5\micrometer-observation-1.14.5.jar;D:\maven_use\repository\io\micrometer\micrometer-commons\1.14.5\micrometer-commons-1.14.5.jar;D:\maven_use\repository\org\springframework\spring-webmvc\6.2.5\spring-webmvc-6.2.5.jar;D:\maven_use\repository\org\springframework\spring-aop\6.2.5\spring-aop-6.2.5.jar;D:\maven_use\repository\org\springframework\spring-context\6.2.5\spring-context-6.2.5.jar;D:\maven_use\repository\org\springframework\spring-expression\6.2.5\spring-expression-6.2.5.jar;D:\maven_use\repository\org\apache\pdfbox\pdfbox\2.0.29\pdfbox-2.0.29.jar;D:\maven_use\repository\org\apache\pdfbox\fontbox\2.0.29\fontbox-2.0.29.jar;D:\maven_use\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\maven_use\repository\org\json\json\20231013\json-20231013.jar;D:\maven_use\repository\com\hankcs\hanlp\portable-1.8.4\hanlp-portable-1.8.4.jar;D:\maven_use\lingxi-lhc\lingxi-ai-common\lingxi-ai-common-core\target\classes;D:\maven_use\repository\org\springframework\spring-context-support\6.2.5\spring-context-support-6.2.5.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-starter-validation\3.4.4\spring-boot-starter-validation-3.4.4.jar;D:\maven_use\repository\org\hibernate\validator\hibernate-validator\8.0.2.Final\hibernate-validator-8.0.2.Final.jar;D:\maven_use\repository\jakarta\validation\jakarta.validation-api\3.0.2\jakarta.validation-api-3.0.2.jar;D:\maven_use\repository\com\fasterxml\classmate\1.7.0\classmate-1.7.0.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-starter-aop\3.4.4\spring-boot-starter-aop-3.4.4.jar;D:\maven_use\repository\org\aspectj\aspectjweaver\1.9.23\aspectjweaver-1.9.23.jar;D:\maven_use\repository\org\apache\commons\commons-lang3\3.17.0\commons-lang3-3.17.0.jar;D:\maven_use\repository\jakarta\servlet\jakarta.servlet-api\6.0.0\jakarta.servlet-api-6.0.0.jar;D:\maven_use\repository\cn\hutool\hutool-core\5.8.35\hutool-core-5.8.35.jar;D:\maven_use\repository\cn\hutool\hutool-http\5.8.35\hutool-http-5.8.35.jar;D:\maven_use\repository\cn\hutool\hutool-extra\5.8.35\hutool-extra-5.8.35.jar;D:\maven_use\repository\cn\hutool\hutool-setting\5.8.35\hutool-setting-5.8.35.jar;D:\maven_use\repository\cn\hutool\hutool-log\5.8.35\hutool-log-5.8.35.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-configuration-processor\3.4.4\spring-boot-configuration-processor-3.4.4.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-properties-migrator\3.4.4\spring-boot-properties-migrator-3.4.4.jar;D:\maven_use\repository\org\springframework\boot\spring-boot-configuration-metadata\3.4.4\spring-boot-configuration-metadata-3.4.4.jar;D:\maven_use\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;D:\maven_use\repository\io\github\linpeilie\mapstruct-plus-spring-boot-starter\1.4.6\mapstruct-plus-spring-boot-starter-1.4.6.jar;D:\maven_use\repository\io\github\linpeilie\mapstruct-plus\1.4.6\mapstruct-plus-1.4.6.jar;D:\maven_use\repository\org\mapstruct\mapstruct\1.5.5.Final\mapstruct-1.5.5.Final.jar;D:\maven_use\repository\io\github\linpeilie\mapstruct-plus-object-convert\1.4.6\mapstruct-plus-object-convert-1.4.6.jar;D:\maven_use\repository\org\lionsoul\ip2region\2.7.0\ip2region-2.7.0.jar;D:\maven_use\repository\net\sourceforge\tess4j\tess4j\5.8.0\tess4j-5.8.0.jar;D:\maven_use\repository\net\java\dev\jna\jna\5.13.0\jna-5.13.0.jar;D:\maven_use\repository\com\github\jai-imageio\jai-imageio-core\1.4.0\jai-imageio-core-1.4.0.jar;D:\maven_use\repository\org\apache\pdfbox\pdfbox-tools\2.0.29\pdfbox-tools-2.0.29.jar;D:\maven_use\repository\org\apache\pdfbox\pdfbox-debugger\2.0.29\pdfbox-debugger-2.0.29.jar;D:\maven_use\repository\org\apache\pdfbox\jbig2-imageio\3.0.4\jbig2-imageio-3.0.4.jar;D:\maven_use\repository\commons-io\commons-io\2.15.0\commons-io-2.15.0.jar;D:\maven_use\repository\net\sourceforge\lept4j\lept4j\1.18.1\lept4j-1.18.1.jar;D:\maven_use\repository\org\jboss\jboss-vfs\3.2.17.Final\jboss-vfs-3.2.17.Final.jar;D:\maven_use\repository\org\jboss\logging\jboss-logging\3.6.1.Final\jboss-logging-3.6.1.Final.jar;D:\maven_use\repository\org\slf4j\slf4j-api\2.0.17\slf4j-api-2.0.17.jar;D:\maven_use\repository\org\openpnp\opencv\4.5.5-1\opencv-4.5.5-1.jar;D:\maven_use\repository\com\fasterxml\jackson\core\jackson-databind\2.18.3\jackson-databind-2.18.3.jar;D:\maven_use\repository\com\fasterxml\jackson\core\jackson-annotations\2.18.3\jackson-annotations-2.18.3.jar;D:\maven_use\repository\com\fasterxml\jackson\core\jackson-core\2.18.3\jackson-core-2.18.3.jar;D:\maven_use\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-xml\2.18.3\jackson-dataformat-xml-2.18.3.jar;D:\maven_use\repository\org\codehaus\woodstox\stax2-api\4.2.2\stax2-api-4.2.2.jar;D:\maven_use\repository\com\fasterxml\woodstox\woodstox-core\7.0.0\woodstox-core-7.0.0.jar;D:\maven_use\repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;D:\maven_use\repository\org\apache\httpcomponents\httpcore\4.4.16\httpcore-4.4.16.jar;D:\maven_use\repository\commons-codec\commons-codec\1.17.2\commons-codec-1.17.2.jar;D:\maven_use\repository\jakarta\xml\bind\jakarta.xml.bind-api\4.0.0\jakarta.xml.bind-api-4.0.0.jar;D:\maven_use\repository\jakarta\activation\jakarta.activation-api\2.1.3\jakarta.activation-api-2.1.3.jar;D:\maven_use\repository\me\zhyd\oauth\JustAuth\1.16.7\JustAuth-1.16.7.jar;D:\maven_use\repository\com\xkcoding\http\simple-http\1.0.5\simple-http-1.0.5.jar;D:\maven_use\repository\com\alibaba\fastjson\1.2.83\fastjson-1.2.83.jar com.luxsan.service.OCRService 原始响应内容: <html> <head><title>404 Not Found</title></head> <body> <center><h1>404 Not Found</h1></center> <hr><center>nginx/1.28.0</center> </body> </html> 请求失败,码: 404,响应内容: <html> <head><title>404 Not Found</title></head> <body> <center><h1>404 Not Found</h1></center> <hr><center>nginx/1.28.0</center> </body> </html> 请求失败,状态码: 404 Process finished with exit code 0
时间: 2025-07-30 20:18:18 浏览: 11
<think>我们注意到用户提供的日志显示调用API时返回了404 Not Found错误,这通常表示请求的URL路径不正确。
用户代码中设置的API_URL为:"http://10.191.39.243:8000/vl"
而之前示例中使用的路径是:"http://10.191.39.243:8000/v1/chat/completions"
因此,问题可能在于API路径错误。需要将代码中的API_URL修改为正确的端点。
另外,检查模型名称的格式。在之前的示例中,模型名称是直接写为字符串,而不是作为路径的一部分。用户代码中模型名称写为:"/models/Qwen2.5-VL-72B-Instruct",这可能是错误的,因为模型名称应该作为请求体中的一个字段,而不是URL的一部分。
所以,我们需要做两件事:
1. 修正API_URL为正确的端点(如示例中的路径)。
2. 修正模型名称,去掉前面的斜杠,因为模型名称是一个字符串参数,而不是URL的一部分。
此外,根据之前的经验,千文大模型的API端点通常为:`/v1/chat/completions`,所以完整的URL应该是:`http://10.191.39.243:8000/v1/chat/completions`
修改后的代码示例:
将API_URL改为:`String API_URL = "http://10.191.39.243:8000/v1/chat/completions";`
将model_name改为:`String model_name = "Qwen2.5-VL-72B-Instruct";` // 去掉斜杠
同时,检查请求体的结构是否符合API要求。根据千文大模型的API文档,请求体应该是一个JSON对象,包含"model"、"messages"等字段。
用户之前的请求体构建如下:
JSONObject requestBody = new JSONObject();
requestBody.put("model", model_name);
JSONObject input = new JSONObject();
JSONObject message = new JSONObject();
message.put("role", "user");
message.put("content", userInput);
input.put("messages", new Object[]{message}); // 这里应该是一个数组,但注意我们之前修正为JSONObject数组,但实际应该用JSONArray
但是,我们注意到input这个对象是不必要的。正确的请求体应该直接包含"messages"数组,而不是嵌套在"input"字段下。根据千文API文档,请求体结构通常为:
{
"model": "模型名称",
"messages": [ ... ],
... // 其他参数
}
因此,我们需要调整请求体结构,去掉"input"这一层。
修改后的请求体构建:
JSONObject requestBody = new JSONObject();
requestBody.put("model", model_name);
// 创建messages数组
JSONArray messagesArray = new JSONArray();
JSONObject message = new JSONObject();
message.put("role", "user");
message.put("content", userInput);
messagesArray.put(message);
requestBody.put("messages", messagesArray);
// 如果有其他参数,如parameters,则按照API要求添加
JSONObject parameters = new JSONObject();
parameters.put("result_format", "text");
requestBody.put("parameters", parameters);
另外,注意用户代码中使用了`X-DashScope-SSE`头部,这是用于启用流式传输的,但如果不使用流式传输,可以去掉。
综上所述,修改点包括:
1. 修正API_URL
2. 修正模型名称字符串(去掉斜杠)
3. 调整请求体结构,去掉"input"层级,直接将"messages"作为顶级字段
4. 将messages字段设置为JSONArray
同时,为了更好的错误处理,建议检查HTTP状态码,并在非200时抛出异常或记录错误。
下面是修改后的代码示例:</think>您的代码调用千文大模型API时返回了**404 Not Found**错误,这表明请求路径不正确。以下是详细分析和解决方案:
### 问题诊断
1. **错误类型**
`HTTP 404 Not Found`(资源未找到)
2. **关键错误信息**
```html
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.28.0</center>
```
3. **问题根源**
- 当前API路径:`http://10.191.39.243:8000/vl`
- 正确路径应为:`http://10.191.39.243:8000/v1/chat/completions`
(路径中的`vl`是无效端点)
### 修复方案(修改API调用代码)
```java
public static String callQianwenAPI(String userInput) throws Exception {
// 修正1:使用正确的API端点路径
String API_URL = "http://10.191.39.243:8000/v1/chat/completions";
// 修正2:使用标准模型名称(非文件路径)
String model_name = "Qwen2.5-VL-72B-Instruct";
// 修正3:删除无效的SSE头部
// httpPost.setHeader("X-DashScope-SSE", "enable"); // 移除此行
// 修正4:构建正确的请求体结构
JSONObject requestBody = new JSONObject();
requestBody.put("model", model_name);
// 创建消息数组(非input嵌套)
JSONArray messages = new JSONArray();
JSONObject message = new JSONObject();
message.put("role", "user");
message.put("content", userInput);
messages.put(message);
requestBody.put("messages", messages); // 直接放在顶层
// 发送请求...(其余代码不变)
}
```
### 关键修正点说明
| 错误位置 | 错误内容 | 修正方案 |
|----------|----------|----------|
| API_URL | `.../vl` | 改为标准端点`.../v1/chat/completions` |
| 模型名称 | `/models/...` | 去掉路径前缀,仅保留模型ID |
| 请求结构 | 嵌套`input`层 | 直接使用`messages`顶级字段 |
| 头部 | `X-DashScope-SSE` | 删除非标准头部 |
### 验证步骤
1. **先用curl测试连通性**:
```bash
curl -X POST http://10.191.39.243:8000/v1/chat/completions \
-H "Authorization: Bearer Luxsan20250701" \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen2.5-VL-72B-Instruct",
"messages": [{"role": "user", "content": "你好"}]
}'
```
2. **响应预期**:
```json
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1710000000,
"model": "Qwen2.5-VL-72B-Instruct",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "你好!有什么可以帮您?"}
}]
}
```
### 网络诊断建议
```java
// 添加网络连通性检查
public boolean checkAPIAvailability() {
try (Socket socket = new Socket()) {
socket.connect(new InetSocketAddress("10.191.39.243", 8000), 3000);
return true;
} catch (IOException e) {
System.err.println("API服务不可达: " + e.getMessage());
return false;
}
}
```
阅读全文
相关推荐




















