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

@@ -34,7 +34,7 @@ export const streamFetch = ({
// response data
let responseText = '';
let remainTextList: string[] = [];
let remainText = '';
let errMsg = '';
let responseData: ChatHistoryItemResType[] = [];
let finished = false;
@@ -60,23 +60,22 @@ export const streamFetch = ({
function animateResponseText() {
// abort message
if (abortCtrl.signal.aborted) {
const remainText = remainTextList.join('');
onMessage({ text: remainText });
responseText += remainText;
return finish();
}
if (remainTextList.length > 0) {
const fetchCount = Math.max(1, Math.round(remainTextList.length / 60));
const fetchText = remainTextList.slice(0, fetchCount).join('');
if (remainText) {
const fetchCount = Math.max(1, Math.round(remainText.length / 60));
const fetchText = remainText.slice(0, fetchCount);
onMessage({ text: fetchText });
responseText += fetchText;
remainTextList = remainTextList.slice(fetchCount);
remainText = remainText.slice(fetchCount);
}
if (finished && remainTextList.length === 0) {
if (finished && !remainText) {
return finish();
}
@@ -126,10 +125,7 @@ export const streamFetch = ({
try {
failedFinish(await res.clone().json());
} catch {
const errText = await res.clone().text();
if (!errText.startsWith('event: error')) {
failedFinish();
}
failedFinish(await res.clone().text());
}
}
},
@@ -149,13 +145,11 @@ export const streamFetch = ({
if (event === sseResponseEventEnum.answer) {
const text: string = parseJson?.choices?.[0]?.delta?.content || '';
for (const item of text) {
remainTextList.push(item);
}
remainText += text;
} else if (event === sseResponseEventEnum.response) {
const text: string = parseJson?.choices?.[0]?.delta?.content || '';
remainTextList.push(text);
onMessage({ text });
responseText += text;
} else if (
event === sseResponseEventEnum.moduleStatus &&
parseJson?.name &&

View File

@@ -15,7 +15,6 @@ export const getMyApps = () => GET<AppListItemType[]>('/core/app/list');
*/
export const postCreateApp = (data: CreateAppParams) => POST<string>('/core/app/create', data);
export const getMyAppsByTags = (data: {}) => POST(`/proApi/core/chat/team/getApps`, data);
/**
* 根据 ID 删除模型
*/
@@ -31,12 +30,7 @@ export const getModelById = (id: string) => GET<AppDetailType>(`/core/app/detail
*/
export const putAppById = (id: string, data: AppUpdateParams) =>
PUT(`/core/app/update?appId=${id}`, data);
export const replaceAppById = (id: string, data: AppUpdateParams) =>
PUT(`/core/app/updateTeamTasg?appId=${id}`, data);
// updateTeamTasg
export const putAppTagsById = (id: string, data: AppUpdateParams) =>
PUT(`/core/app/updateTeamTasg?appId=${id}`, data);
/* 共享市场 */
/**
* 获取共享市场模型

View File

@@ -1,7 +1,7 @@
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import { getMyApps, getModelById, putAppById, replaceAppById } from '@/web/core/app/api';
import { getMyApps, getModelById, putAppById } from '@/web/core/app/api';
import { defaultApp } from '@/constants/app';
import type { AppUpdateParams } from '@fastgpt/global/core/app/api.d';
import { AppDetailType, AppListItemType } from '@fastgpt/global/core/app/type.d';
@@ -12,7 +12,6 @@ type State = {
appDetail: AppDetailType;
loadAppDetail: (id: string, init?: boolean) => Promise<AppDetailType>;
updateAppDetail(appId: string, data: AppUpdateParams): Promise<void>;
replaceAppDetail(appId: string, data: AppUpdateParams): Promise<void>;
clearAppModules(): void;
};
@@ -48,15 +47,6 @@ export const useAppStore = create<State>()(
};
});
},
async replaceAppDetail(appId: string, data: AppUpdateParams) {
await replaceAppById(appId, { ...get().appDetail, ...data });
set((state) => {
state.appDetail = {
...state.appDetail,
...data
};
});
},
clearAppModules() {
set((state) => {
state.appDetail = {

View File

@@ -121,7 +121,7 @@ export const appTemplates: (AppItemType & {
},
{
key: 'model',
type: 'selectLLMModel',
type: 'selectChatModel',
label: 'core.module.input.label.aiModel',
required: true,
valueType: 'string',
@@ -569,7 +569,7 @@ export const appTemplates: (AppItemType & {
},
{
key: 'model',
type: 'selectLLMModel',
type: 'selectChatModel',
label: 'core.module.input.label.aiModel',
required: true,
valueType: 'string',
@@ -882,7 +882,7 @@ export const appTemplates: (AppItemType & {
},
{
key: 'model',
type: 'selectLLMModel',
type: 'selectChatModel',
label: 'core.module.input.label.aiModel',
required: true,
valueType: 'string',
@@ -1115,7 +1115,7 @@ export const appTemplates: (AppItemType & {
},
{
key: 'model',
type: 'selectLLMModel',
type: 'selectCQModel',
valueType: 'string',
label: 'core.module.input.label.Classify model',
required: true,
@@ -1345,7 +1345,7 @@ export const appTemplates: (AppItemType & {
},
{
key: 'model',
type: 'selectLLMModel',
type: 'selectChatModel',
label: 'core.module.input.label.aiModel',
required: true,
valueType: 'string',

View File

@@ -1,6 +1,5 @@
import { GET, POST, DELETE, PUT } from '@/web/common/api/request';
import type { ChatHistoryItemType, chatAppListSchema } from '@fastgpt/global/core/chat/type.d';
import type { ChatHistoryItemType } from '@fastgpt/global/core/chat/type.d';
import type {
CloseCustomFeedbackParams,
InitChatProps,
@@ -17,31 +16,13 @@ import type {
} from '@/global/core/chat/api.d';
import { UpdateChatFeedbackProps } from '@fastgpt/global/core/chat/api';
/**
* 根据队伍ID和获取
*/
export const getChatListById = (data: { teamId: string; authToken: string }) =>
GET<chatAppListSchema>(`/proApi/core/chat/init`, data);
/**
* 获取团队分享的对话列表 initTeamChat
* @param data
* @returns
*/
export const getinitTeamChat = (data: { teamId: string; authToken: string; appId: string }) =>
GET(`/proApi/core/chat/initTeamChat`, data);
/**
* 获取初始化聊天内容
*/
export const getInitChatInfo = (data: InitChatProps) =>
GET<InitChatResponse>(`/core/chat/init`, data);
export const getInitChatInfoTeam = (data: InitChatProps) =>
GET<InitChatResponse>(`/core/chat/init`, data);
export const getInitOutLinkChatInfo = (data: InitOutLinkChatProps) =>
GET<InitChatResponse>(`/core/chat/outLink/init`, data);
export const getTeamChatInfo = (data: { appId: string; chatId: string; outLinkUid?: string }) =>
GET<InitChatResponse>(`/core/chat/team/init`, data);
/**
* get current window history(appid or shareId)

View File

@@ -1,42 +0,0 @@
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import type { ChatHistoryItemType } from '@fastgpt/global/core/chat/type.d';
import { customAlphabet } from 'nanoid';
const nanoid = customAlphabet(
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWSYZ1234567890_',
24
);
type State = {
localUId: string;
teamShareChatHistory: (ChatHistoryItemType & { delete?: boolean })[];
clearLocalHistory: (shareId?: string) => void;
};
export const useTeamShareChatStore = create<State>()(
devtools(
persist(
immer((set, get) => ({
localUId: `shareChat-${Date.now()}-${nanoid()}`,
teamShareChatHistory: [], // old version field
clearLocalHistory() {
// abandon
set((state) => {
state.teamShareChatHistory = state.teamShareChatHistory.map((item) => ({
...item,
delete: true
}));
});
}
})),
{
name: 'shareChatStore',
partialize: (state) => ({
localUId: state.localUId,
shareChatHistory: state.teamShareChatHistory
})
}
)
)
);

View File

@@ -12,7 +12,7 @@ import {
import { defaultDatasetDetail } from '@/constants/dataset';
import type { DatasetUpdateBody } from '@fastgpt/global/core/dataset/api.d';
import { DatasetStatusEnum } from '@fastgpt/global/core/dataset/constants';
import { postCreateTrainingUsage } from '@/web/support/wallet/usage/api';
import { postCreateTrainingBill } from '@/web/support/wallet/bill/api';
import { checkTeamWebSyncLimit } from '@/web/support/user/team/api';
type State = {
@@ -89,17 +89,19 @@ export const useDatasetStore = create<State>()(
async startWebsiteSync() {
await checkTeamWebSyncLimit();
const billId = await postCreateTrainingUsage({
name: 'core.dataset.training.Website Sync',
datasetId: get().datasetDetail._id
});
return postWebsiteSync({ datasetId: get().datasetDetail._id, billId }).then(() => {
const [_, billId] = await Promise.all([
get().updateDataset({
id: get().datasetDetail._id,
status: DatasetStatusEnum.syncing
});
});
}),
postCreateTrainingBill({
name: 'core.dataset.training.Website Sync',
datasetId: get().datasetDetail._id
})
]);
try {
postWebsiteSync({ datasetId: get().datasetDetail._id, billId });
} catch (error) {}
}
})),
{

View File

@@ -68,6 +68,12 @@ export async function chunksUpload({
});
}
// add chunk index
chunks = chunks.map((chunk) => ({
...chunk,
chunkIndex: chunk.chunkIndex
}));
let successInsert = 0;
let retryTimes = 10;
for (let i = 0; i < chunks.length; i += rate) {

View File

@@ -13,7 +13,7 @@ import { RunAppModule } from '@fastgpt/global/core/module/template/system/runApp
import { PluginInputModule } from '@fastgpt/global/core/module/template/system/pluginInput';
import { PluginOutputModule } from '@fastgpt/global/core/module/template/system/pluginOutput';
import { RunPluginModule } from '@fastgpt/global/core/module/template/system/runPlugin';
import { AiQueryExtension } from '@fastgpt/global/core/module/template/system/queryExtension';
import { AiCFR } from '@fastgpt/global/core/module/template/system/coreferenceResolution';
import type {
FlowModuleTemplateType,
@@ -31,8 +31,7 @@ export const appSystemModuleTemplates: FlowModuleTemplateType[] = [
RunAppModule,
ClassifyQuestionModule,
ContextExtractModule,
HttpModule468,
AiQueryExtension
HttpModule468
];
export const pluginSystemModuleTemplates: FlowModuleTemplateType[] = [
PluginInputModule,
@@ -44,8 +43,7 @@ export const pluginSystemModuleTemplates: FlowModuleTemplateType[] = [
RunAppModule,
ClassifyQuestionModule,
ContextExtractModule,
HttpModule468,
AiQueryExtension
HttpModule468
];
export const moduleTemplatesFlat: FlowModuleTemplateType[] = [
@@ -63,7 +61,7 @@ export const moduleTemplatesFlat: FlowModuleTemplateType[] = [
PluginInputModule,
PluginOutputModule,
RunPluginModule,
AiQueryExtension
AiCFR
];
export const moduleTemplatesList: moduleTemplateListType = [

View File

@@ -217,7 +217,7 @@ const Button = defineStyleConfig({
const Input: ComponentStyleConfig = {
baseStyle: {
fontsize: '1rem'
fontsize: '14px'
},
sizes: {
sm: defineStyle({
@@ -368,11 +368,12 @@ export const theme = extendTheme({
styles: {
global: {
'html, body': {
fontSize: '14px',
color: 'myGray.900',
fontSize: 'md',
fontWeight: 400,
height: '100%',
overflow: 'hidden'
// lineHeight: 'unset'
},
a: {
color: 'primary.600'
@@ -471,16 +472,16 @@ export const theme = extendTheme({
body: 'PingFang,Noto Sans,-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"'
},
fontSizes: {
xs: '0.8rem',
sm: '0.93rem',
md: '1rem',
lg: '1.15rem',
xl: '1.3rem',
'2xl': '1.45rem',
'3xl': '1.6rem',
'4xl': '1.75rem',
'5xl': '1.9rem',
'6xl': '2.05rem'
xs: '12px',
sm: '13px',
md: '14px',
lg: '16px',
xl: '18px',
'2xl': '20px',
'3xl': '24px',
'4xl': '28px',
'5xl': '32px',
'6xl': '36px'
},
borders: {
sm: '1px solid #E8EBF0',

View File

@@ -8,7 +8,6 @@ import {
UpdateTeamMemberProps,
UpdateTeamProps
} from '@fastgpt/global/support/user/team/controller.d';
import type { TeamTagsSchema } from '@fastgpt/global/support/user/team/type';
import {
TeamItemType,
TeamMemberItemType,
@@ -24,14 +23,6 @@ export const putUpdateTeam = (data: UpdateTeamProps) =>
PUT(`/proApi/support/user/team/update`, data);
export const putSwitchTeam = (teamId: string) =>
PUT<string>(`/proApi/support/user/team/switch`, { teamId });
export const updateTags = (teamId: string, tagsUrl: string) =>
POST<TeamTagsSchema[]>(`/proApi/support/user/team/tags/asyncTags`, { teamId, tagsUrl });
export const getTeamsTags = (teamId: string) =>
GET(`/proApi/support/user/team/tags/list`, { teamId });
export const putUpdateTeamTags = (data: any) =>
PUT(`/proApi/support/user/team/tags/updateUrl`, data);
export const insertTeamsTags = (tags: Array<any>) =>
POST(`/proApi/support/user/team/tags/create`, tags);
/* --------------- team member ---------------- */
export const getTeamMembers = (teamId: string) =>

View File

@@ -3,17 +3,14 @@ import { devtools, persist } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import type { UserUpdateParams } from '@/types/user';
import type { UserType } from '@fastgpt/global/support/user/type.d';
import { formatStorePrice2Read } from '@fastgpt/global/support/wallet/bill/tools';
import { getTokenLogin, putUserInfo } from '@/web/support/user/api';
import { FeTeamPlanStatusType } from '@fastgpt/global/support/wallet/sub/type';
import { getTeamPlanStatus } from '@/web/support/wallet/sub/api';
type State = {
userInfo: UserType | null;
initUserInfo: () => Promise<UserType>;
setUserInfo: (user: UserType | null) => void;
updateUserInfo: (user: UserUpdateParams) => Promise<void>;
teamPlanStatus: FeTeamPlanStatusType | null;
initTeamPlanStatus: () => Promise<any>;
};
export const useUserStore = create<State>()(
@@ -22,22 +19,19 @@ export const useUserStore = create<State>()(
immer((set, get) => ({
userInfo: null,
async initUserInfo() {
get().initTeamPlanStatus();
const res = await getTokenLogin();
get().setUserInfo(res);
//设置html的fontsize
const html = document?.querySelector('html');
if (html) {
// html.style.fontSize = '16px';
}
return res;
},
setUserInfo(user: UserType | null) {
set((state) => {
state.userInfo = user ? user : null;
state.userInfo = user
? {
...user,
balance: formatStorePrice2Read(user.balance)
}
: null;
});
},
async updateUserInfo(user: UserUpdateParams) {
@@ -57,15 +51,6 @@ export const useUserStore = create<State>()(
});
return Promise.reject(error);
}
},
teamPlanStatus: null,
initTeamPlanStatus() {
return getTeamPlanStatus().then((res) => {
set((state) => {
state.teamPlanStatus = res;
});
return res;
});
}
})),
{

View File

@@ -1,22 +1,10 @@
import { RequestPaging } from '@/types';
import { GET, POST } from '@/web/common/api/request';
import { CreateBillProps, CreateBillResponse } from '@fastgpt/global/support/wallet/bill/api';
import { BillTypeEnum } from '@fastgpt/global/support/wallet/bill/constants';
import type { BillSchemaType } from '@fastgpt/global/support/wallet/bill/type.d';
import { CreateTrainingBillProps } from '@fastgpt/global/support/wallet/bill/api.d';
import type { PagingData, RequestPaging } from '@/types';
import type { BillItemType } from '@fastgpt/global/support/wallet/bill/type';
export const getBills = (
data: RequestPaging & {
type?: `${BillTypeEnum}`;
}
) => POST<BillSchemaType[]>(`/proApi/support/wallet/bill/list`, data);
export const getUserBills = (data: RequestPaging) =>
POST<PagingData<BillItemType>>(`/proApi/support/wallet/bill/getBill`, data);
export const getWxPayQRCode = (data: CreateBillProps) =>
POST<CreateBillResponse>(`/proApi/support/wallet/bill/create`, data);
export const checkBalancePayResult = (payId: string) =>
GET<string>(`/proApi/support/wallet/bill/checkPayResult`, { payId }).then((data) => {
try {
GET('/common/system/unlockTask');
} catch (error) {}
return data;
});
export const postCreateTrainingBill = (data: CreateTrainingBillProps) =>
POST<string>(`/support/wallet/bill/createTrainingBill`, data);

View File

@@ -0,0 +1,17 @@
import { GET } from '@/web/common/api/request';
import type { PaySchema } from '@fastgpt/global/support/wallet/pay/type.d';
export const getPayOrders = () => GET<PaySchema[]>(`/proApi/support/wallet/pay/getPayOrders`);
export const getPayCode = (amount: number) =>
GET<{
codeUrl: string;
payId: string;
}>(`/proApi/support/wallet/pay/getPayCode`, { amount });
export const checkPayResult = (payId: string) =>
GET<string>(`/proApi/support/wallet/pay/checkPayResult`, { payId }).then((data) => {
try {
GET('/common/system/unlockTask');
} catch (error) {}
return data;
});

View File

@@ -1,20 +1,30 @@
import { GET, POST, PUT, DELETE } from '@/web/common/api/request';
import {
StandardSubPlanParams,
StandardSubPlanUpdateResponse
StandardSubPlanUpdateResponse,
SubDatasetSizeParams,
SubDatasetSizePreviewCheckResponse
} from '@fastgpt/global/support/wallet/sub/api';
import { SubStatusEnum, SubTypeEnum } from '@fastgpt/global/support/wallet/sub/constants';
import { FeTeamPlanStatusType } from '@fastgpt/global/support/wallet/sub/type';
import { FeTeamSubType } from '@fastgpt/global/support/wallet/sub/type';
export const putTeamDatasetSubStatus = (data: {
status: `${SubStatusEnum}`;
type: `${SubTypeEnum}`;
}) => POST('/proApi/support/wallet/sub/updateStatus', data);
export const getTeamPlanStatus = () =>
GET<FeTeamPlanStatusType>(`/support/wallet/sub/getTeamSubStatus`);
export const getTeamDatasetValidSub = () =>
GET<FeTeamSubType>(`/support/wallet/sub/getTeamSubStatus`);
export const postCheckStandardSub = (data: StandardSubPlanParams) =>
POST<StandardSubPlanUpdateResponse>('/proApi/support/wallet/sub/standard/preCheck', data);
export const postUpdateStandardSub = (data: StandardSubPlanParams) =>
POST<StandardSubPlanUpdateResponse>('/proApi/support/wallet/sub/standard/update', data);
export const posCheckTeamDatasetSizeSub = (data: SubDatasetSizeParams) =>
POST<SubDatasetSizePreviewCheckResponse>(
'/proApi/support/wallet/sub/extraDatasetSize/preCheck',
data
);
export const postUpdateTeamDatasetSizeSub = (data: SubDatasetSizeParams) =>
POST('/proApi/support/wallet/sub/extraDatasetSize/update', data);

View File

@@ -1,2 +0,0 @@
export const AI_POINT_USAGE_CARD_ROUTE = '/price#point-card';
export const EXTRA_PLAN_CARD_ROUTE = '/price#extra-plan';

View File

@@ -1,10 +0,0 @@
import { GET, POST } from '@/web/common/api/request';
import { CreateTrainingUsageProps } from '@fastgpt/global/support/wallet/usage/api.d';
import type { PagingData, RequestPaging } from '@/types';
import type { UsageItemType } from '@fastgpt/global/support/wallet/usage/type';
export const getUserUsages = (data: RequestPaging) =>
POST<PagingData<UsageItemType>>(`/proApi/support/wallet/usage/getUsage`, data);
export const postCreateTrainingUsage = (data: CreateTrainingUsageProps) =>
POST<string>(`/support/wallet/usage/createTrainingUsage`, data);