diff --git a/README.md b/README.md index 92ff1ac..bc2c157 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ + diff --git a/backend/ai/views/ai_model.py b/backend/ai/views/ai_model.py index 4768228..e9f0942 100644 --- a/backend/ai/views/ai_model.py +++ b/backend/ai/views/ai_model.py @@ -14,15 +14,15 @@ class AIModelSerializer(CustomModelSerializer): fields = '__all__' read_only_fields = ['id', 'create_time', 'update_time'] + class AIModelViewSet(CustomModelViewSet): """ AI 模型 视图集 """ - queryset = AIModel.objects.filter(is_deleted=False).select_related('key').order_by('-id') + queryset = AIModel.objects.filter(is_deleted=False).select_related('key') serializer_class = AIModelSerializer - filterset_fields = ['id', 'remark', 'creator', 'modifier', 'is_deleted', 'name', 'sort', 'status', 'platform', - 'model', 'max_tokens', 'max_contexts'] + filterset_fields = ['name', 'status', 'platform', 'model', 'model_type', ] search_fields = ['name'] # 根据实际字段调整 ordering_fields = ['create_time', 'id'] - ordering = ['-create_time'] + ordering = ['sort'] diff --git a/images/ai_drawing.png b/images/ai_drawing.png new file mode 100644 index 0000000..f5e3214 Binary files /dev/null and b/images/ai_drawing.png differ diff --git a/web/apps/web-antd/src/views/ai/ai_model/data.ts b/web/apps/web-antd/src/views/ai/ai_model/data.ts index 7ae1b2b..e67caa8 100644 --- a/web/apps/web-antd/src/views/ai/ai_model/data.ts +++ b/web/apps/web-antd/src/views/ai/ai_model/data.ts @@ -28,7 +28,7 @@ export function useSchema(): VbenFormSchema[] { }, fieldName: 'key', label: 'API 秘钥', - rules: z.number(), + rules: z.number().nullable(), }, { component: 'ApiSelect', @@ -142,9 +142,22 @@ export function useGridFormSchema(): VbenFormSchema[] { }, }, { - component: 'Input', + component: 'Select', fieldName: 'platform', - label: '模型平台', + label: '平台', + componentProps: { + allowClear: true, + options: useDictOptions('ai_platform'), + }, + }, + { + component: 'Select', + fieldName: 'model_type', + label: '模型类型', + componentProps: { + allowClear: true, + options: useDictOptions('ai_model_type'), + }, }, ]; } @@ -166,10 +179,6 @@ export function useColumns( field: 'name', title: '模型名字', }, - { - field: 'sort', - title: '排序', - }, { cellRender: { name: 'CellTag', @@ -195,6 +204,10 @@ export function useColumns( field: 'model', title: '模型标识', }, + { + field: 'sort', + title: '排序', + }, { field: 'temperature', title: '温度参数', diff --git a/web/apps/web-antd/src/views/ai/api_key/data.ts b/web/apps/web-antd/src/views/ai/api_key/data.ts index 8ee82a6..9fa49d7 100644 --- a/web/apps/web-antd/src/views/ai/api_key/data.ts +++ b/web/apps/web-antd/src/views/ai/api_key/data.ts @@ -5,6 +5,7 @@ import type { OnActionClickFn } from '#/adapter/vxe-table'; import type { AiAIApiKeyApi } from '#/models/ai/ai_api_key'; import { z } from '#/adapter/form'; +import { dictFormatter, useDictOptions } from '#/hooks/useDictOptions'; import { $t } from '#/locales'; import { op } from '#/utils/permission'; @@ -23,14 +24,13 @@ export function useSchema(): VbenFormSchema[] { .max(100, $t('ui.formRules.maxLength', ['名称', 100])), }, { - component: 'Select', + component: 'ApiSelect', fieldName: 'platform', - label: '平台', componentProps: { - options: PLATFORM_OPTIONS, + options: useDictOptions('ai_platform'), class: 'w-full', - placeholder: '请选择', }, + label: '模型平台', rules: z.string(), }, { @@ -85,7 +85,7 @@ export function useGridFormSchema(): VbenFormSchema[] { label: '平台', componentProps: { allowClear: true, - options: PLATFORM_OPTIONS, + options: useDictOptions('ai_platform'), }, }, { @@ -127,9 +127,11 @@ export function useColumns( }, field: 'platform', title: '平台', - formatter: ({ cellValue }: { cellValue: string }) => { - return PLATFORM_MAP[String(cellValue)] || String(cellValue); - }, + formatter: dictFormatter('ai_platform'), + }, + { + field: 'api_key', + title: '密钥', }, { field: 'url', @@ -167,27 +169,3 @@ export function useColumns( }, ]; } - -// 平台选项和映射常量 -export const PLATFORM_OPTIONS = [ - { label: 'OpenAI 微软', value: 'AzureOpenAI' }, - { label: 'OpenAI', value: 'OpenAI' }, - { label: 'Ollama', value: 'Ollama' }, - { label: '文心一言', value: 'YiYan' }, - { label: '讯飞星火', value: 'XingHuo' }, - { label: '通义千问', value: 'TongYi' }, - { label: 'StableDiffusion', value: 'StableDiffusion' }, - { label: 'Midjourney', value: 'Midjourney' }, - { label: 'Suno', value: 'Suno' }, - { label: 'DeepSeek', value: 'DeepSeek' }, - { label: '字节豆包', value: 'DouBao' }, - { label: '腾讯混元', value: 'HunYuan' }, - { label: '硅基流动', value: 'SiliconFlow' }, - { label: '智谱', value: 'ZhiPu' }, - { label: 'MiniMax', value: 'MiniMax' }, - { label: '月之暗灭', value: 'Moonshot' }, - { label: '百川智能', value: 'BaiChuan' }, -]; -export const PLATFORM_MAP: Record = Object.fromEntries( - PLATFORM_OPTIONS.map((opt) => [opt.value, opt.label]), -); diff --git a/web/apps/web-antd/src/views/system/dict_type/data.ts b/web/apps/web-antd/src/views/system/dict_type/data.ts index b962d3d..e735730 100644 --- a/web/apps/web-antd/src/views/system/dict_type/data.ts +++ b/web/apps/web-antd/src/views/system/dict_type/data.ts @@ -7,7 +7,7 @@ import type { SystemDictTypeApi } from '#/api/system/dict_type'; import { z } from '#/adapter/form'; import { $t } from '#/locales'; import { format_datetime } from '#/utils/date'; -import { op } from "#/utils/permission"; +import { op } from '#/utils/permission'; /** * 获取编辑表单的字段配置。如果没有使用多语言,可以直接export一个数组常量 @@ -30,6 +30,13 @@ export function useSchema(): VbenFormSchema[] { component: 'Input', fieldName: 'value', label: '字典类型', + rules: z + .string() + .min(2, $t('ui.formRules.minLength', [$t('system.dict_type.value'), 2])) + .max( + 20, + $t('ui.formRules.maxLength', [$t('system.dict_type.value'), 20]), + ), }, { component: 'RadioGroup',
AI对话
AI对话
AI绘画
AI对话
部门管理
部门管理