TASK:LLM;

This commit is contained in:
shahaibo
2025-05-18 12:46:12 +08:00
parent bf92edb267
commit 59ffa38ff7
23 changed files with 600 additions and 8 deletions

View File

@@ -4382,4 +4382,46 @@ public class PythonService {
log.error("PythonService##poseTransferBatch接口调用失败###{}", response);
throw new BusinessException("poseTransferBatch.interface.exception");
}
public JSONObject getProjectParam(String prompt) {
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
.build();
MediaType mediaType = MediaType.parse("application/json");
Map<String, Object> content = Maps.newHashMap();
content.put("prompt", prompt);
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
log.info("getProjectParam 请求地址: {}", accessPythonIp + ":" + accessPythonPort + "/api/extraction_project_info");
Request request = new Request.Builder()
.url(accessPythonIp + ":" + accessPythonPort + "/api/extraction_project_info")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = null;
try {
response = client.newCall(request).execute();
} catch (IOException ioException) {
log.error("PythonService##getProjectParam异常###{}", ExceptionUtil.getThrowableList(ioException));
throw new BusinessException("getProjectParam.interface.exception");
}
String responseBody;
if (response.isSuccessful() && response.body() != null) {
try {
responseBody = response.body().string();
JSONObject responseObject = JSON.parseObject(responseBody);
log.info("PythonService##responseObject###{}", responseObject);
return responseObject;
} catch (IOException | JSONException e) {
log.error("PythonService##getProjectParam异常###{}", e.getMessage());
throw new BusinessException("getProjectParam.interface.exception");
}
}
log.error("PythonService##getProjectParam接口调用失败###{}", response);
throw new BusinessException("getProjectParam.interface.exception");
}
}