diff --git a/docSite/content/zh-cn/docs/development/upgrading/497.md b/docSite/content/zh-cn/docs/development/upgrading/497.md index 1e073a182..29d40c47a 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/497.md +++ b/docSite/content/zh-cn/docs/development/upgrading/497.md @@ -18,4 +18,7 @@ weight: 793 ## 🐛 修复 1. 文件上传分块大小限制,避免超出 MongoDB 限制。 +2. 使用记录仪表盘,无法获取指定成员的使用统计。 +3. 仪表盘接口,因未考虑时区问题,统计异常。 +4. LLM 模型测试接口,无法测试未启用的 LLM。 diff --git a/packages/global/common/time/timezone.ts b/packages/global/common/time/timezone.ts index ee3cbbac2..f7eb2f9de 100644 --- a/packages/global/common/time/timezone.ts +++ b/packages/global/common/time/timezone.ts @@ -30,7 +30,7 @@ export const getTimezoneOffset = (timeZone: string): number => { * * Generated by Trelent */ -export const timezoneList = () => { +export const getTimeZoneList = () => { const result = timezones .map((timezone) => { try { @@ -71,6 +71,23 @@ export const timezoneList = () => { time: number; }[]; }; +export const timeZoneList = getTimeZoneList(); + +export const getMongoTimezoneCode = (timeString: string) => { + if (!timeString.includes(':')) { + return '+00:00'; + } + + if (timeString.includes('+')) { + const timezoneMatch = timeString.split('+'); + return `+${timezoneMatch[1]}`; + } else if (timeString.includes('-')) { + const timezoneMatch = timeString.split('-'); + return `-${timezoneMatch[1]}`; + } else { + return '+00:00'; + } +}; export const getSystemTime = (timeZone: string) => { const timezoneDiff = getTimezoneOffset(timeZone); diff --git a/packages/global/support/wallet/usage/api.d.ts b/packages/global/support/wallet/usage/api.d.ts index 785eb257d..750a773ac 100644 --- a/packages/global/support/wallet/usage/api.d.ts +++ b/packages/global/support/wallet/usage/api.d.ts @@ -7,8 +7,8 @@ export type CreateTrainingUsageProps = { }; export type GetUsageProps = { - dateStart: Date; - dateEnd: Date; + dateStart: string; + dateEnd: string; sources?: UsageSourceEnum[]; teamMemberIds?: string[]; projectName?: string; diff --git a/packages/service/core/ai/config.ts b/packages/service/core/ai/config.ts index fda44d9dc..da99ef155 100644 --- a/packages/service/core/ai/config.ts +++ b/packages/service/core/ai/config.ts @@ -10,6 +10,7 @@ import { addLog } from '../../common/system/log'; import { i18nT } from '../../../web/i18n/utils'; import { OpenaiAccountType } from '@fastgpt/global/support/user/team/type'; import { getLLMModel } from './model'; +import { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; const aiProxyBaseUrl = process.env.AIPROXY_API_ENDPOINT ? `${process.env.AIPROXY_API_ENDPOINT}/v1` @@ -68,7 +69,11 @@ export const createChatCompletion = async ({ ) > => { try { + // Rewrite model const modelConstantsData = getLLMModel(body.model); + if (!modelConstantsData) { + return Promise.reject(`${body.model} not found`); + } const formatTimeout = timeout ? timeout : body.stream ? 60000 : 600000; const ai = getAIApi({ diff --git a/packages/service/core/ai/config/utils.ts b/packages/service/core/ai/config/utils.ts index e1f8c104f..31f0619da 100644 --- a/packages/service/core/ai/config/utils.ts +++ b/packages/service/core/ai/config/utils.ts @@ -45,43 +45,42 @@ export const loadSystemModels = async (init = false) => { if (model.isActive) { global.systemActiveModelList.push(model); - - if (model.type === ModelTypeEnum.llm) { - global.llmModelMap.set(model.model, model); - global.llmModelMap.set(model.name, model); - if (model.isDefault) { - global.systemDefaultModel.llm = model; - } - if (model.isDefaultDatasetTextModel) { - global.systemDefaultModel.datasetTextLLM = model; - } - if (model.isDefaultDatasetImageModel) { - global.systemDefaultModel.datasetImageLLM = model; - } - } else if (model.type === ModelTypeEnum.embedding) { - global.embeddingModelMap.set(model.model, model); - global.embeddingModelMap.set(model.name, model); - if (model.isDefault) { - global.systemDefaultModel.embedding = model; - } - } else if (model.type === ModelTypeEnum.tts) { - global.ttsModelMap.set(model.model, model); - global.ttsModelMap.set(model.name, model); - if (model.isDefault) { - global.systemDefaultModel.tts = model; - } - } else if (model.type === ModelTypeEnum.stt) { - global.sttModelMap.set(model.model, model); - global.sttModelMap.set(model.name, model); - if (model.isDefault) { - global.systemDefaultModel.stt = model; - } - } else if (model.type === ModelTypeEnum.rerank) { - global.reRankModelMap.set(model.model, model); - global.reRankModelMap.set(model.name, model); - if (model.isDefault) { - global.systemDefaultModel.rerank = model; - } + } + if (model.type === ModelTypeEnum.llm) { + global.llmModelMap.set(model.model, model); + global.llmModelMap.set(model.name, model); + if (model.isDefault) { + global.systemDefaultModel.llm = model; + } + if (model.isDefaultDatasetTextModel) { + global.systemDefaultModel.datasetTextLLM = model; + } + if (model.isDefaultDatasetImageModel) { + global.systemDefaultModel.datasetImageLLM = model; + } + } else if (model.type === ModelTypeEnum.embedding) { + global.embeddingModelMap.set(model.model, model); + global.embeddingModelMap.set(model.name, model); + if (model.isDefault) { + global.systemDefaultModel.embedding = model; + } + } else if (model.type === ModelTypeEnum.tts) { + global.ttsModelMap.set(model.model, model); + global.ttsModelMap.set(model.name, model); + if (model.isDefault) { + global.systemDefaultModel.tts = model; + } + } else if (model.type === ModelTypeEnum.stt) { + global.sttModelMap.set(model.model, model); + global.sttModelMap.set(model.name, model); + if (model.isDefault) { + global.systemDefaultModel.stt = model; + } + } else if (model.type === ModelTypeEnum.rerank) { + global.reRankModelMap.set(model.model, model); + global.reRankModelMap.set(model.name, model); + if (model.isDefault) { + global.systemDefaultModel.rerank = model; } } }; diff --git a/packages/web/components/common/MySelect/TimezoneSelect.tsx b/packages/web/components/common/MySelect/TimezoneSelect.tsx index 02cc8728b..387f2d764 100644 --- a/packages/web/components/common/MySelect/TimezoneSelect.tsx +++ b/packages/web/components/common/MySelect/TimezoneSelect.tsx @@ -1,9 +1,9 @@ import React, { useRef } from 'react'; -import { timezoneList } from '@fastgpt/global/common/time/timezone'; +import { getTimeZoneList } from '@fastgpt/global/common/time/timezone'; import { Select } from '@chakra-ui/react'; const TimezoneSelect = ({ value, onChange }: { value?: string; onChange: (e: string) => void }) => { - const timezones = useRef(timezoneList()); + const timezones = useRef(getTimeZoneList()); return (