mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-21 11:43:56 +00:00

* split tokens into input and output (#3477) * split tokens into input and output * query extension & tool call & question guide * fix * perf: input and output tokens * perf: tool call if else * perf: remove code * fix: extract usage count * fix: qa usage count --------- Co-authored-by: heheer <heheer@sealos.io>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { FastGPTConfigFileType } from '@fastgpt/global/common/system/types';
|
|
import { isIPv6 } from 'net';
|
|
|
|
export const SERVICE_LOCAL_PORT = `${process.env.PORT || 3000}`;
|
|
export const SERVICE_LOCAL_HOST =
|
|
process.env.HOSTNAME && isIPv6(process.env.HOSTNAME)
|
|
? `[${process.env.HOSTNAME}]:${SERVICE_LOCAL_PORT}`
|
|
: `${process.env.HOSTNAME || 'localhost'}:${SERVICE_LOCAL_PORT}`;
|
|
|
|
export const initFastGPTConfig = (config?: FastGPTConfigFileType) => {
|
|
if (!config) return;
|
|
|
|
global.feConfigs = config.feConfigs;
|
|
global.systemEnv = config.systemEnv;
|
|
global.subPlans = config.subPlans;
|
|
|
|
global.llmModels = config.llmModels;
|
|
global.llmModelPriceType = global.llmModels.some((item) => typeof item.inputPrice === 'number')
|
|
? 'IO'
|
|
: 'Tokens';
|
|
global.vectorModels = config.vectorModels;
|
|
global.audioSpeechModels = config.audioSpeechModels;
|
|
global.whisperModel = config.whisperModel;
|
|
global.reRankModels = config.reRankModels;
|
|
};
|
|
|
|
export const systemStartCb = () => {
|
|
process.on('uncaughtException', (err) => {
|
|
console.error('Uncaught Exception:', err);
|
|
// process.exit(1); // 退出进程
|
|
});
|
|
|
|
process.on('unhandledRejection', (reason, promise) => {
|
|
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
// process.exit(1); // 退出进程
|
|
});
|
|
};
|
|
|
|
export const surrenderProcess = () => new Promise((resolve) => setImmediate(resolve));
|