feat(ai): 添加 AI 聊天功能

- 新增 AI 聊天对话和消息相关 API
- 实现聊天界面,包括对话列表、消息列表、发送消息等功能
- 添加音乐生成功能的初始框架
This commit is contained in:
gjd
2025-06-12 18:26:10 +08:00
parent d2fbb5a18b
commit 4596cd9fa5
25 changed files with 3109 additions and 94 deletions

View File

@@ -0,0 +1,79 @@
import type { VbenFormSchema } from '#/adapter/form';
import { getModelSimpleList } from '#/api/ai/model/model';
import { AiModelTypeEnum } from '#/utils';
export function useFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'id',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'systemMessage',
label: '角色设定',
component: 'Textarea',
componentProps: {
rows: 4,
placeholder: '请输入角色设定',
},
},
{
component: 'ApiSelect',
fieldName: 'modelId',
label: '模型',
componentProps: {
api: () => getModelSimpleList(AiModelTypeEnum.CHAT),
labelField: 'name',
valueField: 'id',
allowClear: true,
placeholder: '请选择模型',
},
rules: 'required',
},
{
fieldName: 'temperature',
label: '温度参数',
component: 'InputNumber',
componentProps: {
controlsPosition: 'right',
placeholder: '请输入温度参数',
class: 'w-full',
precision: 2,
min: 0,
max: 2,
},
rules: 'required',
},
{
fieldName: 'maxTokens',
label: '回复数 Token 数',
component: 'InputNumber',
componentProps: {
controlsPosition: 'right',
placeholder: '请输入回复数 Token 数',
class: 'w-full',
min: 0,
max: 8192,
},
rules: 'required',
},
{
fieldName: 'maxContexts',
label: '上下文数量',
component: 'InputNumber',
componentProps: {
controlsPosition: 'right',
placeholder: '请输入上下文数量',
class: 'w-full',
min: 0,
max: 20,
},
rules: 'required',
},
];
}