Optimize the project structure and introduce DDD design (#394)

This commit is contained in:
Archer
2023-10-12 17:46:37 +08:00
committed by GitHub
parent 76ac5238b6
commit ad7a17bf40
193 changed files with 1169 additions and 1084 deletions

View File

@@ -0,0 +1,3 @@
export type CreateTrainingBillType = {
name: string;
};

View File

@@ -0,0 +1,4 @@
export type FetchResultItem = {
url: string;
content: string;
};

View 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;
};

View File

@@ -0,0 +1,6 @@
import { ChatCompletionRequestMessage } from '@fastgpt/core/ai/type';
export type CreateQuestionGuideParams = {
messages: ChatCompletionRequestMessage[];
shareId?: string;
};

View File

@@ -0,0 +1,7 @@
import { RequestPaging } from '@/types';
export type GetAppChatLogsParams = RequestPaging & {
appId: string;
dateStart: Date;
dateEnd: Date;
};

View File

@@ -0,0 +1,6 @@
import { AppListItemType } from '@/types/app';
export type AppListResponse = {
myApps: AppListItemType[];
myCollectionApps: AppListItemType[];
};

View File

@@ -0,0 +1,6 @@
export type AdminUpdateFeedbackParams = {
chatItemId: string;
kbId: string;
dataId: string;
content: string;
};

View 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[];
};

View 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;
};

View 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;
};

View File

@@ -0,0 +1,10 @@
export const defaultQuoteTemplate = `{instruction:"{{q}}",output:"{{a}}"}`;
export const defaultQuotePrompt = `你的背景知识:
"""
{{quote}}
"""
对话要求:
1. 背景知识是最新的,其中 instruction 是相关介绍output 是预期回答或补充。
2. 使用背景知识回答问题。
3. 背景知识无法满足问题时,你需严谨的回答问题。
我的问题是:"{{question}}"`;

View 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"]`;

View 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'];
};

View File

@@ -0,0 +1,6 @@
import type { InitChatResponse } from '@/global/core/api/chatRes.d';
export type InitShareChatResponse = {
userAvatar: string;
app: InitChatResponse['app'];
};

View 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'];
}