llm config fix

This commit is contained in:
Chuck1sn
2025-05-25 18:17:50 +08:00
parent b6f72942ad
commit 402c421370
8 changed files with 42 additions and 2 deletions

View File

@@ -12,6 +12,8 @@ public class LlmVm {
@NotEmpty(message = "模型名称不能为空") private String modelName;
@NotEmpty(message = "模型类型不能为空") private String type;
@NotEmpty(message = "apikey 不能为空") private String apiKey;
@NotEmpty(message = "url 不能为空") private String url;

View File

@@ -26,7 +26,8 @@ public class LlmRepository extends AiLlmConfigDao {
public Result<Record> pageFetchBy(PageRequestDto pageRequestDto, LlmQueryDto llmQueryDto) {
return ctx()
.select(
AI_LLM_CONFIG.asterisk(), DSL.count().over().as("total_llm").convertFrom(Long::valueOf))
AI_LLM_CONFIG.asterisk(),
DSL.count().over().as("total_llm").convertFrom(Long::valueOf))
.from(AI_LLM_CONFIG)
.where(
StringUtils.isNotEmpty(llmQueryDto.name())

View File

@@ -18,6 +18,8 @@ import org.jooq.generated.mjga.tables.pojos.AiLlmConfig;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import static org.jooq.generated.mjga.Tables.AI_LLM_CONFIG;
@Service
@RequiredArgsConstructor
@Slf4j
@@ -42,7 +44,11 @@ public class LlmService {
if (records.isEmpty()) {
return PageResponseDto.empty();
}
List<LlmVm> llmVms = records.into(LlmVm.class);
List<LlmVm> llmVms = records.map((record) -> {
LlmVm into = record.into(LlmVm.class);
into.setType(record.get(AI_LLM_CONFIG.TYPE).getLiteral());
return into;
});
Long totalLlm = records.get(0).getValue("total_llm", Long.class);
return new PageResponseDto<>(totalLlm, llmVms);
}

View File

@@ -1129,6 +1129,7 @@
"modelName",
"name",
"priority",
"type",
"url"
],
"type": "object",
@@ -1143,6 +1144,9 @@
"modelName": {
"type": "string"
},
"type": {
"type": "string"
},
"apiKey": {
"type": "string"
},

View File

@@ -545,6 +545,7 @@ export interface components {
id: number;
name: string;
modelName: string;
type: string;
apiKey: string;
url: string;
enable: boolean;

View File

@@ -34,6 +34,14 @@
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 "
required />
</div>
<div class="col-span-2 sm:col-span-1">
<label for="type" class="block mb-2 text-sm font-medium text-gray-900 ">类型</label>
<select id="type" v-model="formData.type"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5">
<option :value="'CHAT'">聊天</option>
<option :value="'EMBEDDING'">嵌入</option>
</select>
</div>
<div class="col-span-2">
<label for="apiKey" class="block mb-2 text-sm font-medium autocomplete text-gray-900 ">apiKey</label>
<input type="text" id="apiKey" autocomplete="new-password" v-model="formData.apiKey"
@@ -121,6 +129,9 @@ const handleSubmit = async () => {
priority: z.number({
message: "优先级必须为数字",
}),
type: z.string({
message: "类型不能为空",
}),
});
const validatedData = llmSchema.parse(formData.value);
await onSubmit(validatedData);

View File

@@ -0,0 +1,11 @@
import client from "../../api/client";
const useAiAction = () => {
const actionChat = (message: string) => {
return client.POST("/ai/action/chat", {
body: message,
});
};
return { actionChat };
};

View File

@@ -40,6 +40,7 @@
</th>
<th scope="col" class="px-6 py-3">名称</th>
<th scope="col" class="px-6 py-3">模型名称</th>
<th scope="col" class="px-6 py-3">类型</th>
<th scope="col" class="px-6 py-3">apiKey</th>
<th scope="col" class="px-6 py-3">url</th>
<th scope="col" class="px-6 py-3">状态</th>
@@ -62,6 +63,9 @@
<td class="px-6 py-4 max-w-sm overflow-hidden text-ellipsis">{{
`${llm.modelName}` }}
</td>
<td class="px-6 py-4 max-w-sm overflow-hidden text-ellipsis">{{
llm.type === 'CHAT' ? '聊天' : '嵌入' }}
</td>
<td class="px-6 py-4 max-w-sm overflow-hidden text-ellipsis">{{
llm.apiKey }}
</td>