|
@@ -7,8 +7,10 @@ import com.qmth.boot.core.exception.ForbiddenException;
|
|
|
import com.qmth.boot.tools.signature.SignatureType;
|
|
|
import com.qmth.ops.api.security.AccessOrg;
|
|
|
import com.qmth.ops.biz.domain.LlmOrgConfig;
|
|
|
+import com.qmth.ops.biz.domain.LlmPromptTemplate;
|
|
|
import com.qmth.ops.biz.service.LlmClientService;
|
|
|
import com.qmth.ops.biz.service.LlmOrgConfigService;
|
|
|
+import com.qmth.ops.biz.service.LlmPromptTemplateService;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -24,6 +26,9 @@ public class LlmController {
|
|
|
@Resource
|
|
|
private LlmClientService llmClientService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private LlmPromptTemplateService llmPromptTemplateService;
|
|
|
+
|
|
|
@PostMapping(AiConstants.LLM_CHAT_PATH)
|
|
|
public ChatResult chat(@RequestAttribute AccessOrg accessOrg,
|
|
|
@RequestHeader(AiConstants.LLM_APP_TYPE_HEADER) LlmAppType type,
|
|
@@ -42,8 +47,8 @@ public class LlmController {
|
|
|
@PostMapping(AiConstants.LLM_BALANCE_PATH)
|
|
|
public LlmAppBalance balance(@RequestAttribute AccessOrg accessOrg,
|
|
|
@RequestHeader(AiConstants.LLM_APP_TYPE_HEADER) LlmAppType type) {
|
|
|
- LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg(), type);
|
|
|
LlmAppBalance balance = new LlmAppBalance();
|
|
|
+ LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg(), type);
|
|
|
if (config != null) {
|
|
|
balance.setPermitCount(config.getPermitCount());
|
|
|
balance.setLeftCount(config.getLeftCount());
|
|
@@ -54,6 +59,15 @@ public class LlmController {
|
|
|
@PostMapping(AiConstants.LLM_PROMPT_TEMPLATE_PATH)
|
|
|
public PromptTemplate getPromptTemplate(@RequestAttribute AccessOrg accessOrg,
|
|
|
@RequestHeader(AiConstants.LLM_APP_TYPE_HEADER) LlmAppType type) {
|
|
|
- return null;
|
|
|
+ PromptTemplate template = new PromptTemplate();
|
|
|
+ LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg(), type);
|
|
|
+ if (config != null) {
|
|
|
+ LlmPromptTemplate llmPromptTemplate = llmPromptTemplateService.findByAppType(type, config.getModelId());
|
|
|
+ if (llmPromptTemplate != null) {
|
|
|
+ template.setSystem(llmPromptTemplate.getSystem());
|
|
|
+ template.setUser(llmPromptTemplate.getUser());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return template;
|
|
|
}
|
|
|
}
|