TASK:LLM;

This commit is contained in:
shahaibo
2025-05-19 10:47:02 +08:00
parent a67b487dc0
commit 738144ad22
3 changed files with 20 additions and 18 deletions

View File

@@ -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);

View 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();