|
|
@@ -1,5 +1,6 @@
|
|
|
package com.njuzr.eaibackend.service;
|
|
|
|
|
|
+import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
import com.njuzr.eaibackend.exception.MyException;
|
|
|
import com.njuzr.eaibackend.po.AIEntry;
|
|
|
import com.njuzr.eaibackend.utils.WebClientUtil;
|
|
|
@@ -50,6 +51,12 @@ public class AIRequestService {
|
|
|
@Value("${config.llm.QWen14B.url}")
|
|
|
private String qWen14BUrl;
|
|
|
|
|
|
+ @Value("${config.llm.PreSentenceWorkflowChatGLM4.url}")
|
|
|
+ private String preSentenceWorkflowglm4Url;
|
|
|
+
|
|
|
+ @Value("${config.llm.PreSentenceWorkflowChatGLM4.token}")
|
|
|
+ private String preSentenceWorkflowglm4Token;
|
|
|
+
|
|
|
public AIRequestService(WebClientUtil chatgptClient, WebClientUtil chatglmClient, WebClientUtil qwenClient) {
|
|
|
this.chatgptClient = chatgptClient;
|
|
|
this.chatglmClient = chatglmClient;
|
|
|
@@ -107,6 +114,66 @@ public class AIRequestService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public WorkflowRunResponse requestPreSentenceWorkflow(String content, String assignmentDescription, String sentence) {
|
|
|
+ MyWorkflowRequestInput input = new MyWorkflowRequestInput(content, assignmentDescription,sentence);
|
|
|
+ MyWorkflowRequestObject requestObject = new MyWorkflowRequestObject("abc-1234", "blocking", input);
|
|
|
+ String url = preSentenceWorkflowglm4Url;
|
|
|
+
|
|
|
+ try {
|
|
|
+ return chatglmClient.postWithToken(url, requestObject, WorkflowRunResponse.class, preSentenceWorkflowglm4Token);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("WebClient请求失败,AI请求失败~"+e.getMessage());
|
|
|
+ throw new MyException(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()+":"+"服务器请求AI出错");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ @AllArgsConstructor
|
|
|
+ static class MyWorkflowRequestObject {
|
|
|
+ private String user;
|
|
|
+ private String response_mode;
|
|
|
+ private MyWorkflowRequestInput inputs;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ @AllArgsConstructor
|
|
|
+ static class MyWorkflowRequestInput {
|
|
|
+ private String content;
|
|
|
+ private String assignment_description;
|
|
|
+ private String sentence;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ static class WorkflowRunResponse {
|
|
|
+ private String task_id;
|
|
|
+ private String workflow_run_id;
|
|
|
+ private WorkflowRunData data;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ static
|
|
|
+ class WorkflowRunData {
|
|
|
+ private String id;
|
|
|
+ private String workflow_id;
|
|
|
+ private String status;
|
|
|
+ private Outputs outputs;
|
|
|
+ private Object error;
|
|
|
+ private double elapsed_time;
|
|
|
+ private int total_tokens;
|
|
|
+ private int total_steps;
|
|
|
+ private long created_at;
|
|
|
+ private long finished_at;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ static
|
|
|
+ class Outputs {
|
|
|
+ private String result_type;
|
|
|
+ private String result_category;
|
|
|
+ private String result_content;
|
|
|
+ }
|
|
|
+
|
|
|
@Data
|
|
|
@AllArgsConstructor
|
|
|
static class MyRequestObject {
|