fix: timezone count (#4604)
* fix: timezone count * fix: ts * fix: test llm
This commit is contained in:
parent
61aa91b3aa
commit
4ac2a2f43e
@ -18,4 +18,7 @@ weight: 793
|
||||
## 🐛 修复
|
||||
|
||||
1. 文件上传分块大小限制,避免超出 MongoDB 限制。
|
||||
2. 使用记录仪表盘,无法获取指定成员的使用统计。
|
||||
3. 仪表盘接口,因未考虑时区问题,统计异常。
|
||||
4. LLM 模型测试接口,无法测试未启用的 LLM。
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -7,8 +7,8 @@ export type CreateTrainingUsageProps = {
|
||||
};
|
||||
|
||||
export type GetUsageProps = {
|
||||
dateStart: Date;
|
||||
dateEnd: Date;
|
||||
dateStart: string;
|
||||
dateEnd: string;
|
||||
sources?: UsageSourceEnum[];
|
||||
teamMemberIds?: string[];
|
||||
projectName?: string;
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -45,7 +45,7 @@ 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);
|
||||
@ -83,7 +83,6 @@ export const loadSystemModels = async (init = false) => {
|
||||
global.systemDefaultModel.rerank = model;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!init && global.systemModelList) return;
|
||||
|
||||
@ -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 (
|
||||
<Select
|
||||
|
||||
@ -70,11 +70,11 @@ const UsageDashboard = ({
|
||||
() =>
|
||||
getDashboardData({
|
||||
dateStart: dateRange.from
|
||||
? new Date(dateRange.from.setHours(0, 0, 0, 0))
|
||||
: new Date(new Date().setHours(0, 0, 0, 0)),
|
||||
? dayjs(dateRange.from.setHours(0, 0, 0, 0)).format()
|
||||
: dayjs(new Date().setHours(0, 0, 0, 0)).format(),
|
||||
dateEnd: dateRange.to
|
||||
? new Date(addDays(dateRange.to, 1).setHours(0, 0, 0, 0))
|
||||
: new Date(addDays(new Date(), 1).setHours(0, 0, 0, 0)),
|
||||
? dayjs(addDays(dateRange.to, 1).setHours(0, 0, 0, 0)).format()
|
||||
: dayjs(addDays(new Date(), 1).setHours(0, 0, 0, 0)).format(),
|
||||
sources: isSelectAllSource ? undefined : usageSources,
|
||||
teamMemberIds: isSelectAllTmb ? undefined : selectTmbIds,
|
||||
unit
|
||||
|
||||
@ -45,8 +45,8 @@ const UsageTableList = ({
|
||||
filterParams;
|
||||
const requestParams = useMemo(() => {
|
||||
return {
|
||||
dateStart: dateRange.from || new Date(),
|
||||
dateEnd: addDays(dateRange.to || new Date(), 1),
|
||||
dateStart: dayjs(dateRange.from || new Date()).format(),
|
||||
dateEnd: dayjs(addDays(dateRange.to || new Date(), 1)).format(),
|
||||
sources: isSelectAllSource ? undefined : usageSources,
|
||||
teamMemberIds: isSelectAllTmb ? undefined : selectTmbIds,
|
||||
projectName
|
||||
|
||||
@ -16,8 +16,6 @@ import FillRowTabs from '@fastgpt/web/components/common/Tabs/FillRowTabs';
|
||||
import MultipleSelect, {
|
||||
useMultipleSelect
|
||||
} from '@fastgpt/web/components/common/MySelect/MultipleSelect';
|
||||
import SearchInput from '@fastgpt/web/components/common/Input/SearchInput';
|
||||
import MySelect from '@fastgpt/web/components/common/MySelect';
|
||||
import { useRouter } from 'next/router';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ export const readConfigData = async (name: string) => {
|
||||
export function initGlobalVariables() {
|
||||
function initPlusRequest() {
|
||||
global.textCensorHandler = function textCensorHandler({ text }: { text: string }) {
|
||||
if (!isProVersion()) return Promise.resolve({ code: 200 });
|
||||
return POST<{ code: number; message?: string }>('/common/censor/check', { text });
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user