Commit e30f0e35 by Archer Committed by GitHub

fix: defaultconfig (#6938)

parent 5e64f6c9
---
title: 'V4.14.20 (In Progress)'
description: 'FastGPT V4.14.20 release notes'
---
## Upgrade Guide
### 1. Update image tags
- Update the fastgpt-app image tag (FastGPT main service): v4.14.20
- Update the fastgpt-pro image tag (FastGPT commercial edition): v4.14.20
## 🐛 Fixes
1. Improved workflow Zod data type compatibility.
2. Fixed an issue where model configuration could not fully override `defaultConfig`.
---
title: 'V4.14.20(进行中)'
description: 'FastGPT V4.14.20 更新说明'
---
## 升级指南
### 1. 更新镜像 tag
- 更新 fastgpt-app(fastgpt 主服务) 镜像 tag: v4.14.20
- 更新 fastgpt-pro(fastgpt 商业版) 镜像 tag: v4.14.20
## 🐛 修复
1. 增强工作流 zod 数据类型适配性。
2. 模型配置,无法完全覆盖 defaultConfig。
......@@ -2,6 +2,7 @@
"title": "4.14.x",
"description": "",
"pages": [
"41420",
"41419",
"41418",
"41417",
......
......@@ -2,6 +2,7 @@
"title": "4.14.x",
"description": "",
"pages": [
"41420",
"41419",
"41418",
"41417",
......
......@@ -128,6 +128,7 @@ description: FastGPT Toc
- [/en/self-host/upgrading/4-14/41416](/en/self-host/upgrading/4-14/41416)
- [/en/self-host/upgrading/4-14/41419](/en/self-host/upgrading/4-14/41419)
- [/en/self-host/upgrading/4-14/4142](/en/self-host/upgrading/4-14/4142)
- [/en/self-host/upgrading/4-14/41420](/en/self-host/upgrading/4-14/41420)
- [/en/self-host/upgrading/4-14/4143](/en/self-host/upgrading/4-14/4143)
- [/en/self-host/upgrading/4-14/4144](/en/self-host/upgrading/4-14/4144)
- [/en/self-host/upgrading/4-14/4145](/en/self-host/upgrading/4-14/4145)
......
......@@ -130,6 +130,7 @@ description: FastGPT 文档目录
- [/self-host/upgrading/4-14/41418](/self-host/upgrading/4-14/41418)
- [/self-host/upgrading/4-14/41419](/self-host/upgrading/4-14/41419)
- [/self-host/upgrading/4-14/4142](/self-host/upgrading/4-14/4142)
- [/self-host/upgrading/4-14/41420](/self-host/upgrading/4-14/41420)
- [/self-host/upgrading/4-14/4143](/self-host/upgrading/4-14/4143)
- [/self-host/upgrading/4-14/4144](/self-host/upgrading/4-14/4144)
- [/self-host/upgrading/4-14/4145](/self-host/upgrading/4-14/4145)
......
......@@ -205,8 +205,8 @@
"content/self-host/migration/docker_mongo.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/troubleshooting/attention.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/troubleshooting/attention.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/troubleshooting/faq.en.mdx": "2026-05-12T16:38:31+08:00",
"content/self-host/troubleshooting/faq.mdx": "2026-05-12T16:38:31+08:00",
"content/self-host/troubleshooting/faq.en.mdx": "2026-05-12T18:16:10+08:00",
"content/self-host/troubleshooting/faq.mdx": "2026-05-12T18:16:10+08:00",
"content/self-host/troubleshooting/methods.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/troubleshooting/methods.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/troubleshooting/model-errors.en.mdx": "2026-04-26T21:08:47+08:00",
......
......@@ -36,14 +36,14 @@ export const loadSystemModels = async (init = false, language = 'en') => {
return Promise.reject(error);
}
let _systemModelList: SystemModelItemType[] = [];
let _systemActiveModelList: SystemModelItemType[] = [];
let _llmModelMap = new Map<string, LLMModelItemType>();
let _embeddingModelMap = new Map<string, EmbeddingModelItemType>();
let _ttsModelMap = new Map<string, TTSModelType>();
let _sttModelMap = new Map<string, STTModelType>();
let _reRankModelMap = new Map<string, RerankModelItemType>();
let _systemDefaultModel: SystemDefaultModelType = {};
const _systemModelList: SystemModelItemType[] = [];
const _systemActiveModelList: SystemModelItemType[] = [];
const _llmModelMap = new Map<string, LLMModelItemType>();
const _embeddingModelMap = new Map<string, EmbeddingModelItemType>();
const _ttsModelMap = new Map<string, TTSModelType>();
const _sttModelMap = new Map<string, STTModelType>();
const _reRankModelMap = new Map<string, RerankModelItemType>();
const _systemDefaultModel: SystemDefaultModelType = {};
if (!global.systemModelList) {
global.systemModelList = [];
......@@ -149,8 +149,14 @@ export const loadSystemModels = async (init = false, language = 'en') => {
...(model.type === ModelTypeEnum.llm && dbModel?.metadata?.type === ModelTypeEnum.llm
? {
maxResponse: dbModel?.metadata?.maxResponse ?? model.maxTokens ?? 8000,
defaultConfig: mergeObject(model.defaultConfig, dbModel?.metadata?.defaultConfig),
fieldMap: mergeObject(model.fieldMap, dbModel?.metadata?.fieldMap),
defaultConfig:
typeof dbModel?.metadata?.defaultConfig === 'object'
? dbModel?.metadata?.defaultConfig
: model.defaultConfig,
fieldMap:
typeof dbModel?.metadata?.fieldMap === 'object'
? dbModel?.metadata?.fieldMap
: model.fieldMap,
/** @deprecated */
maxTokens: undefined
}
......
......@@ -6,22 +6,16 @@ import { findModelFromAlldata } from '@fastgpt/service/core/ai/model';
import { updatedReloadSystemModel } from '@fastgpt/service/core/ai/config/utils';
import { ModelTypeEnum } from '@fastgpt/global/core/ai/constants';
export type updateQuery = {};
export type updateBody = {
model: string;
metadata?: Record<string, any>;
};
export type updateResponse = {};
async function handler(
req: ApiRequestProps<updateBody, updateQuery>,
res: ApiResponseType<any>
): Promise<updateResponse> {
async function handler(req: ApiRequestProps<updateBody>, res: ApiResponseType<any>) {
await authSystemAdmin({ req });
let { model, metadata } = req.body;
const metadata = req.body.metadata;
let { model } = req.body;
if (!model) return Promise.reject(new Error('model is required'));
model = model.trim();
......@@ -60,6 +54,11 @@ async function handler(
}
});
// 强制更新 defaultConfig 数据类型
if ('defaultConfig' in metadataConcat && typeof metadataConcat.defaultConfig !== 'object') {
metadataConcat.defaultConfig = {};
}
await MongoSystemModel.updateOne(
{ model },
{
......
......@@ -6,18 +6,11 @@ import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
import { MongoSystemModel } from '@fastgpt/service/core/ai/config/schema';
import { updatedReloadSystemModel } from '@fastgpt/service/core/ai/config/utils';
export type updateWithJsonQuery = {};
export type updateWithJsonBody = {
config: string;
};
export type updateWithJsonResponse = {};
async function handler(
req: ApiRequestProps<updateWithJsonBody, updateWithJsonQuery>,
res: ApiResponseType<any>
): Promise<updateWithJsonResponse> {
async function handler(req: ApiRequestProps<updateWithJsonBody>, res: ApiResponseType<any>) {
await authSystemAdmin({ req });
const { config } = req.body;
......@@ -41,6 +34,11 @@ async function handler(
if (!item.metadata.name) {
item.metadata.name = item.model;
}
if ('defaultConfig' in item.metadata && typeof item.metadata.defaultConfig !== 'object') {
{
item.metadata.defaultConfig = {};
}
}
}
await mongoSessionRun(async (session) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment