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

@@ -1,5 +1,6 @@
import React, { useContext, useCallback, createContext, useState, useMemo, useEffect } from 'react';
import { formatModelPrice2Read } from '@fastgpt/global/support/wallet/bill/tools';
import { splitText2Chunks } from '@fastgpt/global/common/string/textSplitter';
import { TrainingModeEnum } from '@fastgpt/global/core/dataset/constants';
import { useTranslation } from 'next-i18next';
@@ -33,7 +34,7 @@ type useImportStoreType = {
totalChunkChars: number;
totalChunks: number;
chunkSize: number;
predictPoints: number;
predictPrice: number;
priceTip: string;
uploadRate: number;
splitSources2Chunks: () => void;
@@ -53,7 +54,7 @@ const StateContext = createContext<useImportStoreType>({
totalChunkChars: 0,
totalChunks: 0,
chunkSize: 0,
predictPoints: 0,
predictPrice: 0,
priceTip: '',
uploadRate: 50,
splitSources2Chunks: () => {}
@@ -104,9 +105,10 @@ const Provider = ({
chunkSize: embeddingChunkSize,
showChunkInput: true,
showPromptInput: false,
charsPointsPrice: vectorModel.charsPointsPrice,
inputPrice: vectorModel.inputPrice,
outputPrice: 0,
priceTip: t('core.dataset.import.Embedding Estimated Price Tips', {
price: vectorModel.charsPointsPrice
price: vectorModel.inputPrice
}),
uploadRate: 150
},
@@ -118,9 +120,10 @@ const Provider = ({
chunkSize: agentModel.maxContext * 0.55 || 6000,
showChunkInput: false,
showPromptInput: true,
charsPointsPrice: agentModel.charsPointsPrice,
inputPrice: agentModel.inputPrice,
outputPrice: agentModel.outputPrice,
priceTip: t('core.dataset.import.QA Estimated Price Tips', {
price: agentModel?.charsPointsPrice
price: agentModel?.inputPrice
}),
uploadRate: 30
}
@@ -148,12 +151,15 @@ const Provider = ({
() => sources.reduce((sum, file) => sum + file.chunkChars, 0),
[sources]
);
const predictPoints = useMemo(() => {
const predictPrice = useMemo(() => {
if (mode === TrainingModeEnum.qa) {
return +(((totalChunkChars * 1.5) / 1000) * agentModel.charsPointsPrice).toFixed(2);
const inputTotal = totalChunkChars * selectModelStaticParam.inputPrice;
const outputTotal = totalChunkChars * 0.5 * selectModelStaticParam.inputPrice;
return formatModelPrice2Read(inputTotal + outputTotal);
}
return +((totalChunkChars / 1000) * vectorModel.charsPointsPrice).toFixed(2);
}, [agentModel.charsPointsPrice, mode, totalChunkChars, vectorModel.charsPointsPrice]);
return formatModelPrice2Read(totalChunkChars * selectModelStaticParam.inputPrice);
}, [mode, selectModelStaticParam.inputPrice, totalChunkChars]);
const totalChunks = useMemo(
() => sources.reduce((sum, file) => sum + file.chunks.length, 0),
[sources]
@@ -172,8 +178,7 @@ const Provider = ({
return {
...file,
chunkChars: chars,
chunks: chunks.map((chunk, i) => ({
chunkIndex: i,
chunks: chunks.map((chunk) => ({
q: chunk,
a: ''
}))
@@ -193,7 +198,7 @@ const Provider = ({
totalChunkChars,
totalChunks,
chunkSize,
predictPoints,
predictPrice,
splitSources2Chunks
};
return <StateContext.Provider value={value}>{children}</StateContext.Provider>;

View File

@@ -46,7 +46,7 @@ function DataProcess({
maxChunkSize,
totalChunkChars,
totalChunks,
predictPoints,
predictPrice,
showRePreview,
splitSources2Chunks,
priceTip
@@ -275,7 +275,7 @@ function DataProcess({
{feConfigs?.show_pay && (
<MyTooltip label={priceTip}>
<Tag colorSchema={'gray'} py={'6px'} borderRadius={'md'} px={3}>
{t('core.dataset.import.Estimated points', { points: predictPoints })}
{t('core.dataset.import.Estimated Price', { amount: predictPrice, unit: '元' })}
</Tag>
</MyTooltip>
)}

View File

@@ -16,7 +16,7 @@ import { useImportStore, type FormType } from '../Provider';
import { useTranslation } from 'next-i18next';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useRequest } from '@/web/common/hooks/useRequest';
import { postCreateTrainingUsage } from '@/web/support/wallet/usage/api';
import { postCreateTrainingBill } from '@/web/support/wallet/bill/api';
import { useDatasetStore } from '@/web/core/dataset/store/dataset';
import { chunksUpload, fileCollectionCreate } from '@/web/core/dataset/utils';
import { ImportSourceItemType } from '@/web/core/dataset/type';
@@ -54,7 +54,7 @@ const Upload = ({ showPreviewChunks }: { showPreviewChunks: boolean }) => {
// Batch create collection and upload chunks
for await (const item of uploadList) {
const billId = await postCreateTrainingUsage({
const billId = await postCreateTrainingBill({
name: item.sourceName,
datasetId: datasetDetail._id
});