From 8c597db8a9b41412db6961ae5864b861309b8014 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Tue, 20 May 2025 16:54:20 +0800 Subject: [PATCH] =?UTF-8?q?TASK:LLM=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/controller/LLMController.java | 6 ++++-- src/main/java/com/ai/da/python/PythonService.java | 4 +++- src/main/java/com/ai/da/service/LLMService.java | 2 +- src/main/java/com/ai/da/service/impl/LLMServiceImpl.java | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ai/da/controller/LLMController.java b/src/main/java/com/ai/da/controller/LLMController.java index bfb16785..d54490be 100644 --- a/src/main/java/com/ai/da/controller/LLMController.java +++ b/src/main/java/com/ai/da/controller/LLMController.java @@ -65,8 +65,10 @@ public class LLMController { @ApiOperation(value = "对话创建项目") @GetMapping(value = "/chatCreateProject") - public Response chatCreateProject(@RequestParam String prompt, @RequestParam String process) { - return Response.success(llmService.chatCreateProject(prompt, process)); + public Response chatCreateProject(@RequestParam String prompt, @RequestParam String process, + @RequestParam(required = false) String fileUrl, + @RequestParam(required = false) List imageUrlList) { + return Response.success(llmService.chatCreateProject(prompt, process, fileUrl, imageUrlList)); } @ApiOperation(value = "上传文件") diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 18623875..f686f881 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -4383,7 +4383,7 @@ public class PythonService { throw new BusinessException("poseTransferBatch.interface.exception"); } - public JSONObject getProjectParam(String prompt) { + public JSONObject getProjectParam(String prompt, String fileUrl, List imageUrlList) { OkHttpClient client = new OkHttpClient().newBuilder() .connectTimeout(30, TimeUnit.SECONDS) .pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒) @@ -4393,6 +4393,8 @@ public class PythonService { MediaType mediaType = MediaType.parse("application/json"); Map content = Maps.newHashMap(); content.put("prompt", prompt); + content.put("image_list", !CollectionUtils.isEmpty(imageUrlList) ? imageUrlList : null); + content.put("file_list", !StringUtils.isEmpty(fileUrl) ? Collections.singletonList(fileUrl) : null); RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content)); log.info("getProjectParam 请求地址: {}", accessPythonIp + ":" + accessPythonPort + "/api/extraction_project_info"); diff --git a/src/main/java/com/ai/da/service/LLMService.java b/src/main/java/com/ai/da/service/LLMService.java index 807817a6..5c370d32 100644 --- a/src/main/java/com/ai/da/service/LLMService.java +++ b/src/main/java/com/ai/da/service/LLMService.java @@ -33,7 +33,7 @@ public interface LLMService { SseEmitter stream(String prompt, Long projectId, String fileUrl, List imageUrlList, String token, Boolean enableThinking); - Long chatCreateProject(String prompt, String process); + Long chatCreateProject(String prompt, String process, String fileUrl, List imageUrlList); List uploadFile(MultipartFile file); diff --git a/src/main/java/com/ai/da/service/impl/LLMServiceImpl.java b/src/main/java/com/ai/da/service/impl/LLMServiceImpl.java index af8cc65f..97445da1 100644 --- a/src/main/java/com/ai/da/service/impl/LLMServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/LLMServiceImpl.java @@ -202,9 +202,9 @@ public class LLMServiceImpl implements LLMService { } @Override - public Long chatCreateProject(String prompt, String process) { + public Long chatCreateProject(String prompt, String process, String fileUrl, List imageUrlList) { AuthPrincipalVo userHolder = UserContext.getUserHolder(); - JSONObject jsonObject = pythonService.getProjectParam(prompt); + JSONObject jsonObject = pythonService.getProjectParam(prompt, fileUrl, imageUrlList); JSONObject data = jsonObject.getJSONObject("data"); Project project = new Project(); LocalDateTime now = LocalDateTime.now();