- {adapterNameList.find(item => item.value === form.watch('adapter'))?.label}
+ {
+ adapterNameList.find(
+ (item) => item.value === form.watch('adapter'),
+ )?.label
+ }
{adapterDescriptionList[form.watch('adapter')]}
@@ -470,25 +497,40 @@ export default function BotForm({
/>
)}
-
{!initBotId && (
-
+
)}
{initBotId && (
<>
-
diff --git a/web/src/app/home/bots/components/bot-form/ChooseEntity.ts b/web/src/app/home/bots/components/bot-form/ChooseEntity.ts
index 0bb067c8..492b4226 100644
--- a/web/src/app/home/bots/components/bot-form/ChooseEntity.ts
+++ b/web/src/app/home/bots/components/bot-form/ChooseEntity.ts
@@ -6,4 +6,4 @@ export interface IChooseAdapterEntity {
export interface IPipelineEntity {
label: string;
value: string;
-}
\ No newline at end of file
+}
diff --git a/web/src/app/home/bots/page.tsx b/web/src/app/home/bots/page.tsx
index 0e7d6b7c..ba478e87 100644
--- a/web/src/app/home/bots/page.tsx
+++ b/web/src/app/home/bots/page.tsx
@@ -2,8 +2,6 @@
import { useEffect, useState } from 'react';
import styles from './botConfig.module.css';
-import EmptyAndCreateComponent from '@/app/home/components/empty-and-create-component/EmptyAndCreateComponent';
-import { useRouter } from 'next/navigation';
import { BotCardVO } from '@/app/home/bots/components/bot-card/BotCardVO';
import BotForm from '@/app/home/bots/components/bot-form/BotForm';
import BotCard from '@/app/home/bots/components/bot-card/BotCard';
@@ -13,12 +11,10 @@ import { Bot, Adapter } from '@/app/infra/entities/api';
import {
Dialog,
DialogContent,
- DialogDescription,
DialogHeader,
DialogTitle,
- DialogTrigger,
-} from "@/components/ui/dialog"
-import { toast } from "sonner";
+} from '@/components/ui/dialog';
+import { toast } from 'sonner';
export default function BotConfigPage() {
const [modalOpen, setModalOpen] = useState
(false);
const [botList, setBotList] = useState([]);
@@ -30,7 +26,6 @@ export default function BotConfigPage() {
}, []);
async function getBotList() {
-
const adapterListResp = await httpClient.getAdapters();
const adapterList = adapterListResp.adapters.map((adapter: Adapter) => {
return {
@@ -48,7 +43,9 @@ export default function BotConfigPage() {
iconURL: httpClient.getAdapterIconURL(bot.adapter),
name: bot.name,
description: bot.description,
- adapterLabel: adapterList.find((item) => item.value === bot.adapter)?.label || bot.adapter.substring(0, 10),
+ adapterLabel:
+ adapterList.find((item) => item.value === bot.adapter)?.label ||
+ bot.adapter.substring(0, 10),
usePipelineName: bot.use_pipeline_name || '',
});
});
@@ -56,7 +53,7 @@ export default function BotConfigPage() {
})
.catch((err) => {
console.error('get bot list error', err);
- toast.error("获取机器人列表失败:" + err.message);
+ toast.error('获取机器人列表失败:' + err.message);
})
.finally(() => {
// setIsLoading(false);
@@ -82,11 +79,12 @@ export default function BotConfigPage() {
return (
-
);
}
diff --git a/web/src/app/home/models/component/llm-card/LLMCard.tsx b/web/src/app/home/models/component/llm-card/LLMCard.tsx
index f0dffcf9..bd7c2f5e 100644
--- a/web/src/app/home/models/component/llm-card/LLMCard.tsx
+++ b/web/src/app/home/models/component/llm-card/LLMCard.tsx
@@ -1,19 +1,35 @@
import styles from './LLMCard.module.css';
import { LLMCardVO } from '@/app/home/models/component/llm-card/LLMCardVO';
-import { Button } from '@/components/ui/button';
function checkAbilityBadges(abilities: string[]) {
-
const abilityBadges = {
- 'vision': ,
- 'func_call': ,
- }
+ vision: (
+
+ ),
+ func_call: (
+
+ ),
+ };
return abilities.map((ability) => {
return abilityBadges[ability as keyof typeof abilityBadges];
@@ -24,7 +40,11 @@ export default function LLMCard({ cardVO }: { cardVO: LLMCardVO }) {
return (
-

+
{/* 名称 */}
@@ -33,24 +53,39 @@ export default function LLMCard({ cardVO }: { cardVO: LLMCardVO }) {
{/* 厂商 */}
-
+
+
+
{cardVO.providerLabel}
{/* baseURL */}
-
-
- {cardVO.baseURL}
-
+
+
+
+
{cardVO.baseURL}
{/* 能力 */}
{checkAbilityBadges(cardVO.abilities)}
-
);
diff --git a/web/src/app/home/models/component/llm-form/LLMForm.tsx b/web/src/app/home/models/component/llm-form/LLMForm.tsx
index de46e739..fd6bd998 100644
--- a/web/src/app/home/models/component/llm-form/LLMForm.tsx
+++ b/web/src/app/home/models/component/llm-form/LLMForm.tsx
@@ -5,9 +5,9 @@ import { httpClient } from '@/app/infra/http/HttpClient';
import { LLMModel } from '@/app/infra/entities/api';
import { UUID } from 'uuidjs';
-import { zodResolver } from "@hookform/resolvers/zod"
-import { useForm } from "react-hook-form"
-import { z } from "zod"
+import { zodResolver } from '@hookform/resolvers/zod';
+import { useForm } from 'react-hook-form';
+import { z } from 'zod';
import {
Dialog,
@@ -15,10 +15,9 @@ import {
DialogDescription,
DialogHeader,
DialogTitle,
- DialogTrigger,
DialogFooter,
-} from "@/components/ui/dialog"
-import { Button } from "@/components/ui/button"
+} from '@/components/ui/dialog';
+import { Button } from '@/components/ui/button';
import {
Form,
FormControl,
@@ -27,31 +26,44 @@ import {
FormItem,
FormLabel,
FormMessage,
-} from "@/components/ui/form"
-import { Input } from "@/components/ui/input"
-import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"
-import { Checkbox } from "@/components/ui/checkbox"
-import { toast } from "sonner"
-const extraArgSchema = z.object({
- key: z.string().min(1, { message: '键名不能为空' }),
- type: z.enum(['string', 'number', 'boolean']),
- value: z.string(),
-}).superRefine((data, ctx) => {
- if (data.type === 'number' && isNaN(Number(data.value))) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: "必须是有效的数字",
- path: ['value'],
- });
- }
- if (data.type === 'boolean' && data.value !== 'true' && data.value !== 'false') {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: "必须是 true 或 false",
- path: ['value'],
- });
- }
-});
+} from '@/components/ui/form';
+import { Input } from '@/components/ui/input';
+import {
+ Select,
+ SelectContent,
+ SelectGroup,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import { Checkbox } from '@/components/ui/checkbox';
+import { toast } from 'sonner';
+const extraArgSchema = z
+ .object({
+ key: z.string().min(1, { message: '键名不能为空' }),
+ type: z.enum(['string', 'number', 'boolean']),
+ value: z.string(),
+ })
+ .superRefine((data, ctx) => {
+ if (data.type === 'number' && isNaN(Number(data.value))) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: '必须是有效的数字',
+ path: ['value'],
+ });
+ }
+ if (
+ data.type === 'boolean' &&
+ data.value !== 'true' &&
+ data.value !== 'false'
+ ) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: '必须是 true 或 false',
+ path: ['value'],
+ });
+ }
+ });
const formSchema = z.object({
name: z.string().min(1, { message: '模型名称不能为空' }),
@@ -60,7 +72,7 @@ const formSchema = z.object({
api_key: z.string().min(1, { message: 'API Key不能为空' }),
abilities: z.array(z.string()),
extra_args: z.array(extraArgSchema).optional(),
-})
+});
export default function LLMForm({
editMode,
@@ -87,10 +99,12 @@ export default function LLMForm({
},
});
- const [extraArgs, setExtraArgs] = useState<{key: string, type: 'string' | 'number' | 'boolean', value: string}[]>([]);
+ const [extraArgs, setExtraArgs] = useState<
+ { key: string; type: 'string' | 'number' | 'boolean'; value: string }[]
+ >([]);
const [showDeleteConfirmModal, setShowDeleteConfirmModal] = useState(false);
- const abilityOptions: { label: string, value: string }[] = [
+ const abilityOptions: { label: string; value: string }[] = [
{
label: '视觉能力',
value: 'vision',
@@ -115,21 +129,21 @@ export default function LLMForm({
form.setValue('model_provider', val.model_provider);
form.setValue('url', val.url);
form.setValue('api_key', val.api_key);
- form.setValue('abilities', val.abilities as ("vision" | "func_call")[]);
+ form.setValue('abilities', val.abilities as ('vision' | 'func_call')[]);
// 转换extra_args为新格式
- if(val.extra_args) {
- const args = val.extra_args.map(arg => {
+ if (val.extra_args) {
+ const args = val.extra_args.map((arg) => {
const [key, value] = arg.split(':');
let type: 'string' | 'number' | 'boolean' = 'string';
- if(!isNaN(Number(value))) {
+ if (!isNaN(Number(value))) {
type = 'number';
- } else if(value === 'true' || value === 'false') {
+ } else if (value === 'true' || value === 'false') {
type = 'boolean';
}
return {
key,
type,
- value
+ value,
};
});
setExtraArgs(args);
@@ -143,14 +157,18 @@ export default function LLMForm({
}, []);
const addExtraArg = () => {
- setExtraArgs([...extraArgs, {key: '', type: 'string', value: ''}]);
+ setExtraArgs([...extraArgs, { key: '', type: 'string', value: '' }]);
};
- const updateExtraArg = (index: number, field: 'key' | 'type' | 'value', value: string) => {
+ const updateExtraArg = (
+ index: number,
+ field: 'key' | 'type' | 'value',
+ value: string,
+ ) => {
const newArgs = [...extraArgs];
newArgs[index] = {
...newArgs[index],
- [field]: value
+ [field]: value,
};
setExtraArgs(newArgs);
form.setValue('extra_args', newArgs);
@@ -216,11 +234,12 @@ export default function LLMForm({
function onCreateLLM(value: z.infer
) {
console.log('create llm', value);
// 转换extra_args为对象格式
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const extraArgsObj: Record = {};
- value.extra_args?.forEach(arg => {
- if(arg.type === 'number') {
+ value.extra_args?.forEach((arg) => {
+ if (arg.type === 'number') {
extraArgsObj[arg.key] = Number(arg.value);
- } else if(arg.type === 'boolean') {
+ } else if (arg.type === 'boolean') {
extraArgsObj[arg.key] = arg.value === 'true';
} else {
extraArgsObj[arg.key] = arg.value;
@@ -240,46 +259,56 @@ export default function LLMForm({
api_keys: [value.api_key],
abilities: value.abilities,
};
- httpClient.createProviderLLMModel(requestParam).then(() => {
- onFormSubmit(value);
- toast.success("创建成功");
- }).catch((err) => {
- toast.error("创建失败:" + err.message);
- });
+ httpClient
+ .createProviderLLMModel(requestParam)
+ .then(() => {
+ onFormSubmit(value);
+ toast.success('创建成功');
+ })
+ .catch((err) => {
+ toast.error('创建失败:' + err.message);
+ });
}
- function handleAbilitiesChange() { }
-
function deleteModel() {
if (initLLMId) {
- httpClient.deleteProviderLLMModel(initLLMId).then(() => {
- onLLMDeleted();
- toast.success("删除成功");
- }).catch((err) => {
- toast.error("删除失败:" + err.message);
- });
+ httpClient
+ .deleteProviderLLMModel(initLLMId)
+ .then(() => {
+ onLLMDeleted();
+ toast.success('删除成功');
+ })
+ .catch((err) => {
+ toast.error('删除失败:' + err.message);
+ });
}
}
return (
-
-