|
@@ -36,7 +36,7 @@ public class LlmController {
|
|
|
public ChatResult chat(@RequestAttribute AccessOrg accessOrg,
|
|
|
@RequestHeader(AiConstants.LLM_APP_TYPE_HEADER) LlmAppType type,
|
|
|
@RequestBody @Validated ChatRequest request) throws Exception {
|
|
|
- LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg(), type);
|
|
|
+ LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg().getId(), type);
|
|
|
if (config == null || config.getLeftCount() <= 0) {
|
|
|
throw new ForbiddenException(
|
|
|
"Chat api is disabled or exhausted for org=" + accessOrg.getOrg().getCode() + ", app_type=" + type);
|
|
@@ -50,12 +50,12 @@ public class LlmController {
|
|
|
public ChatResult chatTemplate(@RequestAttribute AccessOrg accessOrg,
|
|
|
@RequestHeader(AiConstants.LLM_APP_TYPE_HEADER) LlmAppType type, @RequestBody Map<String, Object> param)
|
|
|
throws Exception {
|
|
|
- LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg(), type);
|
|
|
+ LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg().getId(), type);
|
|
|
if (config == null || config.getLeftCount() <= 0) {
|
|
|
throw new ForbiddenException(
|
|
|
"Chat api is disabled or exhausted for org=" + accessOrg.getOrg().getCode() + ", app_type=" + type);
|
|
|
}
|
|
|
- LlmPromptTemplate llmPromptTemplate = llmPromptTemplateService.findByAppType(type, config.getModelId());
|
|
|
+ LlmPromptTemplate llmPromptTemplate = llmPromptTemplateService.findByModelAndAppType(config.getModelId(), type);
|
|
|
if (llmPromptTemplate == null) {
|
|
|
throw new NotFoundException(
|
|
|
"Chat prompt template not found for app_type=" + type + ", modelId=" + config.getModelId());
|
|
@@ -76,7 +76,7 @@ public class LlmController {
|
|
|
public LlmAppBalance balance(@RequestAttribute AccessOrg accessOrg,
|
|
|
@RequestHeader(AiConstants.LLM_APP_TYPE_HEADER) LlmAppType type) {
|
|
|
LlmAppBalance balance = new LlmAppBalance();
|
|
|
- LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg(), type);
|
|
|
+ LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg().getId(), type);
|
|
|
if (config != null) {
|
|
|
balance.setPermitCount(config.getPermitCount());
|
|
|
balance.setLeftCount(config.getLeftCount());
|
|
@@ -88,9 +88,10 @@ public class LlmController {
|
|
|
public PromptTemplate getPromptTemplate(@RequestAttribute AccessOrg accessOrg,
|
|
|
@RequestHeader(AiConstants.LLM_APP_TYPE_HEADER) LlmAppType type) {
|
|
|
PromptTemplate template = new PromptTemplate();
|
|
|
- LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg(), type);
|
|
|
+ LlmOrgConfig config = llmOrgConfigService.findByOrgAndAppType(accessOrg.getOrg().getId(), type);
|
|
|
if (config != null) {
|
|
|
- LlmPromptTemplate llmPromptTemplate = llmPromptTemplateService.findByAppType(type, config.getModelId());
|
|
|
+ LlmPromptTemplate llmPromptTemplate = llmPromptTemplateService
|
|
|
+ .findByModelAndAppType(config.getModelId(), type);
|
|
|
if (llmPromptTemplate != null) {
|
|
|
template.setSystem(llmPromptTemplate.getSystem());
|
|
|
template.setUser(llmPromptTemplate.getUser());
|