mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-04-10 16:07:06 +00:00
llm config fix
This commit is contained in:
@@ -12,6 +12,8 @@ public class LlmVm {
|
|||||||
|
|
||||||
@NotEmpty(message = "模型名称不能为空") private String modelName;
|
@NotEmpty(message = "模型名称不能为空") private String modelName;
|
||||||
|
|
||||||
|
@NotEmpty(message = "模型类型不能为空") private String type;
|
||||||
|
|
||||||
@NotEmpty(message = "apikey 不能为空") private String apiKey;
|
@NotEmpty(message = "apikey 不能为空") private String apiKey;
|
||||||
|
|
||||||
@NotEmpty(message = "url 不能为空") private String url;
|
@NotEmpty(message = "url 不能为空") private String url;
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ public class LlmRepository extends AiLlmConfigDao {
|
|||||||
public Result<Record> pageFetchBy(PageRequestDto pageRequestDto, LlmQueryDto llmQueryDto) {
|
public Result<Record> pageFetchBy(PageRequestDto pageRequestDto, LlmQueryDto llmQueryDto) {
|
||||||
return ctx()
|
return ctx()
|
||||||
.select(
|
.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)
|
.from(AI_LLM_CONFIG)
|
||||||
.where(
|
.where(
|
||||||
StringUtils.isNotEmpty(llmQueryDto.name())
|
StringUtils.isNotEmpty(llmQueryDto.name())
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import org.jooq.generated.mjga.tables.pojos.AiLlmConfig;
|
|||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import static org.jooq.generated.mjga.Tables.AI_LLM_CONFIG;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -42,7 +44,11 @@ public class LlmService {
|
|||||||
if (records.isEmpty()) {
|
if (records.isEmpty()) {
|
||||||
return PageResponseDto.empty();
|
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);
|
Long totalLlm = records.get(0).getValue("total_llm", Long.class);
|
||||||
return new PageResponseDto<>(totalLlm, llmVms);
|
return new PageResponseDto<>(totalLlm, llmVms);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1129,6 +1129,7 @@
|
|||||||
"modelName",
|
"modelName",
|
||||||
"name",
|
"name",
|
||||||
"priority",
|
"priority",
|
||||||
|
"type",
|
||||||
"url"
|
"url"
|
||||||
],
|
],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -1143,6 +1144,9 @@
|
|||||||
"modelName": {
|
"modelName": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"apiKey": {
|
"apiKey": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|||||||
1
frontend/src/api/types/schema.d.ts
vendored
1
frontend/src/api/types/schema.d.ts
vendored
@@ -545,6 +545,7 @@ export interface components {
|
|||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
|
type: string;
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
url: string;
|
url: string;
|
||||||
enable: boolean;
|
enable: boolean;
|
||||||
|
|||||||
@@ -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 "
|
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 />
|
required />
|
||||||
</div>
|
</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">
|
<div class="col-span-2">
|
||||||
<label for="apiKey" class="block mb-2 text-sm font-medium autocomplete text-gray-900 ">apiKey</label>
|
<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"
|
<input type="text" id="apiKey" autocomplete="new-password" v-model="formData.apiKey"
|
||||||
@@ -121,6 +129,9 @@ const handleSubmit = async () => {
|
|||||||
priority: z.number({
|
priority: z.number({
|
||||||
message: "优先级必须为数字",
|
message: "优先级必须为数字",
|
||||||
}),
|
}),
|
||||||
|
type: z.string({
|
||||||
|
message: "类型不能为空",
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
const validatedData = llmSchema.parse(formData.value);
|
const validatedData = llmSchema.parse(formData.value);
|
||||||
await onSubmit(validatedData);
|
await onSubmit(validatedData);
|
||||||
|
|||||||
11
frontend/src/composables/ai/useAiAction.ts
Normal file
11
frontend/src/composables/ai/useAiAction.ts
Normal 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 };
|
||||||
|
};
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
</th>
|
</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">模型名称</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">apiKey</th>
|
||||||
<th scope="col" class="px-6 py-3">url</th>
|
<th scope="col" class="px-6 py-3">url</th>
|
||||||
<th scope="col" class="px-6 py-3">状态</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">{{
|
<td class="px-6 py-4 max-w-sm overflow-hidden text-ellipsis">{{
|
||||||
`${llm.modelName}` }}
|
`${llm.modelName}` }}
|
||||||
</td>
|
</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">{{
|
<td class="px-6 py-4 max-w-sm overflow-hidden text-ellipsis">{{
|
||||||
llm.apiKey }}
|
llm.apiKey }}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user