|
@@ -38,23 +38,25 @@ public class AiService {
|
|
/**
|
|
/**
|
|
* 获取当前机构大模型接口调用次数余额
|
|
* 获取当前机构大模型接口调用次数余额
|
|
*
|
|
*
|
|
- * @param appType 大模型接口应用类型
|
|
|
|
|
|
+ * @param baseUrl 接口前缀地址,默认取配置文件的值(选填)
|
|
* @param signature 使用当前机构AK作为鉴权信息
|
|
* @param signature 使用当前机构AK作为鉴权信息
|
|
|
|
+ * @param appType 大模型接口应用类型
|
|
* @return 调用次数余额
|
|
* @return 调用次数余额
|
|
*/
|
|
*/
|
|
- public LlmAppBalance getLlmBalance(@NotNull LlmAppType appType, @NotNull SignatureInfo signature) {
|
|
|
|
- return llmApiClient.getBalance(signature, appType);
|
|
|
|
|
|
+ public LlmAppBalance getLlmBalance(String baseUrl, @NotNull SignatureInfo signature, @NotNull LlmAppType appType) {
|
|
|
|
+ return llmApiClient.getBalance(baseUrl, signature, appType);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 使用自定义提示词进行自动命题
|
|
* 使用自定义提示词进行自动命题
|
|
*
|
|
*
|
|
- * @param request 大模型通用Chat请求
|
|
|
|
|
|
+ * @param baseUrl 接口前缀地址,默认取配置文件的值(选填)
|
|
* @param signature 使用当前机构AK作为鉴权信息
|
|
* @param signature 使用当前机构AK作为鉴权信息
|
|
|
|
+ * @param request 大模型通用Chat请求
|
|
* @return 大模型返回的文本集合
|
|
* @return 大模型返回的文本集合
|
|
*/
|
|
*/
|
|
- public List<String> autoGenerateQuestion(@NotNull ChatRequest request, @NotNull SignatureInfo signature) {
|
|
|
|
- ChatResult result = llmApiClient.chat(signature, LlmAppType.AUTO_GENERATE_QUESTION, request);
|
|
|
|
|
|
+ public List<String> autoGenerateQuestion(String baseUrl, @NotNull SignatureInfo signature, @NotNull ChatRequest request) {
|
|
|
|
+ ChatResult result = llmApiClient.chat(baseUrl, signature, LlmAppType.AUTO_GENERATE_QUESTION, request);
|
|
return result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
return result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
.map(choice -> choice.getMessage().getContent()).collect(Collectors.toList());
|
|
.map(choice -> choice.getMessage().getContent()).collect(Collectors.toList());
|
|
}
|
|
}
|
|
@@ -62,12 +64,13 @@ public class AiService {
|
|
/**
|
|
/**
|
|
* 使用预设模版进行自动命题
|
|
* 使用预设模版进行自动命题
|
|
*
|
|
*
|
|
- * @param param 基于预设模版的参数对象,可以使用Map或自定义Object
|
|
|
|
|
|
+ * @param baseUrl 接口前缀地址,默认取配置文件的值(选填)
|
|
* @param signature 使用当前机构AK作为鉴权信息
|
|
* @param signature 使用当前机构AK作为鉴权信息
|
|
|
|
+ * @param param 基于预设模版的参数对象,可以使用Map或自定义Object
|
|
* @return 大模型返回的文本集合
|
|
* @return 大模型返回的文本集合
|
|
*/
|
|
*/
|
|
- public List<String> autoGenerateQuestion(@NotNull Object param, @NotNull SignatureInfo signature) {
|
|
|
|
- ChatResult result = llmApiClient.chatTemplate(signature, LlmAppType.AUTO_GENERATE_QUESTION, param);
|
|
|
|
|
|
+ public List<String> autoGenerateQuestion(String baseUrl, @NotNull SignatureInfo signature, @NotNull Object param) {
|
|
|
|
+ ChatResult result = llmApiClient.chatTemplate(baseUrl, signature, LlmAppType.AUTO_GENERATE_QUESTION, param);
|
|
return result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
return result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
.map(choice -> choice.getMessage().getContent()).collect(Collectors.toList());
|
|
.map(choice -> choice.getMessage().getContent()).collect(Collectors.toList());
|
|
}
|
|
}
|
|
@@ -75,11 +78,12 @@ public class AiService {
|
|
/**
|
|
/**
|
|
* 使用预设模版进行自动判分,考生作答为文本
|
|
* 使用预设模版进行自动判分,考生作答为文本
|
|
*
|
|
*
|
|
- * @param request 自动判分请求参数
|
|
|
|
|
|
+ * @param baseUrl 接口前缀地址,默认取配置文件的值(选填)
|
|
* @param signature 使用当前机构AK作为鉴权信息
|
|
* @param signature 使用当前机构AK作为鉴权信息
|
|
|
|
+ * @param request 自动判分请求参数
|
|
* @return 判分结果;null表示无法获取判分结果
|
|
* @return 判分结果;null表示无法获取判分结果
|
|
*/
|
|
*/
|
|
- public AutoScoreResult autoScore(@NotNull @Validated AutoScoreRequest request, @NotNull SignatureInfo signature) {
|
|
|
|
|
|
+ public AutoScoreResult autoScore(String baseUrl, @NotNull SignatureInfo signature, @NotNull @Validated AutoScoreRequest request) {
|
|
if (StringUtils.isBlank(request.getSubjectName())) {
|
|
if (StringUtils.isBlank(request.getSubjectName())) {
|
|
throw new IllegalArgumentException("科目名称不能为空");
|
|
throw new IllegalArgumentException("科目名称不能为空");
|
|
}
|
|
}
|
|
@@ -102,7 +106,7 @@ public class AiService {
|
|
throw new IllegalArgumentException("最小间隔分必须大于0");
|
|
throw new IllegalArgumentException("最小间隔分必须大于0");
|
|
}
|
|
}
|
|
|
|
|
|
- ChatResult result = llmApiClient.chatTemplate(signature, LlmAppType.AUTO_SCORE, request);
|
|
|
|
|
|
+ ChatResult result = llmApiClient.chatTemplate(baseUrl, signature, LlmAppType.AUTO_SCORE, request);
|
|
String text = result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
String text = result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
.map(choice -> choice.getMessage().getContent()).findFirst().orElse("");
|
|
.map(choice -> choice.getMessage().getContent()).findFirst().orElse("");
|
|
|
|
|