Skip to content

Commit

Permalink
4.8.20 update (#3706)
Browse files Browse the repository at this point in the history
* fix: rerank auth token

* feat: check null value

* bind notify

* perf: reasoning config

* Adapt mongo 4.x index
  • Loading branch information
c121914yu authored Feb 6, 2025
1 parent 772c1cd commit d857a39
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 30 deletions.
3 changes: 3 additions & 0 deletions packages/global/core/ai/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export const getModelFromList = (
model: string
) => {
const modelData = modelList.find((item) => item.model === model) ?? modelList[0];
if (!modelData) {
throw new Error('No Key model is configured');
}
const provider = getModelProvider(modelData.provider);
return {
...modelData,
Expand Down
9 changes: 7 additions & 2 deletions packages/service/common/mongo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,20 @@ export const getMongoModel = <T>(name: string, schema: mongoose.Schema) => {

const model = connectionMongo.model<T>(name, schema);

// Sync index
syncMongoIndex(model);

return model;
};

const syncMongoIndex = async (model: Model<any>) => {
if (process.env.SYNC_INDEX !== '0' && process.env.NODE_ENV !== 'test') {
try {
model.syncIndexes({ background: true });
} catch (error) {
addLog.error('Create index error', error);
}
}

return model;
};

export const ReadPreference = connectionMongo.mongo.ReadPreference;
2 changes: 1 addition & 1 deletion packages/service/core/ai/audio/transcriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const aiTranscriptions = async ({
? { url: modelData.requestUrl }
: {
baseURL: aiAxiosConfig.baseUrl,
url: modelData.requestUrl || '/audio/transcriptions'
url: '/audio/transcriptions'
}),
headers: {
Authorization: modelData.requestAuth
Expand Down
10 changes: 7 additions & 3 deletions packages/service/core/ai/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import {
ReRankModelItemType
} from '@fastgpt/global/core/ai/model.d';
import { debounce } from 'lodash';
import { ModelProviderType } from '@fastgpt/global/core/ai/provider';
import {
getModelProvider,
ModelProviderIdType,
ModelProviderType
} from '@fastgpt/global/core/ai/provider';
import { findModelFromAlldata } from '../model';
import {
reloadFastGPTConfigBuffer,
Expand Down Expand Up @@ -91,7 +95,7 @@ export const loadSystemModels = async (init = false) => {
await Promise.all(
providerList.map(async (name) => {
const fileContent = (await import(`./provider/${name}`))?.default as {
provider: ModelProviderType;
provider: ModelProviderIdType;
list: SystemModelItemType[];
};

Expand All @@ -101,7 +105,7 @@ export const loadSystemModels = async (init = false) => {
const modelData: any = {
...fileModel,
...dbModel?.metadata,
provider: dbModel?.metadata?.provider || fileContent.provider,
provider: getModelProvider(dbModel?.metadata?.provider || fileContent.provider).id,
type: dbModel?.metadata?.type || fileModel.type,
isCustom: false
};
Expand Down
10 changes: 6 additions & 4 deletions packages/service/core/ai/embedding/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ export async function getVectorsByText({ model, input, type }: GetVectorProps) {
model: model.model,
input: [input]
},
model.requestUrl && model.requestAuth
model.requestUrl
? {
path: model.requestUrl,
headers: {
Authorization: `Bearer ${model.requestAuth}`
}
headers: model.requestAuth
? {
Authorization: `Bearer ${model.requestAuth}`
}
: undefined
}
: {}
)
Expand Down
4 changes: 2 additions & 2 deletions packages/service/core/ai/rerank/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function reRankRecall({
return Promise.reject('no rerank model');
}

const { baseUrl, authorization } = getAxiosConfig({});
const { baseUrl, authorization } = getAxiosConfig();

let start = Date.now();
return POST<PostReRankResponse>(
Expand All @@ -38,7 +38,7 @@ export function reRankRecall({
},
{
headers: {
Authorization: model.requestAuth ? model.requestAuth : authorization
Authorization: model.requestAuth ? `Bearer ${model.requestAuth}` : authorization
},
timeout: 30000
}
Expand Down
7 changes: 1 addition & 6 deletions packages/service/core/dataset/data/dataTextSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ try {
{ teamId: 1, datasetId: 1, fullTextToken: 'text' },
{
name: 'teamId_1_datasetId_1_fullTextToken_text',
default_language: 'none',
collation: {
locale: 'simple', // 使用简单匹配规则
strength: 2, // 忽略大小写
caseLevel: false // 进一步确保大小写不敏感
}
default_language: 'none'
}
);
DatasetDataTextSchema.index({ dataId: 1 }, { unique: true });
Expand Down
2 changes: 2 additions & 0 deletions packages/web/i18n/en/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"model.output_price": "Output price",
"model.output_price_tip": "The language model output price. If this item is configured, the model comprehensive price will be invalid.",
"model.param_name": "Parameter name",
"model.reasoning": "Support output thinking",
"model.reasoning_tip": "For example, Deepseek-reasoner can output the thinking process.",
"model.request_auth": "Custom key",
"model.request_auth_tip": "When making a request to a custom request address, carry the request header: Authorization: Bearer xxx to make the request.",
"model.request_url": "Custom url",
Expand Down
2 changes: 2 additions & 0 deletions packages/web/i18n/zh-CN/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"model.output_price": "模型输出价格",
"model.output_price_tip": "语言模型输出价格,如果配置了该项,则模型综合价格会失效",
"model.param_name": "参数名",
"model.reasoning": "支持输出思考",
"model.reasoning_tip": "例如 Deepseek-reasoner,可以输出思考过程。",
"model.request_auth": "自定义请求 Key",
"model.request_auth_tip": "向自定义请求地址发起请求时候,携带请求头:Authorization: Bearer xxx 进行请求",
"model.request_url": "自定义请求地址",
Expand Down
2 changes: 2 additions & 0 deletions packages/web/i18n/zh-Hant/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"model.output_price": "模型輸出價格",
"model.output_price_tip": "語言模型輸出價格,如果配置了該項,則模型綜合價格會失效",
"model.param_name": "參數名",
"model.reasoning": "支持輸出思考",
"model.reasoning_tip": "例如 Deepseek-reasoner,可以輸出思考過程。",
"model.request_auth": "自訂請求 Key",
"model.request_auth_tip": "向自訂請求地址發起請求時候,攜帶請求頭:Authorization: Bearer xxx 進行請求",
"model.request_url": "自訂請求地址",
Expand Down
7 changes: 2 additions & 5 deletions projects/app/public/docs/chatProblem.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
### 常见问题

- [**Git 地址**,点击查看项目地址](https://github.com/labring/FastGPT)
- [本地部署 FastGPT](https://doc.tryfastgpt.ai/docs/installation)
- [API 文档](https://doc.tryfastgpt.ai/docs/development/openapi?pre_pathname=%2Fdrive%2Fhome%2F)
- **反馈问卷**: 如果你遇到任何使用问题或有期望的功能,可以[填写该问卷](https://www.wjx.cn/vm/rLIw1uD.aspx#)
- **问题文档**: [先看文档,再提问](https://kjqvjse66l.feishu.cn/docx/HtrgdT0pkonP4kxGx8qcu6XDnGh)
- [点击查看商业版文档](https://doc.tryfastgpt.ai/docs/commercial)
- [点击查看官方文档](https://doc.tryfastgpt.ai/docs/)
- [点击查看商业版文档](https://doc.tryfastgpt.ai/docs/shopping_cart/intro/)
- [计费规则](https://doc.tryfastgpt.ai/docs/pricing/)

**其他问题**
Expand Down
2 changes: 2 additions & 0 deletions projects/app/src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const Layout = ({ children }: { children: JSX.Element }) => {

const showUpdateNotification =
isUpdateNotification &&
feConfigs?.bind_notification_method &&
feConfigs?.bind_notification_method.length > 0 &&
!userInfo?.team.notificationAccount &&
!!userInfo?.team.permission.isOwner;

Expand Down
13 changes: 13 additions & 0 deletions projects/app/src/pageComponents/account/model/ModelConfigTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,19 @@ const ModelEditModal = ({
</Flex>
</Td>
</Tr>
<Tr>
<Td>
<HStack spacing={1}>
<Box>{t('account:model.reasoning')}</Box>
<QuestionTip label={t('account:model.reasoning_tip')} />
</HStack>
</Td>
<Td textAlign={'right'}>
<Flex justifyContent={'flex-end'}>
<Switch {...register('reasoning')} />
</Flex>
</Td>
</Tr>
{feConfigs?.isPlus && (
<Tr>
<Td>
Expand Down
18 changes: 11 additions & 7 deletions projects/app/src/pages/api/core/ai/model/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ const testLLMModel = async (model: LLMModelItemType) => {
},
{
...(model.requestUrl ? { path: model.requestUrl } : {}),
headers: {
...(model.requestAuth ? { Authorization: `Bearer ${model.requestAuth}` } : {})
}
headers: model.requestAuth
? {
Authorization: `Bearer ${model.requestAuth}`
}
: undefined
}
);

Expand Down Expand Up @@ -98,12 +100,14 @@ const testTTSModel = async (model: TTSModelType) => {
response_format: 'mp3',
speed: 1
},
model.requestUrl && model.requestAuth
model.requestUrl
? {
path: model.requestUrl,
headers: {
Authorization: `Bearer ${model.requestAuth}`
}
headers: model.requestAuth
? {
Authorization: `Bearer ${model.requestAuth}`
}
: undefined
}
: {}
);
Expand Down

0 comments on commit d857a39

Please sign in to comment.