Revert "sub plan page (#885)" (#886)

This reverts commit 443ad37b6a.
This commit is contained in:
Archer
2024-02-23 17:48:15 +08:00
committed by GitHub
parent 443ad37b6a
commit fd9b6291af
246 changed files with 4281 additions and 6286 deletions

View File

@@ -3,25 +3,11 @@ import { ErrType } from '../errorCode';
/* team: 500000 */
export enum TeamErrEnum {
teamOverSize = 'teamOverSize',
unAuthTeam = 'unAuthTeam',
aiPointsNotEnough = 'aiPointsNotEnough',
datasetSizeNotEnough = 'datasetSizeNotEnough',
datasetAmountNotEnough = 'datasetAmountNotEnough',
appAmountNotEnough = 'appAmountNotEnough',
pluginAmountNotEnough = 'pluginAmountNotEnough',
websiteSyncNotEnough = 'websiteSyncNotEnough',
reRankNotEnough = 'reRankNotEnough'
unAuthTeam = 'unAuthTeam'
}
const teamErr = [
{ statusText: TeamErrEnum.teamOverSize, message: 'error.team.overSize' },
{ statusText: TeamErrEnum.unAuthTeam, message: '无权操作该团队' },
{ statusText: TeamErrEnum.aiPointsNotEnough, message: 'AI积分已用完~' },
{ statusText: TeamErrEnum.datasetSizeNotEnough, message: '知识库容量不足,请先扩容~' },
{ statusText: TeamErrEnum.datasetAmountNotEnough, message: '知识库数量已达上限~' },
{ statusText: TeamErrEnum.appAmountNotEnough, message: '应用数量已达上限~' },
{ statusText: TeamErrEnum.pluginAmountNotEnough, message: '插件数量已达上限~' },
{ statusText: TeamErrEnum.websiteSyncNotEnough, message: '无权使用Web站点同步~' },
{ statusText: TeamErrEnum.reRankNotEnough, message: '无权使用检索重排~' }
{ statusText: TeamErrEnum.unAuthTeam, message: '无权操作该团队' }
];
export default teamErr.reduce((acc, cur, index) => {
return {

View File

@@ -1,4 +0,0 @@
export const formatNumber = (num: number, digit = 1e4) => Math.round(num * digit) / digit;
export const formatNumber2Million = (num: number) => Math.round(num / 1000000);
export const formatNumber2Thousand = (num: number) => Math.round(num / 1000);

View File

@@ -6,7 +6,8 @@ export type LLMModelItemType = {
quoteMaxToken: number;
maxTemperature: number;
charsPointsPrice: number; // 1k chars=n points
inputPrice: number;
outputPrice: number;
censor?: boolean;
vision?: boolean;
@@ -26,7 +27,8 @@ export type VectorModelItemType = {
model: string;
name: string;
defaultToken: number;
charsPointsPrice: number;
inputPrice: number;
outputPrice: number;
maxToken: number;
weight: number;
hidden?: boolean;
@@ -36,7 +38,8 @@ export type VectorModelItemType = {
export type ReRankModelItemType = {
model: string;
name: string;
charsPointsPrice: number;
inputPrice: number;
outputPrice?: number;
requestUrl?: string;
requestAuth?: string;
};
@@ -44,12 +47,14 @@ export type ReRankModelItemType = {
export type AudioSpeechModelType = {
model: string;
name: string;
charsPointsPrice: number;
inputPrice: number;
outputPrice?: number;
voices: { label: string; value: string; bufferId: string }[];
};
export type WhisperModelType = {
model: string;
name: string;
charsPointsPrice: number; // 60s = n points
inputPrice: number;
outputPrice?: number;
};

View File

@@ -8,7 +8,8 @@ export const defaultQAModels: LLMModelItemType[] = [
maxResponse: 16000,
quoteMaxToken: 13000,
maxTemperature: 1.2,
charsPointsPrice: 0,
inputPrice: 0,
outputPrice: 0,
censor: false,
vision: false,
datasetProcess: true,
@@ -25,7 +26,8 @@ export const defaultVectorModels: VectorModelItemType[] = [
{
model: 'text-embedding-ada-002',
name: 'Embedding-2',
charsPointsPrice: 0,
inputPrice: 0,
outputPrice: 0,
defaultToken: 500,
maxToken: 3000,
weight: 100

View File

@@ -17,7 +17,6 @@ export interface AppUpdateParams {
intro?: string;
modules?: AppSchema['modules'];
permission?: AppSchema['permission'];
teamTags?: AppSchema['teamTags'];
}
export type FormatForm2ModulesProps = {

View File

@@ -5,7 +5,7 @@ import type { AIChatModuleProps, DatasetModuleProps } from '../module/node/type.
import { VariableInputEnum } from '../module/constants';
import { SelectedDatasetType } from '../module/api';
import { DatasetSearchModeEnum } from '../dataset/constants';
import { TeamTagsSchema as TeamTagsSchemaType } from '@fastgpt/global/support/user/team/type.d';
export interface AppSchema {
_id: string;
userId: string;
@@ -20,7 +20,6 @@ export interface AppSchema {
modules: ModuleItemType[];
permission: `${PermissionTypeEnum}`;
inited?: boolean;
teamTags: [string];
}
export type AppListItemType = {

View File

@@ -27,8 +27,7 @@ export enum ChatSourceEnum {
test = 'test',
online = 'online',
share = 'share',
api = 'api',
team = 'team'
api = 'api'
}
export const ChatSourceMap = {
[ChatSourceEnum.test]: {
@@ -42,9 +41,6 @@ export const ChatSourceMap = {
},
[ChatSourceEnum.api]: {
name: 'core.chat.logs.api'
},
[ChatSourceEnum.team]: {
name: 'core.chat.logs.team'
}
};

View File

@@ -4,7 +4,6 @@ import { ChatRoleEnum, ChatSourceEnum, ChatStatusEnum } from './constants';
import { FlowNodeTypeEnum } from '../module/node/constant';
import { ModuleOutputKeyEnum } from '../module/constants';
import { AppSchema } from '../app/type';
import type { AppSchema as AppType } from '@fastgpt/global/core/app/type.d';
import { DatasetSearchModeEnum } from '../dataset/constants';
export type ChatSchema = {
@@ -26,22 +25,6 @@ export type ChatSchema = {
metadata?: Record<string, any>;
};
export type teamInfoType = {
avatar: string;
balance: number;
createTime: string;
maxSize: number;
name: string;
ownerId: string;
tagsUrl: string;
_id: string;
}
export type chatAppListSchema = {
apps: Array<AppType>,
teamInfo: teamInfoSchema
}
export type ChatWithAppSchema = Omit<ChatSchema, 'appId'> & {
appId: AppSchema;
};
@@ -105,15 +88,15 @@ export type ChatHistoryItemType = HistoryItemType & {
export type moduleDispatchResType = {
// common
moduleLogo?: string;
price?: number;
runningTime?: number;
query?: string;
textOutput?: string;
// bill
inputTokens?: number;
outputTokens?: number;
charsLength?: number;
model?: string;
query?: string;
contextTotalLen?: number;
totalPoints?: number;
textOutput?: string;
// chat
temperature?: number;
@@ -128,7 +111,6 @@ export type moduleDispatchResType = {
searchUsingReRank?: boolean;
extensionModel?: string;
extensionResult?: string;
extensionCharsLength?: number;
// cq
cqList?: ClassifyQuestionAgentItemType[];

View File

@@ -71,6 +71,30 @@ export const DatasetCollectionSyncResultMap = {
};
/* ------------ data -------------- */
export enum DatasetDataIndexTypeEnum {
chunk = 'chunk',
qa = 'qa',
summary = 'summary',
hypothetical = 'hypothetical',
custom = 'custom'
}
export const DatasetDataIndexTypeMap = {
[DatasetDataIndexTypeEnum.chunk]: {
name: 'dataset.data.indexes.chunk'
},
[DatasetDataIndexTypeEnum.summary]: {
name: 'dataset.data.indexes.summary'
},
[DatasetDataIndexTypeEnum.hypothetical]: {
name: 'dataset.data.indexes.hypothetical'
},
[DatasetDataIndexTypeEnum.qa]: {
name: 'dataset.data.indexes.qa'
},
[DatasetDataIndexTypeEnum.custom]: {
name: 'dataset.data.indexes.custom'
}
};
/* ------------ training -------------- */
export enum TrainingModeEnum {

View File

@@ -3,6 +3,7 @@ import { PermissionTypeEnum } from '../../support/permission/constant';
import { PushDatasetDataChunkProps } from './api';
import {
DatasetCollectionTypeEnum,
DatasetDataIndexTypeEnum,
DatasetStatusEnum,
DatasetTypeEnum,
SearchScoreTypeEnum,
@@ -63,6 +64,7 @@ export type DatasetCollectionSchemaType = {
export type DatasetDataIndexItemType = {
defaultIndex: boolean;
dataId: string; // pg data id
type: `${DatasetDataIndexTypeEnum}`;
text: string;
};
export type DatasetDataSchemaType = {
@@ -140,7 +142,6 @@ export type DatasetCollectionItemType = CollectionWithDatasetType & {
/* ================= data ===================== */
export type DatasetDataItemType = {
id: string;
teamId: string;
datasetId: string;
collectionId: string;
sourceName: string;
@@ -172,7 +173,7 @@ export type DatasetFileSchema = {
/* ============= search =============== */
export type SearchDataResponseItemType = Omit<
DatasetDataItemType,
'teamId' | 'indexes' | 'isOwner' | 'canWrite'
'indexes' | 'isOwner' | 'canWrite'
> & {
score: { type: `${SearchScoreTypeEnum}`; value: number; index: number }[];
// score: number;

View File

@@ -1,4 +1,4 @@
import { TrainingModeEnum, DatasetCollectionTypeEnum } from './constants';
import { TrainingModeEnum, DatasetCollectionTypeEnum, DatasetDataIndexTypeEnum } from './constants';
import { getFileIcon } from '../../common/file/icon';
import { strIsLink } from '../../common/string/tools';
@@ -41,6 +41,7 @@ export function getDefaultIndex(props?: { q?: string; a?: string; dataId?: strin
const qaStr = `${q}\n${a}`.trim();
return {
defaultIndex: true,
type: a ? DatasetDataIndexTypeEnum.qa : DatasetDataIndexTypeEnum.chunk,
text: a ? qaStr : q,
dataId
};

View File

@@ -89,10 +89,9 @@ export enum ModuleInputKeyEnum {
export enum ModuleOutputKeyEnum {
// common
responseData = 'responseData',
moduleDispatchBills = 'moduleDispatchBills',
userChatInput = 'userChatInput',
finish = 'finish',
responseData = 'responseData',
history = 'history',
answerText = 'answerText', // answer module text key
success = 'success',

View File

@@ -20,7 +20,9 @@ export enum FlowNodeInputTypeEnum {
aiSettings = 'aiSettings',
// ai model select
selectLLMModel = 'selectLLMModel',
selectChatModel = 'selectChatModel',
selectCQModel = 'selectCQModel',
selectExtractModel = 'selectExtractModel',
// dataset special input
selectDataset = 'selectDataset',
@@ -56,7 +58,7 @@ export enum FlowNodeTypeEnum {
pluginModule = 'pluginModule',
pluginInput = 'pluginInput',
pluginOutput = 'pluginOutput',
queryExtension = 'cfr'
cfr = 'cfr'
// abandon
}

View File

@@ -31,7 +31,7 @@ export const AiChatModule: FlowModuleTemplateType = {
Input_Template_Switch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectLLMModel,
type: FlowNodeInputTypeEnum.selectChatModel,
label: 'core.module.input.label.aiModel',
required: true,
valueType: ModuleIOValueTypeEnum.string,

View File

@@ -24,7 +24,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
Input_Template_Switch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectLLMModel,
type: FlowNodeInputTypeEnum.selectCQModel,
valueType: ModuleIOValueTypeEnum.string,
label: 'core.module.input.label.Classify model',
required: true,

View File

@@ -24,7 +24,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
Input_Template_Switch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectLLMModel,
type: FlowNodeInputTypeEnum.selectExtractModel,
valueType: ModuleIOValueTypeEnum.string,
label: 'core.module.input.label.LLM',
required: true,

View File

@@ -3,7 +3,7 @@ import {
FlowNodeOutputTypeEnum,
FlowNodeTypeEnum
} from '../../node/constant';
import { FlowModuleTemplateType } from '../../type';
import { FlowModuleTemplateType } from '../../type.d';
import {
ModuleIOValueTypeEnum,
ModuleInputKeyEnum,
@@ -17,19 +17,19 @@ import {
} from '../input';
import { Output_Template_UserChatInput } from '../output';
export const AiQueryExtension: FlowModuleTemplateType = {
export const AiCFR: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.chatNode,
templateType: ModuleTemplateTypeEnum.other,
flowType: FlowNodeTypeEnum.queryExtension,
flowType: FlowNodeTypeEnum.cfr,
avatar: '/imgs/module/cfr.svg',
name: 'core.module.template.Query extension',
intro: 'core.module.template.Query extension intro',
intro: '该模块已合并到知识库搜索参数中无需单独使用。模块将于2024/3/31弃用请尽快修改。',
showStatus: true,
inputs: [
Input_Template_Switch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectLLMModel,
type: FlowNodeInputTypeEnum.selectExtractModel,
label: 'core.module.input.label.aiModel',
required: true,
valueType: ModuleIOValueTypeEnum.string,
@@ -39,7 +39,7 @@ export const AiQueryExtension: FlowModuleTemplateType = {
{
key: ModuleInputKeyEnum.aiSystemPrompt,
type: FlowNodeInputTypeEnum.textarea,
label: 'core.app.edit.Query extension background prompt',
label: 'core.module.input.label.Background',
max: 300,
valueType: ModuleIOValueTypeEnum.string,
description: 'core.app.edit.Query extension background tip',
@@ -54,8 +54,7 @@ export const AiQueryExtension: FlowModuleTemplateType = {
Output_Template_UserChatInput,
{
key: ModuleOutputKeyEnum.text,
label: 'core.module.output.label.query extension result',
description: 'core.module.output.description.query extension result',
label: 'core.module.output.label.cfr result',
valueType: ModuleIOValueTypeEnum.string,
type: FlowNodeOutputTypeEnum.source,
targets: []

View File

@@ -1,14 +1,6 @@
import { FlowNodeTypeEnum } from './node/constant';
import {
ModuleIOValueTypeEnum,
ModuleOutputKeyEnum,
ModuleTemplateTypeEnum,
VariableInputEnum
} from './constants';
import { ModuleIOValueTypeEnum, ModuleTemplateTypeEnum, VariableInputEnum } from './constants';
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
import { UserModelSchema } from 'support/user/type';
import { moduleDispatchResType } from '..//chat/type';
import { ChatModuleBillType } from '../../support/wallet/bill/type';
export type FlowModuleTemplateType = {
id: string; // module id, unique
@@ -113,7 +105,7 @@ export type ChatDispatchProps = {
mode: 'test' | 'chat';
teamId: string;
tmbId: string;
user: UserModelSchema;
user: UserType;
appId: string;
chatId?: string;
responseChatItemId?: string;
@@ -124,10 +116,7 @@ export type ChatDispatchProps = {
};
export type ModuleDispatchProps<T> = ChatDispatchProps & {
module: RunningModuleItemType;
outputs: RunningModuleItemType['outputs'];
inputs: RunningModuleItemType['inputs'];
params: T;
};
export type ModuleDispatchResponse<T> = T & {
[ModuleOutputKeyEnum.responseData]?: moduleDispatchResType;
[ModuleOutputKeyEnum.moduleDispatchBills]?: ChatModuleBillType[];
};

View File

@@ -1,5 +1,6 @@
export type OpenApiSchema = {
_id: string;
userId: string;
teamId: string;
tmbId: string;
createTime: Date;
@@ -7,9 +8,9 @@ export type OpenApiSchema = {
apiKey: string;
appId?: string;
name: string;
usagePoints: number;
usage: number;
limit?: {
expiredTime?: Date;
maxUsagePoints: number;
credit?: number;
};
};

View File

@@ -1,5 +1,5 @@
import type { HistoryItemType, ChatSiteItemType } from '../../core/chat/type.d';
import { OutLinkSchema } from './type.d';
import { OutLinkSchema } from '@fastgpt/global/support/outLink/type';
export type AuthOutLinkInitProps = {
outLinkUid: string;

View File

@@ -7,14 +7,14 @@ export type OutLinkSchema = {
tmbId: string;
appId: string;
name: string;
usagePoints: number;
total: number;
lastTime: Date;
type: `${OutLinkTypeEnum}`;
responseDetail: boolean;
limit?: {
expiredTime?: Date;
QPM: number;
maxUsagePoints: number;
credit: number;
hookUrl?: string;
};
};

View File

@@ -1,6 +1,7 @@
import { AuthUserTypeEnum } from './constant';
export type AuthResponseType = {
userId: string;
teamId: string;
tmbId: string;
isOwner: boolean;

View File

@@ -1,6 +1,5 @@
export const TeamCollectionName = 'teams';
export const TeamMemberCollectionName = 'team.members';
export const TeamTagsCollectionName = 'team.tags';
export enum TeamMemberRoleEnum {
owner = 'owner',

View File

@@ -15,7 +15,6 @@ export type UpdateTeamProps = {
teamId: string;
name?: string;
avatar?: string;
tagsUrl?: string;
};
/* ------------- member ----------- */

View File

@@ -9,23 +9,11 @@ export type TeamSchema = {
createTime: Date;
balance: number;
maxSize: number;
tagsUrl: string;
limit: {
lastExportDatasetTime: Date;
lastWebsiteSyncTime: Date;
};
};
export type tagsType = {
label: string,
key: string
}
export type TeamTagsSchema = {
_id: string;
label: string;
teamId: string;
key: string;
createTime: Date;
};
export type TeamMemberSchema = {
_id: string;
@@ -38,13 +26,13 @@ export type TeamMemberSchema = {
defaultTeam: boolean;
};
export type TeamMemberWithUserSchema = Omit<TeamMemberSchema, 'userId'> & {
export type TeamMemberWithUserSchema = TeamMemberSchema & {
userId: UserModelSchema;
};
export type TeamMemberWithTeamSchema = Omit<TeamMemberSchema, 'teamId'> & {
export type TeamMemberWithTeamSchema = TeamMemberSchema & {
teamId: TeamSchema;
};
export type TeamMemberWithTeamAndUserSchema = Omit<TeamMemberWithTeamSchema, 'userId'> & {
export type TeamMemberWithTeamAndUserSchema = TeamMemberWithTeamSchema & {
userId: UserModelSchema;
};

View File

@@ -29,5 +29,4 @@ export type UserType = {
promotionRate: UserModelSchema['promotionRate'];
openaiAccount: UserModelSchema['openaiAccount'];
team: TeamItemType;
standardInfo?: standardInfoType;
};

View File

@@ -1,18 +1,25 @@
import { BillTypeEnum } from './constants';
import { BillSourceEnum } from './constants';
import { BillListItemCountType, BillListItemType } from './type';
export type CreateTrainingBillProps = {
name: string;
datasetId: string;
};
export type ConcatBillProps = BillListItemCountType & {
teamId: string;
tmbId: string;
billId?: string;
total: number;
listIndex?: number;
};
export type CreateBillProps = {
type: `${BillTypeEnum}`;
// balance
balance?: number; // read
month?: number;
// extra dataset size
extraDatasetSize?: number; // 1k
extraPoints?: number; // 100w
};
export type CreateBillResponse = {
billId: string;
codeUrl: string;
readPrice: number;
teamId: string;
tmbId: string;
appName: string;
appId?: string;
total: number;
source: `${BillSourceEnum}`;
list: BillListItemType[];
};

View File

@@ -1,57 +1,34 @@
export enum BillTypeEnum {
balance = 'balance',
// model price: xxx/1k tokens
// ¥1 = 100000.
export const PRICE_SCALE = 100000;
export enum BillSourceEnum {
fastgpt = 'fastgpt',
api = 'api',
shareLink = 'shareLink',
training = 'training',
standSubPlan = 'standSubPlan',
extraDatasetSub = 'extraDatasetSub',
extraPoints = 'extraPoints'
extraDatasetSub = 'extraDatasetSub'
}
export const billTypeMap = {
[BillTypeEnum.balance]: {
label: 'support.wallet.subscription.type.balance'
export const BillSourceMap = {
[BillSourceEnum.fastgpt]: {
label: '在线使用'
},
[BillTypeEnum.standSubPlan]: {
[BillSourceEnum.api]: {
label: 'Api'
},
[BillSourceEnum.shareLink]: {
label: '免登录链接'
},
[BillSourceEnum.training]: {
label: 'dataset.Training Name'
},
[BillSourceEnum.standSubPlan]: {
label: 'support.wallet.subscription.type.standard'
},
[BillTypeEnum.extraDatasetSub]: {
[BillSourceEnum.extraDatasetSub]: {
label: 'support.wallet.subscription.type.extraDatasetSize'
},
[BillTypeEnum.extraPoints]: {
label: 'support.wallet.subscription.type.extraPoints'
}
};
export enum BillStatusEnum {
SUCCESS = 'SUCCESS',
REFUND = 'REFUND',
NOTPAY = 'NOTPAY',
CLOSED = 'CLOSED'
}
export const billStatusMap = {
[BillStatusEnum.SUCCESS]: {
label: 'support.wallet.bill.status.success'
},
[BillStatusEnum.REFUND]: {
label: 'support.wallet.bill.status.refund'
},
[BillStatusEnum.NOTPAY]: {
label: 'support.wallet.bill.status.notpay'
},
[BillStatusEnum.CLOSED]: {
label: 'support.wallet.bill.status.closed'
}
};
export enum BillPayWayEnum {
balance = 'balance',
wx = 'wx'
}
export const billPayWayMap = {
[BillPayWayEnum.balance]: {
label: 'support.wallet.bill.payWay.balance'
},
[BillPayWayEnum.wx]: {
label: 'support.wallet.bill.payWay.wx'
}
};
export const SUB_DATASET_SIZE_RATE = 1000;
export const SUB_EXTRA_POINT_RATE = 1000000;

View File

@@ -0,0 +1,26 @@
/* bill common */
import { PRICE_SCALE } from './constants';
import { BillSourceEnum } from './constants';
import { AuthUserTypeEnum } from '../../permission/constant';
/**
* dataset price / PRICE_SCALE = real price
*/
export const formatStorePrice2Read = (val = 0, multiple = 1) => {
return Number(((val / PRICE_SCALE) * multiple).toFixed(10));
};
export const formatModelPrice2Read = (val = 0) => {
return Number((val / 1000).toFixed(10));
};
export const getBillSourceByAuthType = ({
shareId,
authType
}: {
shareId?: string;
authType?: `${AuthUserTypeEnum}`;
}) => {
if (shareId) return BillSourceEnum.shareLink;
if (authType === AuthUserTypeEnum.apikey) return BillSourceEnum.api;
return BillSourceEnum.fastgpt;
};

View File

@@ -1,29 +1,35 @@
import { StandardSubLevelEnum, SubModeEnum, SubTypeEnum } from '../sub/constants';
import { BillPayWayEnum, BillTypeEnum } from './constants';
import { CreateBillProps } from './api';
import { BillSourceEnum } from './constants';
export type BillSchemaType = {
_id: string;
userId: string;
teamId: string;
tmbId: string;
createTime: Date;
orderId: string;
status: 'SUCCESS' | 'REFUND' | 'NOTPAY' | 'CLOSED';
type: `${BillTypeEnum}`;
price: number;
metadata: {
payWay: `${BillPayWayEnum}`;
subMode?: `${SubModeEnum}`;
standSubLevel?: `${StandardSubLevelEnum}`;
month?: number;
datasetSize?: number;
extraPoints?: number;
};
export type BillListItemCountType = {
inputTokens?: number;
outputTokens?: number;
charsLength?: number;
duration?: number;
// sub
datasetSize?: number;
// abandon
tokenLen?: number;
};
export type ChatModuleBillType = {
totalPoints: number;
export type BillListItemType = BillListItemCountType & {
moduleName: string;
model: string;
charsLength: number;
amount: number;
model?: string;
};
export type BillSchema = CreateBillProps & {
_id: string;
time: Date;
};
export type BillItemType = {
id: string;
// memberName: string;
time: Date;
appName: string;
source: BillSchema['source'];
total: number;
list: BillSchema['list'];
};

View File

@@ -1,3 +0,0 @@
// model price: xxx/1k tokens
// ¥1 = 100000.
export const PRICE_SCALE = 100000;

View File

@@ -0,0 +1,41 @@
export enum PayTypeEnum {
balance = 'balance',
subStandard = 'subStandard',
subExtraDatasetSize = 'subExtraDatasetSize',
subExtraPoints = 'subExtraPoints'
}
export const payTypeMap = {
[PayTypeEnum.balance]: {
label: 'support.user.team.pay.type.balance'
},
[PayTypeEnum.subStandard]: {
label: 'support.wallet.subscription.type.standard'
},
[PayTypeEnum.subExtraDatasetSize]: {
label: 'support.wallet.subscription.type.extraDatasetSize'
},
[PayTypeEnum.subExtraPoints]: {
label: 'support.wallet.subscription.type.extraPoints'
}
};
export enum PayStatusEnum {
SUCCESS = 'SUCCESS',
REFUND = 'REFUND',
NOTPAY = 'NOTPAY',
CLOSED = 'CLOSED'
}
export const payStatusMap = {
[PayStatusEnum.SUCCESS]: {
label: 'support.user.team.pay.status.success'
},
[PayStatusEnum.REFUND]: {
label: 'support.user.team.pay.status.refund'
},
[PayStatusEnum.NOTPAY]: {
label: 'support.user.team.pay.status.notpay'
},
[PayStatusEnum.CLOSED]: {
label: 'support.user.team.pay.status.closed'
}
};

View File

@@ -0,0 +1,18 @@
import { SubModeEnum, SubTypeEnum } from '../sub/constants';
import { PayTypeEnum } from './constants';
export type PaySchema = {
_id: string;
userId: string;
teamId: string;
tmbId: string;
createTime: Date;
orderId: string;
status: 'SUCCESS' | 'REFUND' | 'NOTPAY' | 'CLOSED';
type: `${PayType}`;
price: number;
payWay: 'balance' | 'wx';
subMetadata: {};
};

View File

@@ -1,14 +1,26 @@
import { StandardSubLevelEnum, SubModeEnum } from './constants';
import { TeamSubSchema } from './type.d';
export type SubDatasetSizeParams = {
size: number;
};
export type StandardSubPlanParams = {
level: `${StandardSubLevelEnum}`;
mode: `${SubModeEnum}`;
};
export type SubDatasetSizePreviewCheckResponse = {
payForNewSub: boolean; // Does this change require payment
newSubSize: number; // new sub dataset size
alreadySubSize: number; // old sub dataset size
payPrice: number; // this change require payment
newPlanPrice: number; // the new sub price
newSubStartTime: Date;
newSubExpiredTime: Date;
balanceEnough: boolean; // team balance is enough
};
export type StandardSubPlanUpdateResponse = {
balanceEnough: boolean; // team balance is enough
teamBalance: number;
payPrice?: number;
planPrice: number;
planPointPrice: number;

View File

@@ -1,3 +1,5 @@
export const POINTS_SCALE = 10000;
export enum SubTypeEnum {
standard = 'standard',
extraDatasetSize = 'extraDatasetSize',
@@ -17,16 +19,20 @@ export const subTypeMap = {
export enum SubStatusEnum {
active = 'active',
expired = 'expired'
canceled = 'canceled'
}
export const subStatusMap = {
[SubStatusEnum.active]: {
label: 'support.wallet.subscription.status.active'
},
[SubStatusEnum.expired]: {
[SubStatusEnum.canceled]: {
label: 'support.wallet.subscription.status.canceled'
}
};
export const subSelectMap = {
true: SubStatusEnum.active,
false: SubStatusEnum.canceled
};
export enum SubModeEnum {
month = 'month',
@@ -34,11 +40,11 @@ export enum SubModeEnum {
}
export const subModeMap = {
[SubModeEnum.month]: {
label: 'support.wallet.subscription.mode.Month',
label: 'support.wallet.subscription.mode.month',
durationMonth: 1
},
[SubModeEnum.year]: {
label: 'support.wallet.subscription.mode.Year',
label: 'support.wallet.subscription.mode.year',
durationMonth: 12
}
};
@@ -57,7 +63,7 @@ export const standardSubLevelMap = {
},
[StandardSubLevelEnum.experience]: {
label: 'support.wallet.subscription.standardSubLevel.experience',
desc: ''
desc: 'support.wallet.subscription.standardSubLevel.experience desc'
},
[StandardSubLevelEnum.team]: {
label: 'support.wallet.subscription.standardSubLevel.team',

View File

@@ -2,19 +2,19 @@ import { StandardSubLevelEnum, SubModeEnum, SubStatusEnum, SubTypeEnum } from '.
// Content of plan
export type TeamStandardSubPlanItemType = {
price: number; // read price / month
pointPrice: number; // read price/ one thousand
totalPoints: number; // n
price: number; // read price
pointPrice: number; // read price/ one ten thousand
maxTeamMember: number;
maxAppAmount: number; // max app or plugin amount
maxDatasetAmount: number;
chatHistoryStoreDuration: number; // n day
maxDatasetSize: number;
customApiKey: boolean;
customCopyright: boolean; // feature
websiteSyncInterval: number; // n hours
trainingWeight: number; // 1~4
permissionCustomApiKey: boolean;
permissionCustomCopyright: boolean; // feature
permissionWebsiteSync: boolean;
permissionReRank: boolean;
reRankWeight: number; // 1~4
totalPoints: number; // n ten thousand
};
export type StandSubPlanLevelMapType = Record<
@@ -27,9 +27,6 @@ export type SubPlanType = {
[SubTypeEnum.extraDatasetSize]: {
price: number;
};
[SubTypeEnum.extraPoints]: {
price: number;
};
};
export type TeamSubSchema = {
@@ -37,32 +34,40 @@ export type TeamSubSchema = {
teamId: string;
type: `${SubTypeEnum}`;
status: `${SubStatusEnum}`;
currentMode: `${SubModeEnum}`;
nextMode: `${SubModeEnum}`;
startTime: Date;
expiredTime: Date;
price: number;
currentMode: `${SubModeEnum}`;
nextMode: `${SubModeEnum}`;
currentSubLevel: `${StandardSubLevelEnum}`;
nextSubLevel: `${StandardSubLevelEnum}`;
pointPrice: number;
totalPoints: number;
surplusPoints: number;
currentExtraDatasetSize: number;
nextExtraDatasetSize: number;
currentExtraPoints: number;
nextExtraPoints: number;
surplusPoints: number;
// abandon
datasetStoreAmount?: number;
renew?: boolean;
};
export type FeTeamPlanStatusType = {
export type FeTeamSubType = {
[SubTypeEnum.standard]?: TeamSubSchema;
standardConstants?: TeamStandardSubPlanItemType;
[SubTypeEnum.extraDatasetSize]?: TeamSubSchema;
[SubTypeEnum.extraPoints]?: TeamSubSchema;
standardMaxDatasetSize: number;
totalPoints: number;
usedPoints: number;
standardMaxDatasetSize?: number;
standardMaxPoints?: number;
// standard + extra
standardMaxPoints: number;
datasetMaxSize: number;
usedDatasetSize: number;
};

View File

@@ -1,26 +0,0 @@
import { UsageSourceEnum } from './constants';
import { UsageListItemCountType, UsageListItemType } from './type';
export type CreateTrainingUsageProps = {
name: string;
datasetId: string;
};
export type ConcatUsageProps = UsageListItemCountType & {
teamId: string;
tmbId: string;
billId?: string;
totalPoints: number;
listIndex?: number;
};
export type CreateUsageProps = {
teamId: string;
tmbId: string;
appName: string;
appId?: string;
totalPoints: number;
// inputTokens: number;
source: `${UsageSourceEnum}`;
list: UsageListItemType[];
};

View File

@@ -1,21 +0,0 @@
export enum UsageSourceEnum {
fastgpt = 'fastgpt',
api = 'api',
shareLink = 'shareLink',
training = 'training'
}
export const UsageSourceMap = {
[UsageSourceEnum.fastgpt]: {
label: '在线使用'
},
[UsageSourceEnum.api]: {
label: 'Api'
},
[UsageSourceEnum.shareLink]: {
label: '免登录链接'
},
[UsageSourceEnum.training]: {
label: 'dataset.Training Name'
}
};

View File

@@ -1,23 +0,0 @@
/* bill common */
import { PRICE_SCALE } from '../constants';
import { UsageSourceEnum } from './constants';
import { AuthUserTypeEnum } from '../../permission/constant';
/**
* dataset price / PRICE_SCALE = real price
*/
export const formatStorePrice2Read = (val = 0, multiple = 1) => {
return Number(((val / PRICE_SCALE) * multiple).toFixed(10));
};
export const getUsageSourceByAuthType = ({
shareId,
authType
}: {
shareId?: string;
authType?: `${AuthUserTypeEnum}`;
}) => {
if (shareId) return UsageSourceEnum.shareLink;
if (authType === AuthUserTypeEnum.apikey) return UsageSourceEnum.api;
return UsageSourceEnum.fastgpt;
};

View File

@@ -1,26 +0,0 @@
import { CreateUsageProps } from './api';
import { UsageSourceEnum } from './constants';
export type UsageListItemCountType = {
charsLength?: number;
duration?: number;
};
export type UsageListItemType = UsageListItemCountType & {
moduleName: string;
amount: number;
model?: string;
};
export type UsageSchemaType = CreateUsageProps & {
_id: string;
time: Date;
};
export type UsageItemType = {
id: string;
time: Date;
appName: string;
source: UsageSchemaType['source'];
totalPoints: number;
list: UsageSchemaType['list'];
};