初始化

This commit is contained in:
2026-02-22 18:56:10 +08:00
commit 26677972a6
3112 changed files with 255972 additions and 0 deletions

View File

@@ -0,0 +1,138 @@
import type {
AiLlm,
BotInfo,
ChatMessage,
RequestResult,
Session,
} from '@easyflow/types';
import { api } from '#/api/request.js';
/** 获取bot详情 */
export const getBotDetails = (id: string) => {
return api.get<RequestResult<BotInfo>>('/api/v1/bot/getDetail', {
params: { id },
});
};
export interface GetSessionListParams {
botId: string;
tempUserId: string;
}
/** 获取bot对话列表 */
export const getSessionList = (params: GetSessionListParams) => {
return api.get<RequestResult<{ cons: Session[] }>>(
'/api/v1/conversation/externalList',
{ params },
);
};
export interface SaveBotParams {
icon: string;
title: string;
alias: string;
description: string;
categoryId: any;
status: number;
}
/** 创建Bot */
export const saveBot = (params: SaveBotParams) => {
return api.post<RequestResult>('/api/v1/bot/save', { ...params });
};
export interface UpdateBotParams extends SaveBotParams {
id: string;
}
/** 修改Bot */
export const updateBotApi = (params: UpdateBotParams) => {
return api.post<RequestResult>('/api/v1/bot/update', { ...params });
};
/** 删除Bot */
export const removeBotFromId = (id: string) => {
return api.post<RequestResult>('/api/v1/bot/remove', { id });
};
export interface GetMessageListParams {
conversationId: string;
botId: string;
tempUserId: string;
}
/** 获取单个对话的信息列表 */
export const getMessageList = (params: GetMessageListParams) => {
return api.get<RequestResult<ChatMessage[]>>(
'/api/v1/botMessage/messageList',
{
params,
},
);
};
/** 更新Bot的LLM配置 */
export interface UpdateLlmOptionsParams {
id: string;
llmOptions: {
[key: string]: any;
};
}
export interface UpdateBotOptionsParams {
id: string;
options: {
[key: string]: any;
};
}
export const updateLlmOptions = (params: UpdateLlmOptionsParams) => {
return api.post<RequestResult>('/api/v1/bot/updateLlmOptions', {
...params,
});
};
export const updateBotOptions = (params: UpdateBotOptionsParams) => {
return api.post<RequestResult>('/api/v1/bot/updateOptions', {
...params,
});
};
/** 更新Bot的LLM配置 */
export interface GetAiLlmListParams {
[key: string]: any;
}
export const getAiLlmList = (params: GetAiLlmListParams) => {
return api.get<RequestResult<AiLlm[]>>('/api/v1/model/list', {
params,
});
};
/** 更新modelId */
export interface UpdateLlmIdParams {
id: string;
modelId: string;
}
export const updateLlmId = (params: UpdateLlmIdParams) => {
return api.post<RequestResult>('/api/v1/bot/updateLlmId', {
...params,
});
};
export const doPostBotPluginTools = (botId: string) => {
return api.post<RequestResult<any[]>>('/api/v1/pluginItem/tool/list', {
id: botId,
});
};
export const getPerQuestions = (presetQuestions: any[]) => {
if (!presetQuestions) {
return [];
}
return presetQuestions
.filter((item: any) => {
return (
typeof item.description === 'string' && item.description.trim() !== ''
);
})
.map((item: any) => ({
key: item.key,
description: item.description,
}));
};

View File

@@ -0,0 +1,2 @@
export * from './bot';
export * from './llm';

View File

@@ -0,0 +1,44 @@
import { api } from '#/api/request.js';
// 获取LLM供应商
export async function getLlmProviderList() {
return api.get('/api/v1/modelProvider/list');
}
// 保存LLM
export async function saveLlm(data: string) {
return api.post('/api/v1/model/save', data);
}
// 删除LLM
export async function deleteLlm(data: any) {
return api.post(`/api/v1/model/remove`, data);
}
// 修改LLM
export async function updateLlm(data: any) {
return api.post(`/api/v1/model/update`, data);
}
// 一键添加LLM
export async function quickAddLlm(data: any) {
return api.post(`/api/v1/model/quickAdd`, data);
}
export interface llmType {
id: string;
title: string;
modelProvider: {
icon: string;
providerName: string;
providerType: string;
};
withUsed: boolean;
llmModel: string;
icon: string;
description: string;
modelType: string;
groupName: string;
added: boolean;
aiLlmProvider: any;
}