mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-02 12:48:30 +00:00
Optimize the project structure and introduce DDD design (#394)
This commit is contained in:
3
projects/app/src/global/common/api/billReq.d.ts
vendored
Normal file
3
projects/app/src/global/common/api/billReq.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export type CreateTrainingBillType = {
|
||||
name: string;
|
||||
};
|
4
projects/app/src/global/common/api/pluginRes.d.ts
vendored
Normal file
4
projects/app/src/global/common/api/pluginRes.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export type FetchResultItem = {
|
||||
url: string;
|
||||
content: string;
|
||||
};
|
14
projects/app/src/global/common/api/systemRes.d.ts
vendored
Normal file
14
projects/app/src/global/common/api/systemRes.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import {
|
||||
type QAModelItemType,
|
||||
type ChatModelItemType,
|
||||
type VectorModelItemType,
|
||||
FunctionModelItemType
|
||||
} from '@/types/model';
|
||||
|
||||
export type InitDateResponse = {
|
||||
chatModels: ChatModelItemType[];
|
||||
qaModel: QAModelItemType;
|
||||
vectorModels: VectorModelItemType[];
|
||||
feConfigs: FeConfigsType;
|
||||
systemVersion: string;
|
||||
};
|
6
projects/app/src/global/core/api/aiReq.d.ts
vendored
Normal file
6
projects/app/src/global/core/api/aiReq.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ChatCompletionRequestMessage } from '@fastgpt/core/ai/type';
|
||||
|
||||
export type CreateQuestionGuideParams = {
|
||||
messages: ChatCompletionRequestMessage[];
|
||||
shareId?: string;
|
||||
};
|
7
projects/app/src/global/core/api/appReq.d.ts
vendored
Normal file
7
projects/app/src/global/core/api/appReq.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { RequestPaging } from '@/types';
|
||||
|
||||
export type GetAppChatLogsParams = RequestPaging & {
|
||||
appId: string;
|
||||
dateStart: Date;
|
||||
dateEnd: Date;
|
||||
};
|
6
projects/app/src/global/core/api/appRes.d.ts
vendored
Normal file
6
projects/app/src/global/core/api/appRes.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { AppListItemType } from '@/types/app';
|
||||
|
||||
export type AppListResponse = {
|
||||
myApps: AppListItemType[];
|
||||
myCollectionApps: AppListItemType[];
|
||||
};
|
6
projects/app/src/global/core/api/chatReq.d.ts
vendored
Normal file
6
projects/app/src/global/core/api/chatReq.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export type AdminUpdateFeedbackParams = {
|
||||
chatItemId: string;
|
||||
kbId: string;
|
||||
dataId: string;
|
||||
content: string;
|
||||
};
|
19
projects/app/src/global/core/api/chatRes.d.ts
vendored
Normal file
19
projects/app/src/global/core/api/chatRes.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { AppSchema } from '@/types/mongoSchema';
|
||||
import type { ChatItemType } from '@/types/chat';
|
||||
import { AppModuleItemType, VariableItemType } from '@/types/app';
|
||||
|
||||
export type InitChatResponse = {
|
||||
chatId: string;
|
||||
appId: string;
|
||||
app: {
|
||||
userGuideModule?: AppModuleItemType;
|
||||
chatModels?: string[];
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
canUse?: boolean;
|
||||
};
|
||||
title: string;
|
||||
variables: Record<string, any>;
|
||||
history: ChatItemType[];
|
||||
};
|
59
projects/app/src/global/core/api/datasetReq.d.ts
vendored
Normal file
59
projects/app/src/global/core/api/datasetReq.d.ts
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import { KbTypeEnum } from '@/constants/dataset';
|
||||
import type { RequestPaging } from '@/types';
|
||||
import { TrainingModeEnum } from '@/constants/plugin';
|
||||
import type { SearchTestItemType } from '@/types/core/dataset';
|
||||
import { DatasetDataItemType } from '@/types/core/dataset/data';
|
||||
|
||||
/* ===== dataset ===== */
|
||||
export type DatasetUpdateParams = {
|
||||
id: string;
|
||||
parentId?: string;
|
||||
tags?: string;
|
||||
name?: string;
|
||||
avatar?: string;
|
||||
};
|
||||
export type CreateDatasetParams = {
|
||||
parentId?: string;
|
||||
name: string;
|
||||
tags: string[];
|
||||
avatar: string;
|
||||
vectorModel?: string;
|
||||
type: `${KbTypeEnum}`;
|
||||
};
|
||||
|
||||
export type SearchTestProps = {
|
||||
kbId: string;
|
||||
text: string;
|
||||
};
|
||||
|
||||
/* ======= file =========== */
|
||||
export type GetFileListProps = RequestPaging & {
|
||||
kbId: string;
|
||||
searchText: string;
|
||||
};
|
||||
|
||||
export type UpdateFileProps = { id: string; name?: string; datasetUsed?: boolean };
|
||||
|
||||
export type MarkFileUsedProps = { fileIds: string[] };
|
||||
|
||||
/* ==== data ===== */
|
||||
export type PushDataProps = {
|
||||
kbId: string;
|
||||
data: DatasetDataItemType[];
|
||||
mode: `${TrainingModeEnum}`;
|
||||
prompt?: string;
|
||||
billId?: string;
|
||||
};
|
||||
|
||||
export type UpdateDatasetDataPrams = {
|
||||
dataId: string;
|
||||
kbId: string;
|
||||
a?: string;
|
||||
q?: string;
|
||||
};
|
||||
|
||||
export type GetDatasetDataListProps = RequestPaging & {
|
||||
kbId: string;
|
||||
searchText: string;
|
||||
fileId: string;
|
||||
};
|
15
projects/app/src/global/core/api/datasetRes.d.ts
vendored
Normal file
15
projects/app/src/global/core/api/datasetRes.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { KbTypeEnum } from '@/constants/dataset';
|
||||
import type { RequestPaging } from '@/types';
|
||||
import { TrainingModeEnum } from '@/constants/plugin';
|
||||
import type { SearchTestItemType } from '@/types/core/dataset';
|
||||
import { DatasetDataItemType } from '@/types/core/dataset/data';
|
||||
|
||||
/* ===== dataset ===== */
|
||||
export type SearchTestResponseType = SearchTestItemType['results'];
|
||||
|
||||
/* ======= file =========== */
|
||||
|
||||
/* ==== data ===== */
|
||||
export type PushDataResponse = {
|
||||
insertLen: number;
|
||||
};
|
10
projects/app/src/global/core/prompt/AIChat.ts
Normal file
10
projects/app/src/global/core/prompt/AIChat.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export const defaultQuoteTemplate = `{instruction:"{{q}}",output:"{{a}}"}`;
|
||||
export const defaultQuotePrompt = `你的背景知识:
|
||||
"""
|
||||
{{quote}}
|
||||
"""
|
||||
对话要求:
|
||||
1. 背景知识是最新的,其中 instruction 是相关介绍,output 是预期回答或补充。
|
||||
2. 使用背景知识回答问题。
|
||||
3. 背景知识无法满足问题时,你需严谨的回答问题。
|
||||
我的问题是:"{{question}}"`;
|
60
projects/app/src/global/core/prompt/agent.ts
Normal file
60
projects/app/src/global/core/prompt/agent.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
export const Prompt_AgentQA = {
|
||||
prompt: `我会给你一段文本,{{theme}},学习它们,并整理学习成果,要求为:
|
||||
1. 提出最多 25 个问题。
|
||||
2. 给出每个问题的答案。
|
||||
3. 答案要详细完整,答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 markdown 元素。
|
||||
4. 按格式返回多个问题和答案:
|
||||
|
||||
Q1: 问题。
|
||||
A1: 答案。
|
||||
Q2:
|
||||
A2:
|
||||
……
|
||||
|
||||
我的文本:"""{{text}}"""`,
|
||||
defaultTheme: '它们可能包含多个主题内容'
|
||||
};
|
||||
|
||||
export const Prompt_ExtractJson = `你可以从 "对话记录" 中提取指定信息,并返回一个 JSON 对象,JSON 对象要求:
|
||||
1. JSON 对象仅包含字段说明中的值。
|
||||
2. 字段说明中的 required 决定 JSON 对象是否必须存在该字段。
|
||||
3. 必须存在的字段,值可以为空字符串或根据提取要求来设置,不能随机生成值。
|
||||
|
||||
提取要求:
|
||||
"""
|
||||
{{description}}
|
||||
"""
|
||||
|
||||
字段说明:
|
||||
"""
|
||||
{{json}}
|
||||
"""
|
||||
|
||||
对话记录:
|
||||
"""
|
||||
{{text}}
|
||||
"""
|
||||
`;
|
||||
|
||||
export const Prompt_CQJson = `我会给你几个问题类型,请参考额外的背景知识(可能为空)和对话内容,判断我本次的问题类型,并返回对应类型的 ID,格式为 JSON 字符串:
|
||||
"""
|
||||
'{"type":"问题类型的 ID"}'
|
||||
"""
|
||||
|
||||
问题类型:
|
||||
"""
|
||||
{{typeList}}
|
||||
"""
|
||||
|
||||
额外背景知识:
|
||||
"""
|
||||
{{systemPrompt}}
|
||||
"""
|
||||
|
||||
对话内容:
|
||||
"""
|
||||
{{text}}
|
||||
"""
|
||||
`;
|
||||
|
||||
export const Prompt_QuestionGuide = `我不太清楚问你什么问题,请帮我生成 3 个问题,引导我继续提问。问题的长度应小于20个字符,按 JSON 格式返回: ["问题1", "问题2", "问题3"]`;
|
11
projects/app/src/global/support/api/openapiReq.d.ts
vendored
Normal file
11
projects/app/src/global/support/api/openapiReq.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { OpenApiSchema } from '@/types/support/openapi';
|
||||
|
||||
export type GetApiKeyProps = {
|
||||
appId?: string;
|
||||
};
|
||||
|
||||
export type EditApiKeyProps = {
|
||||
appId?: string;
|
||||
name: string;
|
||||
limit: OpenApiSchema['limit'];
|
||||
};
|
6
projects/app/src/global/support/api/outLinkRes.d.ts
vendored
Normal file
6
projects/app/src/global/support/api/outLinkRes.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { InitChatResponse } from '@/global/core/api/chatRes.d';
|
||||
|
||||
export type InitShareChatResponse = {
|
||||
userAvatar: string;
|
||||
app: InitChatResponse['app'];
|
||||
};
|
13
projects/app/src/global/support/api/userRes.d.ts
vendored
Normal file
13
projects/app/src/global/support/api/userRes.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { UserType } from '@/types/user';
|
||||
import type { PromotionRecordSchema } from '@/types/mongoSchema';
|
||||
export interface ResLogin {
|
||||
user: UserType;
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface PromotionRecordType {
|
||||
_id: PromotionRecordSchema['_id'];
|
||||
type: PromotionRecordSchema['type'];
|
||||
createTime: PromotionRecordSchema['createTime'];
|
||||
amount: PromotionRecordSchema['amount'];
|
||||
}
|
Reference in New Issue
Block a user