Skip to content

Commit

Permalink
reload buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Jan 25, 2025
1 parent d2948d7 commit c3192ef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/service/common/system/config/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ export const updateFastGPTConfigBuffer = async () => {

global.systemInitBufferId = res.createTime.getTime().toString();
};

export const reloadFastGPTConfigBuffer = async () => {
const res = await MongoSystemConfigs.findOne({
type: SystemConfigsTypeEnum.fastgpt
}).sort({
createTime: -1
});
if (!res) return;
global.systemInitBufferId = res.createTime.getTime().toString();
};
4 changes: 4 additions & 0 deletions packages/service/core/ai/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { debounce } from 'lodash';
import { ModelProviderType } from '@fastgpt/global/core/ai/provider';
import { findModelFromAlldata } from '../model';
import { reloadFastGPTConfigBuffer } from '../../../common/system/config/controller';

/*
TODO: 分优先级读取:
Expand Down Expand Up @@ -170,7 +171,10 @@ export const watchSystemModelUpdate = () => {
'change',
debounce(async () => {
try {
// Main node will reload twice
await loadSystemModels(true);
// All node reaload buffer
await reloadFastGPTConfigBuffer();
} catch (error) {}
}, 500)
);
Expand Down
1 change: 0 additions & 1 deletion projects/app/src/pages/api/core/ai/model/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/nex
import { NextAPI } from '@/service/middleware/entry';
import { authSystemAdmin } from '@fastgpt/service/support/permission/user/auth';
import { MongoSystemModel } from '@fastgpt/service/core/ai/config/schema';
import { delay } from '@fastgpt/global/common/system/utils';
import { updateFastGPTConfigBuffer } from '@fastgpt/service/common/system/config/controller';
import { findModelFromAlldata } from '@fastgpt/service/core/ai/model';
import { loadSystemModels } from '@fastgpt/service/core/ai/config/utils';
Expand Down

0 comments on commit c3192ef

Please sign in to comment.