feat: 前端搭建
This commit is contained in:
10
Yi.Ai.Vue3/src/api/auth/index.ts
Normal file
10
Yi.Ai.Vue3/src/api/auth/index.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { EmailCodeDTO, LoginDTO, LoginVO, RegisterDTO } from './types';
|
||||
import { post } from '@/utils/request';
|
||||
|
||||
export const login = (data: LoginDTO) => post<LoginVO>('/auth/login', data);
|
||||
|
||||
// 邮箱验证码
|
||||
export const emailCode = (data: EmailCodeDTO) => post('/resource/email/code', data);
|
||||
|
||||
// 注册账号
|
||||
export const register = (data: RegisterDTO) => post('/auth/register', data);
|
||||
146
Yi.Ai.Vue3/src/api/auth/types.ts
Normal file
146
Yi.Ai.Vue3/src/api/auth/types.ts
Normal file
@@ -0,0 +1,146 @@
|
||||
export interface LoginDTO {
|
||||
username: string;
|
||||
password: string;
|
||||
code?: string;
|
||||
// 二次确认密码
|
||||
confirmPassword?: string;
|
||||
}
|
||||
|
||||
export interface LoginVO {
|
||||
access_token?: string;
|
||||
token?: string;
|
||||
userInfo?: LoginUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* LoginUser,登录用户身份权限
|
||||
*/
|
||||
export interface LoginUser {
|
||||
/**
|
||||
* 微信头像
|
||||
*/
|
||||
avatar?: string;
|
||||
/**
|
||||
* 浏览器类型
|
||||
*/
|
||||
browser?: string;
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
deptId?: number;
|
||||
/**
|
||||
* 部门名
|
||||
*/
|
||||
deptName?: string;
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
expireTime?: number;
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
ipaddr?: string;
|
||||
/**
|
||||
* 获取登录id
|
||||
*/
|
||||
loginId?: string;
|
||||
/**
|
||||
* 登录地点
|
||||
*/
|
||||
loginLocation?: string;
|
||||
/**
|
||||
* 登录时间
|
||||
*/
|
||||
loginTime?: number;
|
||||
/**
|
||||
* 菜单权限
|
||||
*/
|
||||
menuPermission?: string[];
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
nickName?: string;
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
os?: string;
|
||||
/**
|
||||
* 数据权限 当前角色ID
|
||||
*/
|
||||
roleId?: number;
|
||||
/**
|
||||
* 角色权限
|
||||
*/
|
||||
rolePermission?: string[];
|
||||
/**
|
||||
* 角色对象
|
||||
*/
|
||||
roles?: RoleDTO[];
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
tenantId?: string;
|
||||
/**
|
||||
* 用户唯一标识
|
||||
*/
|
||||
token?: string;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
userId?: number;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
userType?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* RoleDTO,角色
|
||||
*/
|
||||
export interface RoleDTO {
|
||||
/**
|
||||
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
||||
*/
|
||||
dataScope?: string;
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
roleId?: number;
|
||||
/**
|
||||
* 角色权限
|
||||
*/
|
||||
roleKey?: string;
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
roleName?: string;
|
||||
}
|
||||
|
||||
// 邮箱验证码
|
||||
export interface EmailCodeDTO {
|
||||
username?: string;
|
||||
}
|
||||
|
||||
// 邮箱注册
|
||||
export interface RegisterDTO {
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
username: string;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
password: string;
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
code: string;
|
||||
/**
|
||||
* 确认密码
|
||||
*/
|
||||
confirmPassword?: string;
|
||||
}
|
||||
15
Yi.Ai.Vue3/src/api/chat/index.ts
Normal file
15
Yi.Ai.Vue3/src/api/chat/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { ChatMessageVo, GetChatListParams, SendDTO } from './types';
|
||||
import { get, post } from '@/utils/request';
|
||||
|
||||
// 发送消息
|
||||
export const send = (data: SendDTO) => post<null>('/chat/send', data);
|
||||
|
||||
// 新增对应会话聊天记录
|
||||
export function addChat(data: ChatMessageVo) {
|
||||
return post('/system/message', data);
|
||||
}
|
||||
|
||||
// 获取当前会话的聊天记录
|
||||
export function getChatList(params: GetChatListParams) {
|
||||
return get<ChatMessageVo[]>('/system/message/list', params);
|
||||
}
|
||||
222
Yi.Ai.Vue3/src/api/chat/types.ts
Normal file
222
Yi.Ai.Vue3/src/api/chat/types.ts
Normal file
@@ -0,0 +1,222 @@
|
||||
/**
|
||||
* ChatRequest,描述:对话请求对象
|
||||
*/
|
||||
export interface SendDTO {
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
appId?: string;
|
||||
/**
|
||||
* 上下文的条数
|
||||
*/
|
||||
contentNumber?: number;
|
||||
/**
|
||||
* 是否开启mcp
|
||||
*/
|
||||
isMcp?: boolean;
|
||||
/**
|
||||
* 知识库id
|
||||
*/
|
||||
kid?: string;
|
||||
messages: Message[];
|
||||
// model: ModelType;
|
||||
model?: string;
|
||||
/**
|
||||
* 提示词
|
||||
*/
|
||||
prompt?: string;
|
||||
/**
|
||||
* 是否开启联网搜索(0关闭 1开启)
|
||||
*/
|
||||
search?: boolean;
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
sessionId?: string;
|
||||
/**
|
||||
* 是否开启流式对话
|
||||
*/
|
||||
stream?: boolean;
|
||||
/**
|
||||
* 系统提示词
|
||||
*/
|
||||
sysPrompt?: string;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId?: number;
|
||||
/**
|
||||
* 是否携带上下文
|
||||
*/
|
||||
usingContext?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message,描述:
|
||||
*/
|
||||
export interface Message {
|
||||
content?: string;
|
||||
name?: string;
|
||||
reasoning_content?: string;
|
||||
/**
|
||||
* 目前支持四个中角色参考官网,进行情景输入:
|
||||
* https://platform.openai.com/docs/guides/chat/introduction
|
||||
*/
|
||||
role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
|
||||
tool_call_id?: string;
|
||||
/**
|
||||
* The tool calls generated by the model, such as function calls.
|
||||
*/
|
||||
tool_calls?: ToolCalls[];
|
||||
}
|
||||
|
||||
/**
|
||||
* ToolCalls,The tool calls generated by the model, such as function calls.
|
||||
*/
|
||||
export interface ToolCalls {
|
||||
function?: ToolCallFunction;
|
||||
/**
|
||||
* The ID of the tool call.
|
||||
*/
|
||||
id?: string;
|
||||
/**
|
||||
* The type of the tool. Currently, only function is supported.
|
||||
*/
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* ToolCallFunction,ToolCall 的 Function参数
|
||||
* The function that the model called.
|
||||
*/
|
||||
export interface ToolCallFunction {
|
||||
/**
|
||||
* 方法参数
|
||||
*/
|
||||
arguments?: string;
|
||||
/**
|
||||
* 方法名
|
||||
*/
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface GetChatListParams {
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
content?: string;
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
createBy?: number;
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
createDept?: number;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
createTime?: Date;
|
||||
/**
|
||||
* 扣除金额
|
||||
*/
|
||||
deductCost?: number;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: number;
|
||||
/**
|
||||
* 排序的方向desc或者asc
|
||||
*/
|
||||
isAsc?: string;
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
modelName?: string;
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
orderByColumn?: string;
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
pageNum?: number;
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
pageSize?: number;
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
params?: { [key: string]: { [key: string]: any } };
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
/**
|
||||
* 对话角色
|
||||
*/
|
||||
role?: string;
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
sessionId?: string;
|
||||
/**
|
||||
* 累计 Tokens
|
||||
*/
|
||||
totalTokens?: number;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
updateBy?: number;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
updateTime?: Date;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatMessageVo,聊天消息视图对象 chat_message
|
||||
*/
|
||||
export interface ChatMessageVo {
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
content?: string;
|
||||
/**
|
||||
* 扣除金额
|
||||
*/
|
||||
deductCost?: number;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: number;
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
modelName?: string;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
/**
|
||||
* 对话角色
|
||||
*/
|
||||
role?: string;
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
sessionId?: number;
|
||||
/**
|
||||
* 累计 Tokens
|
||||
*/
|
||||
totalTokens?: number;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId?: number;
|
||||
}
|
||||
4
Yi.Ai.Vue3/src/api/index.ts
Normal file
4
Yi.Ai.Vue3/src/api/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './auth';
|
||||
export * from './chat';
|
||||
export * from './model';
|
||||
export * from './session';
|
||||
7
Yi.Ai.Vue3/src/api/model/index.ts
Normal file
7
Yi.Ai.Vue3/src/api/model/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { GetSessionListVO } from './types';
|
||||
import { get } from '@/utils/request';
|
||||
|
||||
// 获取当前用户的模型列表
|
||||
export function getModelList() {
|
||||
return get<GetSessionListVO[]>('/system/model/modelList');
|
||||
}
|
||||
14
Yi.Ai.Vue3/src/api/model/types.ts
Normal file
14
Yi.Ai.Vue3/src/api/model/types.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
// 查询用户模型列表返回的数据结构
|
||||
export interface GetSessionListVO {
|
||||
id?: number;
|
||||
category?: string;
|
||||
modelName?: string;
|
||||
modelDescribe?: string;
|
||||
modelPrice?: number;
|
||||
modelType?: string;
|
||||
modelShow?: string;
|
||||
systemPrompt?: string;
|
||||
apiHost?: string;
|
||||
apiKey?: string;
|
||||
remark?: string;
|
||||
}
|
||||
27
Yi.Ai.Vue3/src/api/session/index.ts
Normal file
27
Yi.Ai.Vue3/src/api/session/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type {
|
||||
ChatSessionVo,
|
||||
CreateSessionDTO,
|
||||
// CreateSessionVO,
|
||||
GetSessionListParams,
|
||||
} from './types';
|
||||
import { del, get, post, put } from '@/utils/request';
|
||||
|
||||
export function get_session_list(params: GetSessionListParams) {
|
||||
return get<ChatSessionVo[]>('/system/session/list', params);
|
||||
}
|
||||
|
||||
export function create_session(data: CreateSessionDTO) {
|
||||
return post('/system/session', data);
|
||||
}
|
||||
|
||||
export function update_session(data: ChatSessionVo) {
|
||||
return put('/system/session', data);
|
||||
}
|
||||
|
||||
export function get_session(id: string) {
|
||||
return get<ChatSessionVo>(`/system/session/${id}`);
|
||||
}
|
||||
|
||||
export function delete_session(ids: string[]) {
|
||||
return del(`/system/session/${ids}`);
|
||||
}
|
||||
154
Yi.Ai.Vue3/src/api/session/types.ts
Normal file
154
Yi.Ai.Vue3/src/api/session/types.ts
Normal file
@@ -0,0 +1,154 @@
|
||||
import type { Component } from 'vue';
|
||||
|
||||
export interface GetSessionListParams {
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
createBy?: number;
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
createDept?: number;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
createTime?: Date;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: number;
|
||||
/**
|
||||
* 排序的方向desc或者asc
|
||||
*/
|
||||
isAsc?: string;
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
orderByColumn?: string;
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
pageNum?: number;
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
pageSize?: number;
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
params?: { [key: string]: { [key: string]: any } };
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
/**
|
||||
* 会话内容
|
||||
*/
|
||||
sessionContent?: string;
|
||||
/**
|
||||
* 会话标题
|
||||
*/
|
||||
sessionTitle?: string;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
updateBy?: number;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
updateTime?: Date;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatSessionVo,会话管理视图对象 chat_session
|
||||
*/
|
||||
export interface ChatSessionVo {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
// id?: number
|
||||
id?: string;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
/**
|
||||
* 会话内容
|
||||
*/
|
||||
sessionContent?: string;
|
||||
/**
|
||||
* 会话标题
|
||||
*/
|
||||
sessionTitle?: string;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId?: number;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
createTime?: Date;
|
||||
/**
|
||||
* 自定义的消息前缀图标字段
|
||||
*/
|
||||
prefixIcon?: Component;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatSessionBo,会话管理业务对象 chat_session
|
||||
*/
|
||||
export interface CreateSessionDTO {
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
createBy?: number;
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
createDept?: number;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
createTime?: Date;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
// id?: number;
|
||||
id?: string;
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
params?: { [key: string]: { [key: string]: any } };
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
/**
|
||||
* 会话内容
|
||||
*/
|
||||
sessionContent?: string;
|
||||
/**
|
||||
* 会话标题
|
||||
*/
|
||||
sessionTitle: string;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
updateBy?: number;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
updateTime?: Date;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId: number;
|
||||
}
|
||||
|
||||
// export interface CreateSessionVO {
|
||||
// id: number;
|
||||
// }
|
||||
Reference in New Issue
Block a user