TASK:LLM;
This commit is contained in:
@@ -57,14 +57,15 @@ public class LLMController {
|
||||
public SseEmitter streamPrompt(@RequestParam String prompt,
|
||||
@RequestParam Long projectId,
|
||||
@RequestParam(required = false) String fileUrl,
|
||||
@RequestParam(required = false) List<String> imageUrlList,
|
||||
@RequestParam String token) {
|
||||
return llmService.stream(prompt, projectId, fileUrl, token);
|
||||
return llmService.stream(prompt, projectId, fileUrl, imageUrlList, token);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "对话创建项目")
|
||||
@GetMapping(value = "/chatCreateProject")
|
||||
public Response<Long> chatCreateProject(@RequestParam String prompt) {
|
||||
return Response.success(llmService.chatCreateProject(prompt));
|
||||
public Response<Long> chatCreateProject(@RequestParam String prompt, @RequestParam String process) {
|
||||
return Response.success(llmService.chatCreateProject(prompt, process));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "上传文件")
|
||||
|
||||
@@ -31,9 +31,9 @@ import java.util.Set;
|
||||
*/
|
||||
public interface LLMService {
|
||||
|
||||
SseEmitter stream(String prompt, Long projectId, String fileUrl, String token);
|
||||
SseEmitter stream(String prompt, Long projectId, String fileUrl, List<String> imageUrlList, String token);
|
||||
|
||||
Long chatCreateProject(String prompt);
|
||||
Long chatCreateProject(String prompt, String process);
|
||||
|
||||
List<String> uploadFile(MultipartFile file);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class LLMServiceImpl implements LLMService {
|
||||
private final ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
||||
@Override
|
||||
public SseEmitter stream(String prompt, Long projectId, String fileUrl, String token) {
|
||||
public SseEmitter stream(String prompt, Long projectId, String fileUrl, List<String> imageUrlList, String token) {
|
||||
SseEmitter emitter = new SseEmitter(0L); // 永不超时
|
||||
|
||||
executor.submit(() -> {
|
||||
@@ -86,7 +86,7 @@ public class LLMServiceImpl implements LLMService {
|
||||
JSONObject jsonBodyObject = new JSONObject();
|
||||
jsonBodyObject.put("session_id", projectId.toString());
|
||||
jsonBodyObject.put("role", "user");
|
||||
jsonBodyObject.put("image", ""); // 可扩展
|
||||
jsonBodyObject.put("image", imageUrlList); // 可扩展
|
||||
jsonBodyObject.put("file", fileUrl != null ? fileUrl : "");
|
||||
jsonBodyObject.put("message", prompt);
|
||||
jsonBodyObject.put("enable_thinking", false);
|
||||
@@ -161,7 +161,7 @@ public class LLMServiceImpl implements LLMService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long chatCreateProject(String prompt) {
|
||||
public Long chatCreateProject(String prompt, String process) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
JSONObject jsonObject = pythonService.getProjectParam(prompt);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
@@ -172,16 +172,17 @@ public class LLMServiceImpl implements LLMService {
|
||||
project.setAccountId(userHolder.getId());
|
||||
project.setName(data.getString("project_name"));
|
||||
project.setOriginal(1);
|
||||
String process = data.getString("process");
|
||||
if (StringUtils.isEmpty(process)) {
|
||||
project.setProcess(DesignProcess.SERIES_DESIGN.name());
|
||||
}else {
|
||||
if (DesignProcess.isValidName(process)) {
|
||||
project.setProcess(process);
|
||||
}else {
|
||||
project.setProcess(DesignProcess.SERIES_DESIGN.name());
|
||||
}
|
||||
}
|
||||
// String process = data.getString("process");
|
||||
// if (StringUtils.isEmpty(process)) {
|
||||
// project.setProcess(DesignProcess.SERIES_DESIGN.name());
|
||||
// }else {
|
||||
// if (DesignProcess.isValidName(process)) {
|
||||
// project.setProcess(process);
|
||||
// }else {
|
||||
// project.setProcess(DesignProcess.SERIES_DESIGN.name());
|
||||
// }
|
||||
// }
|
||||
project.setProcess(process);
|
||||
projectMapper.insert(project);
|
||||
|
||||
Workspace workspace = new Workspace();
|
||||
|
||||
Reference in New Issue
Block a user