fix: price page init data;perf: usage code;fix: reasoning tokens;fix: workflow basic node cannot upgrade (#3816)
* fix: img read * fix: price page init data * perf: ai model avatar * perf: refresh in change team * perf: null checker * perf: usage code * fix: reasoning tokens * fix: workflow basic node cannot upgrade * perf: model refresh * perf: icon refresh
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { getUserChatInfoAndAuthTeamPoints } from '@fastgpt/service/support/permission/auth/team';
|
||||
import { pushChatUsage } from '@/service/support/wallet/usage/push';
|
||||
import { createChatUsage } from '@fastgpt/service/support/wallet/usage/controller';
|
||||
import { getNextTimeByCronStringAndTimezone } from '@fastgpt/global/common/string/time';
|
||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
import { delay, retryFn } from '@fastgpt/global/common/system/utils';
|
||||
@@ -113,7 +113,7 @@ export const getScheduleTriggerApp = async () => {
|
||||
}
|
||||
]
|
||||
});
|
||||
pushChatUsage({
|
||||
createChatUsage({
|
||||
appName: app.name,
|
||||
appId: app._id,
|
||||
teamId: String(app.teamId),
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { ConcatUsageProps, CreateUsageProps } from '@fastgpt/global/support/wallet/usage/api';
|
||||
import { addLog } from '@fastgpt/service/common/system/log';
|
||||
import { POST } from '@fastgpt/service/common/api/plusRequest';
|
||||
import { FastGPTProUrl } from '@fastgpt/service/common/system/constants';
|
||||
|
||||
export async function createUsage(data: CreateUsageProps) {
|
||||
if (!FastGPTProUrl) return;
|
||||
if (data.totalPoints === 0) {
|
||||
addLog.info('0 totalPoints', data);
|
||||
}
|
||||
try {
|
||||
await POST('/support/wallet/usage/createUsage', data);
|
||||
} catch (error) {
|
||||
addLog.error('createUsage error', error);
|
||||
}
|
||||
}
|
||||
export async function concatUsage(data: ConcatUsageProps) {
|
||||
if (!FastGPTProUrl) return;
|
||||
if (data.totalPoints === 0) {
|
||||
addLog.info('0 totalPoints', data);
|
||||
}
|
||||
try {
|
||||
await POST('/support/wallet/usage/concatUsage', data);
|
||||
} catch (error) {
|
||||
addLog.error('concatUsage error', error);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +1,10 @@
|
||||
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
|
||||
import { addLog } from '@fastgpt/service/common/system/log';
|
||||
import { createUsage, concatUsage } from './controller';
|
||||
import { createUsage, concatUsage } from '@fastgpt/service/support/wallet/usage/controller';
|
||||
import { formatModelChars2Points } from '@fastgpt/service/support/wallet/usage/utils';
|
||||
import { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
|
||||
import { i18nT } from '@fastgpt/web/i18n/utils';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
import { getDefaultTTSModel } from '@fastgpt/service/core/ai/model';
|
||||
|
||||
export const pushChatUsage = ({
|
||||
appName,
|
||||
appId,
|
||||
pluginId,
|
||||
teamId,
|
||||
tmbId,
|
||||
source,
|
||||
flowUsages
|
||||
}: {
|
||||
appName: string;
|
||||
appId?: string;
|
||||
pluginId?: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
source: UsageSourceEnum;
|
||||
flowUsages: ChatNodeUsageType[];
|
||||
}) => {
|
||||
const totalPoints = flowUsages.reduce((sum, item) => sum + (item.totalPoints || 0), 0);
|
||||
|
||||
createUsage({
|
||||
teamId,
|
||||
tmbId,
|
||||
appName,
|
||||
appId,
|
||||
pluginId,
|
||||
totalPoints,
|
||||
source,
|
||||
list: flowUsages.map((item) => ({
|
||||
moduleName: item.moduleName,
|
||||
amount: item.totalPoints || 0,
|
||||
model: item.model,
|
||||
inputTokens: item.inputTokens,
|
||||
outputTokens: item.outputTokens
|
||||
}))
|
||||
});
|
||||
addLog.info(`finish completions`, {
|
||||
source,
|
||||
teamId,
|
||||
totalPoints
|
||||
});
|
||||
return { totalPoints };
|
||||
};
|
||||
|
||||
export const pushQAUsage = async ({
|
||||
teamId,
|
||||
tmbId,
|
||||
|
||||
Reference in New Issue
Block a user