mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
v4.6 -1 (#459)
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export const PRICE_SCALE = 100000;
|
@@ -1,3 +0,0 @@
|
||||
export type CreateTrainingBillType = {
|
||||
name: string;
|
||||
};
|
28
packages/global/common/error/code/app.ts
Normal file
28
packages/global/common/error/code/app.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
/* dataset: 502000 */
|
||||
export enum AppErrEnum {
|
||||
unExist = 'unExist',
|
||||
unAuthApp = 'unAuthApp'
|
||||
}
|
||||
const appErrList = [
|
||||
{
|
||||
statusText: AppErrEnum.unExist,
|
||||
message: '应用不存在'
|
||||
},
|
||||
{
|
||||
statusText: AppErrEnum.unAuthApp,
|
||||
message: '无权操作该应用'
|
||||
}
|
||||
];
|
||||
export default appErrList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[cur.statusText]: {
|
||||
code: 502000 + index,
|
||||
statusText: cur.statusText,
|
||||
message: cur.message,
|
||||
data: null
|
||||
}
|
||||
};
|
||||
}, {} as ErrType<`${AppErrEnum}`>);
|
23
packages/global/common/error/code/chat.ts
Normal file
23
packages/global/common/error/code/chat.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
/* dataset: 504000 */
|
||||
export enum ChatErrEnum {
|
||||
unAuthChat = 'unAuthChat'
|
||||
}
|
||||
const errList = [
|
||||
{
|
||||
statusText: ChatErrEnum.unAuthChat,
|
||||
message: '无权操作该对话记录'
|
||||
}
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[cur.statusText]: {
|
||||
code: 504000 + index,
|
||||
statusText: cur.statusText,
|
||||
message: cur.message,
|
||||
data: null
|
||||
}
|
||||
};
|
||||
}, {} as ErrType<`${ChatErrEnum}`>);
|
43
packages/global/common/error/code/dataset.ts
Normal file
43
packages/global/common/error/code/dataset.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
/* dataset: 501000 */
|
||||
export enum DatasetErrEnum {
|
||||
unAuthDataset = 'unAuthDataset',
|
||||
unCreateCollection = 'unCreateCollection',
|
||||
unAuthDatasetCollection = 'unAuthDatasetCollection',
|
||||
unAuthDatasetData = 'unAuthDatasetData',
|
||||
unAuthDatasetFile = 'unAuthDatasetFile'
|
||||
}
|
||||
const datasetErr = [
|
||||
{
|
||||
statusText: DatasetErrEnum.unAuthDataset,
|
||||
message: '无权操作该知识库'
|
||||
},
|
||||
{
|
||||
statusText: DatasetErrEnum.unAuthDatasetCollection,
|
||||
message: '无权操作该数据集'
|
||||
},
|
||||
{
|
||||
statusText: DatasetErrEnum.unAuthDatasetData,
|
||||
message: '无权操作该数据'
|
||||
},
|
||||
{
|
||||
statusText: DatasetErrEnum.unAuthDatasetFile,
|
||||
message: '无权操作该文件'
|
||||
},
|
||||
{
|
||||
statusText: DatasetErrEnum.unCreateCollection,
|
||||
message: '无权创建数据集'
|
||||
}
|
||||
];
|
||||
export default datasetErr.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[cur.statusText]: {
|
||||
code: 501000 + index,
|
||||
statusText: cur.statusText,
|
||||
message: cur.message,
|
||||
data: null
|
||||
}
|
||||
};
|
||||
}, {} as ErrType<`${DatasetErrEnum}`>);
|
28
packages/global/common/error/code/openapi.ts
Normal file
28
packages/global/common/error/code/openapi.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
/* dataset: 506000 */
|
||||
export enum OpenApiErrEnum {
|
||||
unExist = 'unExist',
|
||||
unAuth = 'unAuth'
|
||||
}
|
||||
const errList = [
|
||||
{
|
||||
statusText: OpenApiErrEnum.unExist,
|
||||
message: 'Api Key 不存在'
|
||||
},
|
||||
{
|
||||
statusText: OpenApiErrEnum.unAuth,
|
||||
message: '无权操作该 Api Key'
|
||||
}
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[cur.statusText]: {
|
||||
code: 506000 + index,
|
||||
statusText: cur.statusText,
|
||||
message: cur.message,
|
||||
data: null
|
||||
}
|
||||
};
|
||||
}, {} as ErrType<`${OpenApiErrEnum}`>);
|
34
packages/global/common/error/code/outLink.ts
Normal file
34
packages/global/common/error/code/outLink.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
/* dataset: 505000 */
|
||||
export enum OutLinkErrEnum {
|
||||
unExist = 'unExist',
|
||||
unAuthLink = 'unAuthLink',
|
||||
linkUnInvalid = 'linkUnInvalid'
|
||||
}
|
||||
const errList = [
|
||||
{
|
||||
statusText: OutLinkErrEnum.unExist,
|
||||
message: '分享链接不存在'
|
||||
},
|
||||
{
|
||||
statusText: OutLinkErrEnum.unAuthLink,
|
||||
message: '分享链接无效'
|
||||
},
|
||||
{
|
||||
code: 501,
|
||||
statusText: OutLinkErrEnum.linkUnInvalid,
|
||||
message: '分享链接无效'
|
||||
}
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[cur.statusText]: {
|
||||
code: cur?.code || 505000 + index,
|
||||
statusText: cur.statusText,
|
||||
message: cur.message,
|
||||
data: null
|
||||
}
|
||||
};
|
||||
}, {} as ErrType<`${OutLinkErrEnum}`>);
|
28
packages/global/common/error/code/plugin.ts
Normal file
28
packages/global/common/error/code/plugin.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
/* dataset: 507000 */
|
||||
export enum PluginErrEnum {
|
||||
unExist = 'unExist',
|
||||
unAuth = 'unAuth'
|
||||
}
|
||||
const errList = [
|
||||
{
|
||||
statusText: PluginErrEnum.unExist,
|
||||
message: '插件不存在'
|
||||
},
|
||||
{
|
||||
statusText: PluginErrEnum.unAuth,
|
||||
message: '无权操作该插件'
|
||||
}
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[cur.statusText]: {
|
||||
code: 507000 + index,
|
||||
statusText: cur.statusText,
|
||||
message: cur.message,
|
||||
data: null
|
||||
}
|
||||
};
|
||||
}, {} as ErrType<`${PluginErrEnum}`>);
|
22
packages/global/common/error/code/team.ts
Normal file
22
packages/global/common/error/code/team.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
/* team: 500000 */
|
||||
export enum TeamErrEnum {
|
||||
teamOverSize = 'teamOverSize',
|
||||
unAuthTeam = 'unAuthTeam'
|
||||
}
|
||||
const teamErr = [
|
||||
{ statusText: TeamErrEnum.teamOverSize, message: 'error.team.overSize' },
|
||||
{ statusText: TeamErrEnum.unAuthTeam, message: '无权操作该团队' }
|
||||
];
|
||||
export default teamErr.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[cur.statusText]: {
|
||||
code: 500000 + index,
|
||||
statusText: cur.statusText,
|
||||
message: cur.message,
|
||||
data: null
|
||||
}
|
||||
};
|
||||
}, {} as ErrType<`${TeamErrEnum}`>);
|
26
packages/global/common/error/code/user.ts
Normal file
26
packages/global/common/error/code/user.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
/* team: 503000 */
|
||||
export enum UserErrEnum {
|
||||
unAuthUser = 'unAuthUser',
|
||||
unAuthRole = 'unAuthRole',
|
||||
binVisitor = 'binVisitor',
|
||||
balanceNotEnough = 'balanceNotEnough'
|
||||
}
|
||||
const errList = [
|
||||
{ statusText: UserErrEnum.unAuthUser, message: '找不到该用户' },
|
||||
{ statusText: UserErrEnum.binVisitor, message: '您的身份校验未通过' },
|
||||
{ statusText: UserErrEnum.binVisitor, message: '您当前身份为游客,无权操作' },
|
||||
{ statusText: UserErrEnum.balanceNotEnough, message: '账号余额不足~' }
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
[cur.statusText]: {
|
||||
code: 503000 + index,
|
||||
statusText: cur.statusText,
|
||||
message: cur.message,
|
||||
data: null
|
||||
}
|
||||
};
|
||||
}, {} as ErrType<`${UserErrEnum}`>);
|
@@ -1,3 +1,12 @@
|
||||
import appErr from './code/app';
|
||||
import chatErr from './code/chat';
|
||||
import datasetErr from './code/dataset';
|
||||
import openapiErr from './code/openapi';
|
||||
import pluginErr from './code/plugin';
|
||||
import outLinkErr from './code/outLink';
|
||||
import teamErr from './code/team';
|
||||
import userErr from './code/user';
|
||||
|
||||
export const ERROR_CODE: { [key: number]: string } = {
|
||||
400: '请求失败',
|
||||
401: '无权访问',
|
||||
@@ -27,10 +36,19 @@ export enum ERROR_ENUM {
|
||||
insufficientQuota = 'insufficientQuota',
|
||||
unAuthModel = 'unAuthModel',
|
||||
unAuthApiKey = 'unAuthApiKey',
|
||||
unAuthDataset = 'unAuthDataset',
|
||||
unAuthDatasetCollection = 'unAuthDatasetCollection',
|
||||
unAuthFile = 'unAuthFile'
|
||||
}
|
||||
|
||||
export type ErrType<T> = Record<
|
||||
string,
|
||||
{
|
||||
code: number;
|
||||
statusText: T;
|
||||
message: string;
|
||||
data: null;
|
||||
}
|
||||
>;
|
||||
|
||||
export const ERROR_RESPONSE: Record<
|
||||
any,
|
||||
{
|
||||
@@ -55,15 +73,10 @@ export const ERROR_RESPONSE: Record<
|
||||
[ERROR_ENUM.unAuthModel]: {
|
||||
code: 511,
|
||||
statusText: ERROR_ENUM.unAuthModel,
|
||||
message: '无权使用该模型',
|
||||
data: null
|
||||
},
|
||||
[ERROR_ENUM.unAuthDataset]: {
|
||||
code: 512,
|
||||
statusText: ERROR_ENUM.unAuthDataset,
|
||||
message: '无权使用该知识库',
|
||||
message: '无权操作该模型',
|
||||
data: null
|
||||
},
|
||||
|
||||
[ERROR_ENUM.unAuthFile]: {
|
||||
code: 513,
|
||||
statusText: ERROR_ENUM.unAuthFile,
|
||||
@@ -76,10 +89,12 @@ export const ERROR_RESPONSE: Record<
|
||||
message: 'Api Key 不合法',
|
||||
data: null
|
||||
},
|
||||
[ERROR_ENUM.unAuthDatasetCollection]: {
|
||||
code: 515,
|
||||
statusText: ERROR_ENUM.unAuthDatasetCollection,
|
||||
message: '无权使用该知识库文件',
|
||||
data: null
|
||||
}
|
||||
...appErr,
|
||||
...chatErr,
|
||||
...datasetErr,
|
||||
...openapiErr,
|
||||
...outLinkErr,
|
||||
...teamErr,
|
||||
...userErr,
|
||||
...pluginErr
|
||||
};
|
||||
|
5
packages/global/common/file/constants.ts
Normal file
5
packages/global/common/file/constants.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum BucketNameEnum {
|
||||
dataset = 'dataset'
|
||||
}
|
||||
|
||||
export const FileBaseUrl = '/api/common/file/read';
|
8
packages/global/common/file/type.d.ts
vendored
Normal file
8
packages/global/common/file/type.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { BucketNameEnum } from './constants';
|
||||
|
||||
export type FileTokenQuery = {
|
||||
bucketName: `${BucketNameEnum}`;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
fileId: string;
|
||||
};
|
@@ -2,5 +2,6 @@ export enum ChatCompletionRequestMessageRoleEnum {
|
||||
'System' = 'system',
|
||||
'User' = 'user',
|
||||
'Assistant' = 'assistant',
|
||||
'Function' = 'function'
|
||||
'Function' = 'function',
|
||||
'Tool' = 'tool'
|
||||
}
|
||||
|
2
packages/global/core/ai/index.ts
Normal file
2
packages/global/core/ai/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import OpenAI from 'openai';
|
||||
export default OpenAI;
|
32
packages/global/core/ai/model.d.ts
vendored
Normal file
32
packages/global/core/ai/model.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
export type LLMModelItemType = {
|
||||
model: string;
|
||||
name: string;
|
||||
maxContext: number;
|
||||
maxResponse: number;
|
||||
price: number;
|
||||
};
|
||||
export type ChatModelItemType = LLMModelItemType & {
|
||||
quoteMaxToken: number;
|
||||
maxTemperature: number;
|
||||
censor?: boolean;
|
||||
defaultSystemChatPrompt?: string;
|
||||
};
|
||||
|
||||
export type FunctionModelItemType = LLMModelItemType & {
|
||||
functionCall: boolean;
|
||||
functionPrompt: string;
|
||||
};
|
||||
|
||||
export type VectorModelItemType = {
|
||||
model: string;
|
||||
name: string;
|
||||
defaultToken: number;
|
||||
price: number;
|
||||
maxToken: number;
|
||||
};
|
||||
|
||||
export type AudioSpeechModelType = {
|
||||
model: string;
|
||||
name: string;
|
||||
price: number;
|
||||
};
|
115
packages/global/core/ai/model.ts
Normal file
115
packages/global/core/ai/model.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import type {
|
||||
LLMModelItemType,
|
||||
ChatModelItemType,
|
||||
FunctionModelItemType,
|
||||
VectorModelItemType,
|
||||
AudioSpeechModelType
|
||||
} from './model.d';
|
||||
|
||||
export const defaultChatModels: ChatModelItemType[] = [
|
||||
{
|
||||
model: 'gpt-3.5-turbo-1106',
|
||||
name: 'GPT35-1106',
|
||||
price: 0,
|
||||
maxContext: 16000,
|
||||
maxResponse: 4000,
|
||||
quoteMaxToken: 2000,
|
||||
maxTemperature: 1.2,
|
||||
censor: false,
|
||||
defaultSystemChatPrompt: ''
|
||||
},
|
||||
{
|
||||
model: 'gpt-3.5-turbo-16k',
|
||||
name: 'GPT35-16k',
|
||||
maxContext: 16000,
|
||||
maxResponse: 16000,
|
||||
price: 0,
|
||||
quoteMaxToken: 8000,
|
||||
maxTemperature: 1.2,
|
||||
censor: false,
|
||||
defaultSystemChatPrompt: ''
|
||||
},
|
||||
{
|
||||
model: 'gpt-4',
|
||||
name: 'GPT4-8k',
|
||||
maxContext: 8000,
|
||||
maxResponse: 8000,
|
||||
price: 0,
|
||||
quoteMaxToken: 4000,
|
||||
maxTemperature: 1.2,
|
||||
censor: false,
|
||||
defaultSystemChatPrompt: ''
|
||||
}
|
||||
];
|
||||
export const defaultQAModels: LLMModelItemType[] = [
|
||||
{
|
||||
model: 'gpt-3.5-turbo-16k',
|
||||
name: 'GPT35-16k',
|
||||
maxContext: 16000,
|
||||
maxResponse: 16000,
|
||||
price: 0
|
||||
}
|
||||
];
|
||||
export const defaultCQModels: FunctionModelItemType[] = [
|
||||
{
|
||||
model: 'gpt-3.5-turbo-1106',
|
||||
name: 'GPT35-1106',
|
||||
maxContext: 16000,
|
||||
maxResponse: 4000,
|
||||
price: 0,
|
||||
functionCall: true,
|
||||
functionPrompt: ''
|
||||
},
|
||||
{
|
||||
model: 'gpt-4',
|
||||
name: 'GPT4-8k',
|
||||
maxContext: 8000,
|
||||
maxResponse: 8000,
|
||||
price: 0,
|
||||
functionCall: true,
|
||||
functionPrompt: ''
|
||||
}
|
||||
];
|
||||
export const defaultExtractModels: FunctionModelItemType[] = [
|
||||
{
|
||||
model: 'gpt-3.5-turbo-1106',
|
||||
name: 'GPT35-1106',
|
||||
maxContext: 16000,
|
||||
maxResponse: 4000,
|
||||
price: 0,
|
||||
functionCall: true,
|
||||
functionPrompt: ''
|
||||
}
|
||||
];
|
||||
export const defaultQGModels: LLMModelItemType[] = [
|
||||
{
|
||||
model: 'gpt-3.5-turbo-1106',
|
||||
name: 'GPT35-1106',
|
||||
maxContext: 1600,
|
||||
maxResponse: 4000,
|
||||
price: 0
|
||||
}
|
||||
];
|
||||
|
||||
export const defaultVectorModels: VectorModelItemType[] = [
|
||||
{
|
||||
model: 'text-embedding-ada-002',
|
||||
name: 'Embedding-2',
|
||||
price: 0,
|
||||
defaultToken: 500,
|
||||
maxToken: 3000
|
||||
}
|
||||
];
|
||||
|
||||
export const defaultAudioSpeechModels: AudioSpeechModelType[] = [
|
||||
{
|
||||
model: 'tts-1',
|
||||
name: 'OpenAI TTS1',
|
||||
price: 0
|
||||
},
|
||||
{
|
||||
model: 'tts-1-hd',
|
||||
name: 'OpenAI TTS1',
|
||||
price: 0
|
||||
}
|
||||
];
|
8
packages/global/core/ai/speech/api.d.ts
vendored
Normal file
8
packages/global/core/ai/speech/api.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Text2SpeechVoiceEnum } from './constant';
|
||||
|
||||
export type Text2SpeechProps = {
|
||||
model?: string;
|
||||
voice?: `${Text2SpeechVoiceEnum}`;
|
||||
input: string;
|
||||
speed?: number;
|
||||
};
|
17
packages/global/core/ai/speech/constant.ts
Normal file
17
packages/global/core/ai/speech/constant.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export enum Text2SpeechVoiceEnum {
|
||||
alloy = 'alloy',
|
||||
echo = 'echo',
|
||||
fable = 'fable',
|
||||
onyx = 'onyx',
|
||||
nova = 'nova',
|
||||
shimmer = 'shimmer'
|
||||
}
|
||||
export const openaiTTSList = [
|
||||
Text2SpeechVoiceEnum.alloy,
|
||||
Text2SpeechVoiceEnum.echo,
|
||||
Text2SpeechVoiceEnum.fable,
|
||||
Text2SpeechVoiceEnum.onyx,
|
||||
Text2SpeechVoiceEnum.nova,
|
||||
Text2SpeechVoiceEnum.shimmer
|
||||
];
|
||||
export const openaiTTSModel = 'tts-1';
|
20
packages/global/core/ai/type.d.ts
vendored
20
packages/global/core/ai/type.d.ts
vendored
@@ -1,9 +1,19 @@
|
||||
import OpenAI from 'openai';
|
||||
export type ChatCompletionRequestMessage = OpenAI.Chat.CreateChatCompletionRequestMessage;
|
||||
export type ChatCompletion = OpenAI.Chat.ChatCompletion;
|
||||
export type CreateChatCompletionRequest = OpenAI.Chat.ChatCompletionCreateParams;
|
||||
import type {
|
||||
ChatCompletion,
|
||||
ChatCompletionCreateParams,
|
||||
ChatCompletionChunk,
|
||||
ChatCompletionMessageParam,
|
||||
ChatCompletionContentPart
|
||||
} from 'openai/resources';
|
||||
export type ChatCompletionContentPart = ChatCompletionContentPart;
|
||||
export type ChatCompletionCreateParams = ChatCompletionCreateParams;
|
||||
export type ChatMessageItemType = Omit<ChatCompletionMessageParam> & {
|
||||
dataId?: string;
|
||||
content: any;
|
||||
};
|
||||
|
||||
export type StreamChatType = Stream<OpenAI.Chat.ChatCompletionChunk>;
|
||||
export type ChatCompletion = ChatCompletion;
|
||||
export type StreamChatType = Stream<ChatCompletionChunk>;
|
||||
|
||||
export type PromptTemplateItem = {
|
||||
title: string;
|
||||
|
18
packages/global/core/app/api.d.ts
vendored
Normal file
18
packages/global/core/app/api.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { AppTypeEnum } from './constants';
|
||||
import { AppSchema } from './type';
|
||||
|
||||
export type CreateAppParams = {
|
||||
name?: string;
|
||||
avatar?: string;
|
||||
type?: `${AppTypeEnum}`;
|
||||
modules: AppSchema['modules'];
|
||||
};
|
||||
|
||||
export interface AppUpdateParams {
|
||||
name?: string;
|
||||
type?: `${AppTypeEnum}`;
|
||||
avatar?: string;
|
||||
intro?: string;
|
||||
modules?: AppSchema['modules'];
|
||||
permission?: AppSchema['permission'];
|
||||
}
|
4
packages/global/core/app/constants.ts
Normal file
4
packages/global/core/app/constants.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export enum AppTypeEnum {
|
||||
basic = 'basic',
|
||||
advanced = 'advanced'
|
||||
}
|
32
packages/global/core/app/type.d.ts
vendored
Normal file
32
packages/global/core/app/type.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ModuleItemType } from '../module/type';
|
||||
import { AppTypeEnum } from './constants';
|
||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||
import { Text2SpeechVoiceEnum } from '../ai/speech/constant';
|
||||
|
||||
export interface AppSchema {
|
||||
_id: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
name: string;
|
||||
type: `${AppTypeEnum}`;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
updateTime: number;
|
||||
modules: ModuleItemType[];
|
||||
permission: `${PermissionTypeEnum}`;
|
||||
}
|
||||
|
||||
export type AppListItemType = {
|
||||
_id: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
isOwner: boolean;
|
||||
permission: `${PermissionTypeEnum}`;
|
||||
};
|
||||
|
||||
export type AppDetailType = AppSchema & {
|
||||
isOwner: boolean;
|
||||
canWrite: boolean;
|
||||
};
|
34
packages/global/core/chat/api.d.ts
vendored
Normal file
34
packages/global/core/chat/api.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ModuleItemType } from '../module/type';
|
||||
import { AdminFbkType, ChatItemType, moduleDispatchResType } from './type';
|
||||
|
||||
export type UpdateHistoryProps = {
|
||||
chatId: string;
|
||||
customTitle?: string;
|
||||
top?: boolean;
|
||||
};
|
||||
|
||||
export type AdminUpdateFeedbackParams = AdminFbkType & {
|
||||
chatItemId: string;
|
||||
};
|
||||
|
||||
export type InitChatResponse = {
|
||||
chatId: string;
|
||||
appId: string;
|
||||
app: {
|
||||
userGuideModule?: ModuleItemType;
|
||||
chatModels?: string[];
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
canUse?: boolean;
|
||||
};
|
||||
title: string;
|
||||
variables: Record<string, any>;
|
||||
history: ChatItemType[];
|
||||
};
|
||||
|
||||
export type ChatHistoryItemResType = moduleDispatchResType & {
|
||||
moduleType: `${FlowNodeTypeEnum}`;
|
||||
moduleName: string;
|
||||
moduleLogo?: string;
|
||||
};
|
56
packages/global/core/chat/constants.ts
Normal file
56
packages/global/core/chat/constants.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
export enum ChatRoleEnum {
|
||||
System = 'System',
|
||||
Human = 'Human',
|
||||
AI = 'AI',
|
||||
Function = 'Function',
|
||||
Tool = 'Tool'
|
||||
}
|
||||
|
||||
export enum TaskResponseKeyEnum {
|
||||
'answerText' = 'answerText', // answer module text key
|
||||
'responseData' = 'responseData',
|
||||
'history' = 'history'
|
||||
}
|
||||
|
||||
export const ChatRoleMap = {
|
||||
[ChatRoleEnum.System]: {
|
||||
name: '系统提示词'
|
||||
},
|
||||
[ChatRoleEnum.Human]: {
|
||||
name: '用户'
|
||||
},
|
||||
[ChatRoleEnum.AI]: {
|
||||
name: 'AI'
|
||||
},
|
||||
[ChatRoleEnum.Function]: {
|
||||
name: 'Function'
|
||||
},
|
||||
[ChatRoleEnum.Tool]: {
|
||||
name: 'Tool'
|
||||
}
|
||||
};
|
||||
|
||||
export enum ChatSourceEnum {
|
||||
test = 'test',
|
||||
online = 'online',
|
||||
share = 'share',
|
||||
api = 'api'
|
||||
}
|
||||
|
||||
export const ChatSourceMap = {
|
||||
[ChatSourceEnum.test]: {
|
||||
name: 'chat.logs.test'
|
||||
},
|
||||
[ChatSourceEnum.online]: {
|
||||
name: 'chat.logs.online'
|
||||
},
|
||||
[ChatSourceEnum.share]: {
|
||||
name: 'chat.logs.share'
|
||||
},
|
||||
[ChatSourceEnum.api]: {
|
||||
name: 'chat.logs.api'
|
||||
}
|
||||
};
|
||||
|
||||
export const HUMAN_ICON = `/icon/human.svg`;
|
||||
export const LOGO_ICON = `/icon/logo.svg`;
|
111
packages/global/core/chat/type.d.ts
vendored
Normal file
111
packages/global/core/chat/type.d.ts
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
import { ClassifyQuestionAgentItemType } from '../module/type';
|
||||
import { SearchDataResponseItemType } from '../dataset/type';
|
||||
import { ChatRoleEnum, ChatSourceEnum, TaskResponseKeyEnum } from './constants';
|
||||
import { FlowNodeTypeEnum } from '../module/node/constant';
|
||||
import { AppSchema } from 'core/app/type';
|
||||
|
||||
export type ChatSchema = {
|
||||
_id: string;
|
||||
chatId: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
appId: string;
|
||||
updateTime: Date;
|
||||
title: string;
|
||||
customTitle: string;
|
||||
top: boolean;
|
||||
variables: Record<string, any>;
|
||||
source: `${ChatSourceEnum}`;
|
||||
shareId?: string;
|
||||
isInit: boolean;
|
||||
content: ChatItemType[];
|
||||
};
|
||||
|
||||
export type ChatWithAppSchema = Omit<ChatSchema, 'appId'> & {
|
||||
appId: AppSchema;
|
||||
};
|
||||
|
||||
export type ChatItemSchema = {
|
||||
dataId: string;
|
||||
chatId: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
appId: string;
|
||||
time: Date;
|
||||
obj: `${ChatRoleEnum}`;
|
||||
value: string;
|
||||
userFeedback?: string;
|
||||
adminFeedback?: AdminFbkType;
|
||||
[TaskResponseKeyEnum.responseData]?: ChatHistoryItemResType[];
|
||||
tts?: Buffer;
|
||||
};
|
||||
|
||||
export type AdminFbkType = {
|
||||
dataId: string;
|
||||
datasetId: string;
|
||||
collectionId: string;
|
||||
q: string;
|
||||
a?: string;
|
||||
};
|
||||
|
||||
export type ChatItemType = {
|
||||
dataId?: string;
|
||||
obj: ChatItemSchema['obj'];
|
||||
value: any;
|
||||
userFeedback?: string;
|
||||
adminFeedback?: ChatItemSchema['feedback'];
|
||||
[TaskResponseKeyEnum.responseData]?: ChatItemSchema[TaskResponseKeyEnum.responseData];
|
||||
};
|
||||
|
||||
export type ChatSiteItemType = {
|
||||
status: 'loading' | 'running' | 'finish';
|
||||
moduleName?: string;
|
||||
ttsBuffer?: Buffer;
|
||||
} & ChatItemType;
|
||||
|
||||
export type HistoryItemType = {
|
||||
chatId: string;
|
||||
updateTime: Date;
|
||||
customTitle?: string;
|
||||
title: string;
|
||||
};
|
||||
export type ChatHistoryItemType = HistoryItemType & {
|
||||
appId: string;
|
||||
top: boolean;
|
||||
};
|
||||
|
||||
// response data
|
||||
export type moduleDispatchResType = {
|
||||
price: number;
|
||||
runningTime?: number;
|
||||
tokens?: number;
|
||||
model?: string;
|
||||
|
||||
// chat
|
||||
question?: string;
|
||||
temperature?: number;
|
||||
maxToken?: number;
|
||||
quoteList?: SearchDataResponseItemType[];
|
||||
historyPreview?: ChatItemType[]; // completion context array. history will slice
|
||||
|
||||
// dataset search
|
||||
similarity?: number;
|
||||
limit?: number;
|
||||
|
||||
// cq
|
||||
cqList?: ClassifyQuestionAgentItemType[];
|
||||
cqResult?: string;
|
||||
|
||||
// content extract
|
||||
extractDescription?: string;
|
||||
extractResult?: Record<string, any>;
|
||||
|
||||
// http
|
||||
body?: Record<string, any>;
|
||||
httpResult?: Record<string, any>;
|
||||
|
||||
// plugin output
|
||||
pluginOutput?: Record<string, any>;
|
||||
};
|
@@ -1,3 +1,5 @@
|
||||
export const PgDatasetTableName = 'modeldata';
|
||||
|
||||
export enum DatasetTypeEnum {
|
||||
folder = 'folder',
|
||||
dataset = 'dataset'
|
||||
|
50
packages/global/core/dataset/type.d.ts
vendored
50
packages/global/core/dataset/type.d.ts
vendored
@@ -1,20 +1,26 @@
|
||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||
import { DatasetCollectionTypeEnum, DatasetTypeEnum, TrainingModeEnum } from './constant';
|
||||
|
||||
export type DatasetSchemaType = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
parentId: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
updateTime: Date;
|
||||
avatar: string;
|
||||
name: string;
|
||||
vectorModel: string;
|
||||
tags: string[];
|
||||
type: `${DatasetTypeEnum}`;
|
||||
permission: `${PermissionTypeEnum}`;
|
||||
};
|
||||
|
||||
export type DatasetCollectionSchemaType = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
datasetId: string;
|
||||
parentId?: string;
|
||||
name: string;
|
||||
@@ -30,6 +36,8 @@ export type DatasetCollectionSchemaType = {
|
||||
export type DatasetTrainingSchemaType = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
datasetId: string;
|
||||
datasetCollectionId: string;
|
||||
billId: string;
|
||||
@@ -42,17 +50,35 @@ export type DatasetTrainingSchemaType = {
|
||||
a: string;
|
||||
};
|
||||
|
||||
export type CollectionWithDatasetType = Omit<DatasetCollectionSchemaType, 'datasetId'> & {
|
||||
datasetId: DatasetSchemaType;
|
||||
};
|
||||
|
||||
/* ================= dataset ===================== */
|
||||
|
||||
/* ================= collection ===================== */
|
||||
export type DatasetCollectionItemType = DatasetCollectionSchemaType & {
|
||||
canWrite: boolean;
|
||||
};
|
||||
|
||||
/* ================= data ===================== */
|
||||
export type PgRawDataItemType = {
|
||||
id: string;
|
||||
q: string;
|
||||
a: string;
|
||||
team_id: string;
|
||||
tmb_id: string;
|
||||
dataset_id: string;
|
||||
collection_id: string;
|
||||
};
|
||||
export type PgDataItemType = {
|
||||
id: string;
|
||||
q: string;
|
||||
a: string;
|
||||
dataset_id: string;
|
||||
collection_id: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
datasetId: string;
|
||||
collectionId: string;
|
||||
};
|
||||
export type DatasetChunkItemType = {
|
||||
q: string;
|
||||
@@ -66,8 +92,24 @@ export type DatasetDataItemType = DatasetChunkItemType & {
|
||||
sourceId?: string;
|
||||
};
|
||||
|
||||
/* --------------- file ---------------------- */
|
||||
export type DatasetFileSchema = {
|
||||
_id: string;
|
||||
length: number;
|
||||
chunkSize: number;
|
||||
uploadDate: Date;
|
||||
filename: string;
|
||||
contentType: string;
|
||||
metadata: {
|
||||
contentType: string;
|
||||
datasetId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
};
|
||||
};
|
||||
|
||||
/* ============= search =============== */
|
||||
export type SearchDataResultItemType = PgDataItemType & {
|
||||
export type SearchDataResultItemType = PgRawDataItemType & {
|
||||
score: number;
|
||||
};
|
||||
export type SearchDataResponseItemType = DatasetDataItemType & {
|
||||
|
0
packages/global/core/module/api.d.ts
vendored
Normal file
0
packages/global/core/module/api.d.ts
vendored
Normal file
13
packages/global/core/module/type.d.ts
vendored
13
packages/global/core/module/type.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { FlowNodeTypeEnum } from './node/constant';
|
||||
import { FlowNodeTypeEnum, FlowNodeValTypeEnum } from './node/constant';
|
||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
|
||||
|
||||
export type FlowModuleTemplateType = {
|
||||
@@ -42,3 +42,14 @@ export type SelectAppItemType = {
|
||||
name: string;
|
||||
logo: string;
|
||||
};
|
||||
|
||||
/* agent */
|
||||
export type ClassifyQuestionAgentItemType = {
|
||||
value: string;
|
||||
key: string;
|
||||
};
|
||||
export type ContextExtractAgentItemType = {
|
||||
desc: string;
|
||||
key: string;
|
||||
required: boolean;
|
||||
};
|
||||
|
2
packages/global/core/plugin/type.d.ts
vendored
2
packages/global/core/plugin/type.d.ts
vendored
@@ -3,6 +3,8 @@ import type { ModuleItemType } from '../module/type.d';
|
||||
export type PluginItemSchema = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
|
@@ -6,7 +6,7 @@
|
||||
"timezones-list": "^3.0.2",
|
||||
"dayjs": "^1.11.7",
|
||||
"encoding": "^0.1.13",
|
||||
"openai": "^4.12.1"
|
||||
"openai": "^4.16.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.8.5"
|
||||
|
2
packages/global/support/openapi/type.d.ts
vendored
2
packages/global/support/openapi/type.d.ts
vendored
@@ -1,6 +1,8 @@
|
||||
export type OpenApiSchema = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
createTime: Date;
|
||||
lastUsedTime?: Date;
|
||||
apiKey: string;
|
||||
|
27
packages/global/support/outLink/api.d.ts
vendored
Normal file
27
packages/global/support/outLink/api.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { HistoryItemType, ChatSiteItemType } from '../../core/chat/type.d';
|
||||
import type { InitChatResponse } from '../../core/chat/api.d';
|
||||
import { OutLinkSchema } from '@fastgpt/global/support/outLink/type';
|
||||
|
||||
export type InitShareChatResponse = {
|
||||
userAvatar: string;
|
||||
app: InitChatResponse['app'];
|
||||
};
|
||||
|
||||
/* one page type */
|
||||
export type ShareChatType = InitShareChatResponse & {
|
||||
history: ShareChatHistoryItemType;
|
||||
};
|
||||
|
||||
/* history list item type */
|
||||
export type ShareChatHistoryItemType = HistoryItemType & {
|
||||
shareId: string;
|
||||
variables?: Record<string, any>;
|
||||
chats: ChatSiteItemType[];
|
||||
};
|
||||
|
||||
export type AuthLinkChatProps = { ip?: string | null; authToken?: string; question: string };
|
||||
export type AuthLinkLimitProps = AuthLinkChatProps & { outLink: OutLinkSchema };
|
||||
export type AuthShareChatInitProps = {
|
||||
authToken?: string;
|
||||
tokenUrl?: string;
|
||||
};
|
2
packages/global/support/outLink/type.d.ts
vendored
2
packages/global/support/outLink/type.d.ts
vendored
@@ -4,6 +4,8 @@ export type OutLinkSchema = {
|
||||
_id: string;
|
||||
shareId: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
appId: string;
|
||||
name: string;
|
||||
total: number;
|
||||
|
21
packages/global/support/permission/constant.ts
Normal file
21
packages/global/support/permission/constant.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export enum AuthUserTypeEnum {
|
||||
token = 'token',
|
||||
root = 'root',
|
||||
apikey = 'apikey',
|
||||
outLink = 'outLink'
|
||||
}
|
||||
|
||||
export enum PermissionTypeEnum {
|
||||
'private' = 'private',
|
||||
'public' = 'public'
|
||||
}
|
||||
export const PermissionTypeMap = {
|
||||
[PermissionTypeEnum.private]: {
|
||||
iconLight: 'support/permission/privateLight',
|
||||
label: 'permission.Private'
|
||||
},
|
||||
[PermissionTypeEnum.public]: {
|
||||
iconLight: 'support/permission/publicLight',
|
||||
label: 'permission.Public'
|
||||
}
|
||||
};
|
12
packages/global/support/permission/type.d.ts
vendored
Normal file
12
packages/global/support/permission/type.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { AuthUserTypeEnum } from './constant';
|
||||
|
||||
export type AuthResponseType = {
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
isOwner: boolean;
|
||||
canWrite: boolean;
|
||||
authType?: `${AuthUserTypeEnum}`;
|
||||
appId?: string;
|
||||
apikey?: string;
|
||||
};
|
27
packages/global/support/permission/utils.ts
Normal file
27
packages/global/support/permission/utils.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { TeamMemberRoleEnum } from '../user/team/constant';
|
||||
import { PermissionTypeEnum } from './constant';
|
||||
|
||||
/* team public source, or owner source in team */
|
||||
export function mongoRPermission({
|
||||
teamId,
|
||||
tmbId,
|
||||
role
|
||||
}: {
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
role: `${TeamMemberRoleEnum}`;
|
||||
}) {
|
||||
return {
|
||||
teamId,
|
||||
...(role === TeamMemberRoleEnum.visitor && { permission: PermissionTypeEnum.public }),
|
||||
...(role === TeamMemberRoleEnum.admin && {
|
||||
$or: [{ permission: PermissionTypeEnum.public }, { tmbId }]
|
||||
})
|
||||
};
|
||||
}
|
||||
export function mongoOwnerPermission({ teamId, tmbId }: { teamId: string; tmbId: string }) {
|
||||
return {
|
||||
teamId,
|
||||
tmbId
|
||||
};
|
||||
}
|
15
packages/global/support/user/api.d.ts
vendored
Normal file
15
packages/global/support/user/api.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { OAuthEnum } from './constant';
|
||||
|
||||
export type PostLoginProps = {
|
||||
username: string;
|
||||
password: string;
|
||||
tmbId?: string;
|
||||
};
|
||||
|
||||
export type OauthLoginProps = {
|
||||
type: `${OAuthEnum}`;
|
||||
code: string;
|
||||
callbackUrl: string;
|
||||
inviterId?: string;
|
||||
tmbId?: string;
|
||||
};
|
@@ -1,30 +1,4 @@
|
||||
export enum InformTypeEnum {
|
||||
system = 'system'
|
||||
export enum OAuthEnum {
|
||||
github = 'github',
|
||||
google = 'google'
|
||||
}
|
||||
|
||||
export const InformTypeMap = {
|
||||
[InformTypeEnum.system]: {
|
||||
label: '系统通知'
|
||||
}
|
||||
};
|
||||
|
||||
export enum TeamMemberRoleEnum {
|
||||
owner = 'owner',
|
||||
admin = 'admin',
|
||||
member = 'member',
|
||||
visitor = 'visitor'
|
||||
}
|
||||
export const TeamMemberRoleMap = {
|
||||
[TeamMemberRoleEnum.owner]: {
|
||||
label: 'user.team.role.owner'
|
||||
},
|
||||
[TeamMemberRoleEnum.admin]: {
|
||||
label: 'user.team.role.admin'
|
||||
},
|
||||
[TeamMemberRoleEnum.member]: {
|
||||
label: 'user.team.role.member'
|
||||
},
|
||||
[TeamMemberRoleEnum.visitor]: {
|
||||
label: 'user.team.role.visitor'
|
||||
}
|
||||
};
|
||||
|
21
packages/global/support/user/controller.d.ts
vendored
21
packages/global/support/user/controller.d.ts
vendored
@@ -1,21 +0,0 @@
|
||||
export type CreateTeamProps = {
|
||||
ownerId: string;
|
||||
name: string;
|
||||
avatar?: string;
|
||||
};
|
||||
export type UpdateTeamProps = {
|
||||
id: string;
|
||||
name?: string;
|
||||
avatar?: string;
|
||||
};
|
||||
export type updateTeamBalanceProps = {
|
||||
id: string;
|
||||
balance: number;
|
||||
};
|
||||
|
||||
export type CreateTeamMemberProps = {
|
||||
ownerId: string;
|
||||
teamId: string;
|
||||
userId: string;
|
||||
name?: string;
|
||||
};
|
9
packages/global/support/user/inform/constants.ts
Normal file
9
packages/global/support/user/inform/constants.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export enum InformTypeEnum {
|
||||
system = 'system'
|
||||
}
|
||||
|
||||
export const InformTypeMap = {
|
||||
[InformTypeEnum.system]: {
|
||||
label: '系统通知'
|
||||
}
|
||||
};
|
18
packages/global/support/user/inform/type.d.ts
vendored
Normal file
18
packages/global/support/user/inform/type.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { InformTypeEnum } from './constant';
|
||||
|
||||
export type SendInformProps = {
|
||||
tmbId?: string;
|
||||
type: `${InformTypeEnum}`;
|
||||
title: string;
|
||||
content: string;
|
||||
};
|
||||
|
||||
export type UserInformSchema = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
time: Date;
|
||||
type: `${InformTypeEnum}`;
|
||||
title: string;
|
||||
content: string;
|
||||
read: boolean;
|
||||
};
|
42
packages/global/support/user/team/constant.ts
Normal file
42
packages/global/support/user/team/constant.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
export const TeamCollectionName = 'teams';
|
||||
export const TeamMemberCollectionName = 'team.members';
|
||||
|
||||
export enum TeamMemberRoleEnum {
|
||||
owner = 'owner',
|
||||
admin = 'admin',
|
||||
visitor = 'visitor'
|
||||
}
|
||||
export const TeamMemberRoleMap = {
|
||||
[TeamMemberRoleEnum.owner]: {
|
||||
value: TeamMemberRoleEnum.owner,
|
||||
label: 'user.team.role.Owner'
|
||||
},
|
||||
[TeamMemberRoleEnum.admin]: {
|
||||
value: TeamMemberRoleEnum.admin,
|
||||
label: 'user.team.role.Admin'
|
||||
},
|
||||
[TeamMemberRoleEnum.visitor]: {
|
||||
value: TeamMemberRoleEnum.visitor,
|
||||
label: 'user.team.role.Visitor'
|
||||
}
|
||||
};
|
||||
|
||||
export enum TeamMemberStatusEnum {
|
||||
waiting = 'waiting',
|
||||
active = 'active',
|
||||
reject = 'reject'
|
||||
}
|
||||
export const TeamMemberStatusMap = {
|
||||
[TeamMemberStatusEnum.waiting]: {
|
||||
label: 'user.team.member.waiting',
|
||||
color: 'orange.600'
|
||||
},
|
||||
[TeamMemberStatusEnum.active]: {
|
||||
label: 'user.team.member.active',
|
||||
color: 'green.600'
|
||||
},
|
||||
[TeamMemberStatusEnum.reject]: {
|
||||
label: 'user.team.member.reject',
|
||||
color: 'red.600'
|
||||
}
|
||||
};
|
40
packages/global/support/user/team/controller.d.ts
vendored
Normal file
40
packages/global/support/user/team/controller.d.ts
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { TeamMemberRoleEnum } from './constant';
|
||||
import { TeamMemberSchema } from './type';
|
||||
|
||||
export type AuthTeamRoleProps = {
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
role?: `${TeamMemberRoleEnum}`;
|
||||
};
|
||||
export type CreateTeamProps = {
|
||||
name: string;
|
||||
avatar?: string;
|
||||
defaultTeam?: boolean;
|
||||
};
|
||||
export type UpdateTeamProps = {
|
||||
teamId: string;
|
||||
name?: string;
|
||||
avatar?: string;
|
||||
};
|
||||
|
||||
/* ------------- member ----------- */
|
||||
export type DelMemberProps = {
|
||||
teamId: string;
|
||||
memberId: string;
|
||||
};
|
||||
export type UpdateTeamMemberProps = {
|
||||
teamId: string;
|
||||
memberId: string;
|
||||
role?: TeamMemberSchema['role'];
|
||||
status?: TeamMemberSchema['status'];
|
||||
};
|
||||
export type InviteMemberProps = {
|
||||
teamId: string;
|
||||
usernames: string[];
|
||||
role: `${TeamMemberRoleEnum}`;
|
||||
};
|
||||
export type UpdateInviteProps = {
|
||||
tmbId: string;
|
||||
status: TeamMemberSchema['status'];
|
||||
};
|
||||
export type InviteMemberResponse = Record<'invite' | 'inValid' | 'inTeam', string[]>;
|
46
packages/global/support/user/team/type.d.ts
vendored
Normal file
46
packages/global/support/user/team/type.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { UserModelSchema } from '../type';
|
||||
import { TeamMemberRoleEnum, TeamMemberStatusEnum } from './constant';
|
||||
|
||||
export type TeamSchema = {
|
||||
_id: string;
|
||||
name: string;
|
||||
ownerId: string;
|
||||
avatar: string;
|
||||
createTime: Date;
|
||||
balance: number;
|
||||
maxSize: number;
|
||||
};
|
||||
|
||||
export type TeamMemberSchema = {
|
||||
_id: string;
|
||||
teamId: string;
|
||||
userId: string;
|
||||
createTime: Date;
|
||||
role: `${TeamMemberRoleEnum}`;
|
||||
status: `${TeamMemberStatusEnum}`;
|
||||
defaultTeam: boolean;
|
||||
};
|
||||
|
||||
export type TeamItemType = {
|
||||
userId: string;
|
||||
teamId: string;
|
||||
teamName: string;
|
||||
avatar: string;
|
||||
balance: number;
|
||||
tmbId: string;
|
||||
defaultTeam: boolean;
|
||||
role: `${TeamMemberRoleEnum}`;
|
||||
status: `${TeamMemberStatusEnum}`;
|
||||
canWrite: boolean;
|
||||
maxSize: number;
|
||||
};
|
||||
|
||||
export type TeamMemberItemType = {
|
||||
userId: string;
|
||||
tmbId: string;
|
||||
teamId: string;
|
||||
memberUsername: string;
|
||||
avatar: string;
|
||||
role: `${TeamMemberRoleEnum}`;
|
||||
status: `${TeamMemberStatusEnum}`;
|
||||
};
|
32
packages/global/support/user/type.d.ts
vendored
32
packages/global/support/user/type.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
import { InformTypeEnum, TeamMemberRoleEnum } from './constant';
|
||||
import { InformTypeEnum } from './constant';
|
||||
import { TeamItemType } from './team/type';
|
||||
|
||||
export type UserModelSchema = {
|
||||
_id: string;
|
||||
@@ -21,28 +22,13 @@ export type UserModelSchema = {
|
||||
};
|
||||
};
|
||||
|
||||
export type UserInformSchema = {
|
||||
export type UserType = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
time: Date;
|
||||
type: `${InformTypeEnum}`;
|
||||
title: string;
|
||||
content: string;
|
||||
read: boolean;
|
||||
};
|
||||
|
||||
export type TeamSchema = {
|
||||
_id: string;
|
||||
name: string;
|
||||
ownerId: string;
|
||||
username: string;
|
||||
avatar: string;
|
||||
createTime: Date;
|
||||
};
|
||||
|
||||
export type TeamMemberSchema = {
|
||||
_id: string;
|
||||
name: string;
|
||||
teamId: string;
|
||||
userId: string;
|
||||
role: `${TeamMemberRoleEnum}`;
|
||||
balance: number;
|
||||
timezone: string;
|
||||
promotionRate: UserModelSchema['promotionRate'];
|
||||
openaiAccount: UserModelSchema['openaiAccount'];
|
||||
team: TeamItemType;
|
||||
};
|
||||
|
25
packages/global/support/wallet/bill/api.d.ts
vendored
Normal file
25
packages/global/support/wallet/bill/api.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { BillSourceEnum } from './constants';
|
||||
import { BillListItemType } from './type';
|
||||
|
||||
export type CreateTrainingBillProps = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type ConcatBillProps = {
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
billId?: string;
|
||||
total: number;
|
||||
listIndex?: number;
|
||||
tokens?: number;
|
||||
};
|
||||
|
||||
export type CreateBillProps = {
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
appName: string;
|
||||
appId?: string;
|
||||
total: number;
|
||||
source: `${BillSourceEnum}`;
|
||||
list: BillListItemType[];
|
||||
};
|
16
packages/global/support/wallet/bill/constants.ts
Normal file
16
packages/global/support/wallet/bill/constants.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// ¥1 = 100000
|
||||
export const PRICE_SCALE = 100000;
|
||||
|
||||
export enum BillSourceEnum {
|
||||
fastgpt = 'fastgpt',
|
||||
api = 'api',
|
||||
shareLink = 'shareLink',
|
||||
training = 'training'
|
||||
}
|
||||
|
||||
export const BillSourceMap: Record<`${BillSourceEnum}`, string> = {
|
||||
[BillSourceEnum.fastgpt]: '在线使用',
|
||||
[BillSourceEnum.api]: 'Api',
|
||||
[BillSourceEnum.shareLink]: '免登录链接',
|
||||
[BillSourceEnum.training]: '数据训练'
|
||||
};
|
@@ -1,5 +1,6 @@
|
||||
/* bill common */
|
||||
import { PRICE_SCALE } from './constants';
|
||||
import { BillItemType, BillSchema } from './type';
|
||||
|
||||
/**
|
||||
* dataset price / PRICE_SCALE = real price
|
24
packages/global/support/wallet/bill/type.d.ts
vendored
Normal file
24
packages/global/support/wallet/bill/type.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { CreateBillProps } from './api';
|
||||
import { BillSourceEnum } from './constants';
|
||||
|
||||
export type BillListItemType = {
|
||||
moduleName: string;
|
||||
amount: number;
|
||||
model?: string;
|
||||
tokenLen?: number;
|
||||
};
|
||||
|
||||
export type BillSchema = CreateBillProps & {
|
||||
_id: string;
|
||||
time: Date;
|
||||
};
|
||||
|
||||
export type BillItemType = {
|
||||
id: string;
|
||||
username: string;
|
||||
time: Date;
|
||||
appName: string;
|
||||
source: BillSchema['source'];
|
||||
total: number;
|
||||
list: BillSchema['list'];
|
||||
};
|
@@ -1,6 +1,8 @@
|
||||
export type PaySchema = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
createTime: Date;
|
||||
price: number;
|
||||
orderId: string;
|
Reference in New Issue
Block a user