|
@@ -55,32 +55,21 @@ public class AiApiDemoTest {
|
|
|
|
|
|
@Test
|
|
|
public void testAll() throws Exception {
|
|
|
- // getLlmBalance();
|
|
|
- // autoGenerateQuestion();
|
|
|
+ // testOcr();
|
|
|
// autoScore();
|
|
|
- // chat();
|
|
|
+ // autoGenerateQuestion();
|
|
|
// chatTemplate();
|
|
|
+ // chat();
|
|
|
// getPromptTemplate();
|
|
|
- // testOcr();
|
|
|
- }
|
|
|
-
|
|
|
- private void getLlmBalance() throws Exception {
|
|
|
- LlmAppBalance result = aiService.getLlmBalance(baseUrl, secret, LlmAppType.AUTO_SCORE);
|
|
|
- // LlmAppBalance result = llmApiClient.getBalance(baseUrl, secret, LlmAppType.AUTO_SCORE);
|
|
|
- System.out.println(new JsonMapper().writeValueAsString(result));
|
|
|
+ // getLlmBalance();
|
|
|
}
|
|
|
|
|
|
- private void autoGenerateQuestion() throws Exception {
|
|
|
- Map<String, Object> param = new HashMap<String, Object>() {{
|
|
|
- put("courseName", "语文");
|
|
|
- put("questionTypeName", "单选题");
|
|
|
- put("questionType", "SINGLE_ANSWER_QUESTION");
|
|
|
- put("knowledgePoint", "诗词");
|
|
|
- put("knowledgeNotes", "作者");
|
|
|
- }};
|
|
|
+ private void testOcr() throws Exception {
|
|
|
+ File file = new File("D:\\home\\test.png");
|
|
|
+ MultipartBody.Part part = UploadFile.build("image", file.getName(), file);
|
|
|
|
|
|
- List<String> result = aiService.autoGenerateQuestion(baseUrl, secret, param);
|
|
|
- System.out.println(new JsonMapper().writeValueAsString(result));
|
|
|
+ String result = ocrApiClient.forImage(baseUrl, secret, OcrType.HANDWRITING, part);
|
|
|
+ System.out.println(result);
|
|
|
}
|
|
|
|
|
|
private void autoScore() throws Exception {
|
|
@@ -105,40 +94,59 @@ public class AiApiDemoTest {
|
|
|
System.out.println(new JsonMapper().writeValueAsString(result));
|
|
|
}
|
|
|
|
|
|
- private void chat() throws Exception {
|
|
|
- ChatRequest request = new ChatRequest();
|
|
|
- request.addMessage(ChatRole.user, "请输出1加1等于几?");
|
|
|
+ private void autoGenerateQuestion() throws Exception {
|
|
|
+ Map<String, Object> param = new HashMap<String, Object>() {{
|
|
|
+ put("courseName", "语文");
|
|
|
+ put("questionTypeName", "单选题");
|
|
|
+ put("syllabus", "熟练掌握诗词");// 教学大纲
|
|
|
+ put("knowledgePoint", "诗词");// 知识点
|
|
|
+ put("knowledgeNotes", "作者出处");// 知识点补充说明
|
|
|
+ // SINGLE_ANSWER_QUESTION、MULTIPLE_ANSWER_QUESTION、BOOL_ANSWER_QUESTION、FILL_BLANK_QUESTION、TEXT_ANSWER_QUESTION
|
|
|
+ put("questionType", "MULTIPLE_ANSWER_QUESTION");
|
|
|
+ // optionCount、blankCount、answerCount
|
|
|
+ put("optionCount", 4);
|
|
|
+ }};
|
|
|
|
|
|
- ChatResult result = llmApiClient.chat(baseUrl, secret, LlmAppType.AUTO_SCORE, request);
|
|
|
- List<String> values = result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
|
- .map(choice -> choice.getMessage().getContent()).collect(Collectors.toList());
|
|
|
- System.out.println(new JsonMapper().writeValueAsString(values));
|
|
|
+ List<String> result = aiService.autoGenerateQuestion(baseUrl, secret, param);
|
|
|
+ System.out.println(new JsonMapper().writeValueAsString(result));
|
|
|
}
|
|
|
|
|
|
private void chatTemplate() throws Exception {
|
|
|
Map<String, Object> param = new HashMap<String, Object>() {{
|
|
|
put("courseName", "语文");
|
|
|
put("questionTypeName", "单选题");
|
|
|
- put("questionType", "SINGLE_ANSWER_QUESTION");
|
|
|
- put("knowledgePoint", "诗词");
|
|
|
- put("knowledgeNotes", "作者");
|
|
|
+ put("syllabus", "熟练掌握诗词");// 教学大纲
|
|
|
+ put("knowledgePoint", "诗词");// 知识点
|
|
|
+ put("knowledgeNotes", "作者出处");// 知识点补充说明
|
|
|
+ // SINGLE_ANSWER_QUESTION、MULTIPLE_ANSWER_QUESTION、BOOL_ANSWER_QUESTION、FILL_BLANK_QUESTION、TEXT_ANSWER_QUESTION
|
|
|
+ put("questionType", "MULTIPLE_ANSWER_QUESTION");
|
|
|
+ // optionCount、blankCount、answerCount
|
|
|
+ put("optionCount", 4);
|
|
|
}};
|
|
|
|
|
|
ChatResult result = llmApiClient.chatTemplate(baseUrl, secret, LlmAppType.AUTO_GENERATE_QUESTION, param);
|
|
|
System.out.println(new JsonMapper().writeValueAsString(result));
|
|
|
}
|
|
|
|
|
|
+ private void chat() throws Exception {
|
|
|
+ ChatRequest request = new ChatRequest();
|
|
|
+ request.addMessage(ChatRole.user, "请输出1加1等于几?");
|
|
|
+
|
|
|
+ ChatResult result = llmApiClient.chat(baseUrl, secret, LlmAppType.AUTO_SCORE, request);
|
|
|
+ List<String> values = result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
|
+ .map(choice -> choice.getMessage().getContent()).collect(Collectors.toList());
|
|
|
+ System.out.println(new JsonMapper().writeValueAsString(values));
|
|
|
+ }
|
|
|
+
|
|
|
private void getPromptTemplate() throws Exception {
|
|
|
PromptTemplate result = llmApiClient.getPromptTemplate(baseUrl, secret, LlmAppType.AUTO_SCORE);
|
|
|
System.out.println(new JsonMapper().writeValueAsString(result));
|
|
|
}
|
|
|
|
|
|
- private void testOcr() throws Exception {
|
|
|
- File file = new File("D:\\home\\test.png");
|
|
|
- MultipartBody.Part part = UploadFile.build("image", file.getName(), file);
|
|
|
-
|
|
|
- String result = ocrApiClient.forImage(baseUrl, secret, OcrType.HANDWRITING, part);
|
|
|
- System.out.println(result);
|
|
|
+ private void getLlmBalance() throws Exception {
|
|
|
+ LlmAppBalance result = aiService.getLlmBalance(baseUrl, secret, LlmAppType.AUTO_SCORE);
|
|
|
+ // LlmAppBalance result = llmApiClient.getBalance(baseUrl, secret, LlmAppType.AUTO_SCORE);
|
|
|
+ System.out.println(new JsonMapper().writeValueAsString(result));
|
|
|
}
|
|
|
|
|
|
}
|