修改api密钥和模型配置
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>AI对话</strong><br><img src="images/ai_chat.png" alt="AI对话" width="400"></td>
|
<td><strong>AI对话</strong><br><img src="images/ai_chat.png" alt="AI对话" width="400"></td>
|
||||||
|
<td><strong>AI绘画</strong><br><img src="images/ai_drawing.png" alt="AI对话" width="400"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>部门管理</strong><br><img src="images/dj_dept.png" alt="部门管理" width="400"></td>
|
<td><strong>部门管理</strong><br><img src="images/dj_dept.png" alt="部门管理" width="400"></td>
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ class AIModelSerializer(CustomModelSerializer):
|
|||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
read_only_fields = ['id', 'create_time', 'update_time']
|
read_only_fields = ['id', 'create_time', 'update_time']
|
||||||
|
|
||||||
|
|
||||||
class AIModelViewSet(CustomModelViewSet):
|
class AIModelViewSet(CustomModelViewSet):
|
||||||
"""
|
"""
|
||||||
AI 模型 视图集
|
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
|
serializer_class = AIModelSerializer
|
||||||
filterset_fields = ['id', 'remark', 'creator', 'modifier', 'is_deleted', 'name', 'sort', 'status', 'platform',
|
filterset_fields = ['name', 'status', 'platform', 'model', 'model_type', ]
|
||||||
'model', 'max_tokens', 'max_contexts']
|
|
||||||
search_fields = ['name'] # 根据实际字段调整
|
search_fields = ['name'] # 根据实际字段调整
|
||||||
ordering_fields = ['create_time', 'id']
|
ordering_fields = ['create_time', 'id']
|
||||||
ordering = ['-create_time']
|
ordering = ['sort']
|
||||||
|
|
||||||
|
|||||||
BIN
images/ai_drawing.png
Normal file
BIN
images/ai_drawing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 712 KiB |
@@ -28,7 +28,7 @@ export function useSchema(): VbenFormSchema[] {
|
|||||||
},
|
},
|
||||||
fieldName: 'key',
|
fieldName: 'key',
|
||||||
label: 'API 秘钥',
|
label: 'API 秘钥',
|
||||||
rules: z.number(),
|
rules: z.number().nullable(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
@@ -142,9 +142,22 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Input',
|
component: 'Select',
|
||||||
fieldName: 'platform',
|
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',
|
field: 'name',
|
||||||
title: '模型名字',
|
title: '模型名字',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
field: 'sort',
|
|
||||||
title: '排序',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellTag',
|
name: 'CellTag',
|
||||||
@@ -195,6 +204,10 @@ export function useColumns(
|
|||||||
field: 'model',
|
field: 'model',
|
||||||
title: '模型标识',
|
title: '模型标识',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'sort',
|
||||||
|
title: '排序',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'temperature',
|
field: 'temperature',
|
||||||
title: '温度参数',
|
title: '温度参数',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type { OnActionClickFn } from '#/adapter/vxe-table';
|
|||||||
import type { AiAIApiKeyApi } from '#/models/ai/ai_api_key';
|
import type { AiAIApiKeyApi } from '#/models/ai/ai_api_key';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
|
import { dictFormatter, useDictOptions } from '#/hooks/useDictOptions';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { op } from '#/utils/permission';
|
import { op } from '#/utils/permission';
|
||||||
|
|
||||||
@@ -23,14 +24,13 @@ export function useSchema(): VbenFormSchema[] {
|
|||||||
.max(100, $t('ui.formRules.maxLength', ['名称', 100])),
|
.max(100, $t('ui.formRules.maxLength', ['名称', 100])),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Select',
|
component: 'ApiSelect',
|
||||||
fieldName: 'platform',
|
fieldName: 'platform',
|
||||||
label: '平台',
|
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: PLATFORM_OPTIONS,
|
options: useDictOptions('ai_platform'),
|
||||||
class: 'w-full',
|
class: 'w-full',
|
||||||
placeholder: '请选择',
|
|
||||||
},
|
},
|
||||||
|
label: '模型平台',
|
||||||
rules: z.string(),
|
rules: z.string(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
label: '平台',
|
label: '平台',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
options: PLATFORM_OPTIONS,
|
options: useDictOptions('ai_platform'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -127,9 +127,11 @@ export function useColumns(
|
|||||||
},
|
},
|
||||||
field: 'platform',
|
field: 'platform',
|
||||||
title: '平台',
|
title: '平台',
|
||||||
formatter: ({ cellValue }: { cellValue: string }) => {
|
formatter: dictFormatter('ai_platform'),
|
||||||
return PLATFORM_MAP[String(cellValue)] || String(cellValue);
|
},
|
||||||
},
|
{
|
||||||
|
field: 'api_key',
|
||||||
|
title: '密钥',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'url',
|
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<string, string> = Object.fromEntries(
|
|
||||||
PLATFORM_OPTIONS.map((opt) => [opt.value, opt.label]),
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import type { SystemDictTypeApi } from '#/api/system/dict_type';
|
|||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { format_datetime } from '#/utils/date';
|
import { format_datetime } from '#/utils/date';
|
||||||
import { op } from "#/utils/permission";
|
import { op } from '#/utils/permission';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取编辑表单的字段配置。如果没有使用多语言,可以直接export一个数组常量
|
* 获取编辑表单的字段配置。如果没有使用多语言,可以直接export一个数组常量
|
||||||
@@ -30,6 +30,13 @@ export function useSchema(): VbenFormSchema[] {
|
|||||||
component: 'Input',
|
component: 'Input',
|
||||||
fieldName: 'value',
|
fieldName: 'value',
|
||||||
label: '字典类型',
|
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',
|
component: 'RadioGroup',
|
||||||
|
|||||||
Reference in New Issue
Block a user