* fix: ts

* fix review
This commit is contained in:
Archer
2026-05-07 21:33:30 +08:00
committed by GitHub
parent 23b5094bf4
commit 2dcb754f47
34 changed files with 111 additions and 68 deletions
@@ -17,3 +17,5 @@ declare global {
var concatUsageHandler: (data: ConcatUsageProps) => any;
var pushUsageItemsHandler: (data: PushUsageItemsProps) => any;
}
export {};
-1
View File
@@ -7,7 +7,6 @@ import {
Worker,
type WorkerOptions
} from 'bullmq';
import './type';
import { getLogger, LogCategories } from '../logger';
import { newQueueRedisConnection, newWorkerRedisConnection } from '../redis';
import { delay } from '@fastgpt/global/common/system/utils';
+7
View File
@@ -0,0 +1,7 @@
import type { SystemCacheType } from './type';
declare global {
var systemCache: SystemCacheType;
}
export {};
+1 -5
View File
@@ -10,7 +10,7 @@ export type SystemCacheDataType = {
[SystemCacheKeyEnum.modelPermission]: null;
};
type SystemCacheType = {
export type SystemCacheType = {
[K in SystemCacheKeyEnum]: {
versionKey: string;
data: SystemCacheDataType[K];
@@ -18,7 +18,3 @@ type SystemCacheType = {
devRefresh?: boolean;
};
};
declare global {
var systemCache: SystemCacheType;
}
@@ -1,7 +1,8 @@
import type { Mongoose } from 'mongoose';
import type { Logger } from 'winston';
declare global {
var mongodb: Mongoose | undefined;
var mongodbLog: Mongoose | undefined;
}
export {};
@@ -3,3 +3,5 @@ import type Redis from 'ioredis';
declare global {
var redisClient: Redis | null;
}
export {};
+9
View File
@@ -0,0 +1,9 @@
import type { S3BaseBucket } from '../buckets/base';
declare global {
var s3BucketMap: {
[key: string]: S3BaseBucket;
};
}
export {};
@@ -1,6 +1,5 @@
import z from 'zod';
import { Readable } from 'node:stream';
import type { S3BaseBucket } from '../buckets/base';
export const S3MetadataSchema = z.object({
filename: z.string(),
@@ -87,9 +86,3 @@ export const UploadFileByBodySchema = z.object({
});
export type UploadFileByBodyParams = z.infer<typeof UploadFileByBodySchema>;
export type UploadFileByBufferParams = UploadFileByBodyParams;
declare global {
var s3BucketMap: {
[key: string]: S3BaseBucket;
};
}
+7
View File
@@ -0,0 +1,7 @@
import type { S3AvatarSource } from '.';
declare global {
var avatarBucket: S3AvatarSource;
}
export {};
@@ -1,10 +1,9 @@
import { S3Sources } from '../contracts/type';
import { MongoS3TTL } from '../models/ttl';
import { S3PublicBucket } from '../buckets/public';
import { avatarAllowedExtensions } from '../utils/uploadConstraints';
import { imageBaseUrl } from '@fastgpt/global/common/file/image/constants';
import type { ClientSession } from 'mongoose';
import { getFileS3Key } from '../utils';
import { getFileS3Key } from '../../utils';
import { MongoS3TTL } from '../../models/ttl';
import { S3PublicBucket } from '../../buckets/public';
import { avatarAllowedExtensions } from '../../utils/uploadConstraints';
class S3AvatarSource extends S3PublicBucket {
constructor() {
@@ -88,7 +87,3 @@ export function getS3AvatarSource() {
global.avatarBucket = new S3AvatarSource();
return global.avatarBucket;
}
declare global {
var avatarBucket: S3AvatarSource;
}
+7
View File
@@ -0,0 +1,7 @@
import type { S3ChatSource } from './index';
declare global {
var chatBucket: S3ChatSource;
}
export {};
@@ -127,7 +127,3 @@ export function getS3ChatSource() {
global.chatBucket = new S3ChatSource();
return global.chatBucket;
}
declare global {
var chatBucket: S3ChatSource;
}
@@ -0,0 +1,7 @@
import type { S3DatasetSource } from './index';
declare global {
var datasetBucket: S3DatasetSource;
}
export {};
@@ -188,7 +188,3 @@ export function getS3DatasetSource() {
global.datasetBucket = new S3DatasetSource();
return global.datasetBucket;
}
declare global {
var datasetBucket: S3DatasetSource;
}
@@ -0,0 +1,7 @@
import type { S3HelperBotSource } from './index';
declare global {
var helperBotBucket: S3HelperBotSource;
}
export {};
@@ -100,7 +100,3 @@ export function getS3HelperBotSource() {
global.helperBotBucket = new S3HelperBotSource();
return global.helperBotBucket;
}
declare global {
var helperBotBucket: S3HelperBotSource;
}
@@ -0,0 +1,7 @@
import type { S3RawTextSource } from './index';
declare global {
var rawTextBucket: S3RawTextSource;
}
export {};
@@ -81,7 +81,3 @@ export function getS3RawTextSource() {
global.rawTextBucket = new S3RawTextSource();
return global.rawTextBucket;
}
declare global {
var rawTextBucket: S3RawTextSource;
}
+11
View File
@@ -0,0 +1,11 @@
import type { Pool as PgPool } from 'pg';
import type { Pool as MysqlPool } from 'mysql2/promise';
import type { MilvusClient } from '@zilliz/milvus2-sdk-node';
declare global {
var pgClient: PgPool | null;
var obClient: MysqlPool | null;
var milvusClient: MilvusClient | null;
}
export {};
-9
View File
@@ -1,6 +1,3 @@
import type { Pool as PgPool } from 'pg';
import type { Pool as MysqlPool } from 'mysql2/promise';
import type { MilvusClient } from '@zilliz/milvus2-sdk-node';
import z from 'zod';
// Embedding recall item schema
@@ -115,9 +112,3 @@ export interface VectorControllerType {
*/
getVectorCount(props: GetVectorCountPropsType): Promise<number>;
}
declare global {
var pgClient: PgPool | null;
var obClient: MysqlPool | null;
var milvusClient: MilvusClient | null;
}
+3 -2
View File
@@ -93,7 +93,7 @@ export const createLLMResponse = async <T extends ChatCompletionCreateParams>(
const requestMessages = await loadRequestMessages({
messages,
useVision: useVision && model.vision,
origin: requestOrigin
supportReason: model.reasoning
});
// Message process
const rewriteMessages = (() => {
@@ -102,7 +102,8 @@ export const createLLMResponse = async <T extends ChatCompletionCreateParams>(
}
return requestMessages;
})();
// console.log(23232323);
// console.dir(rewriteMessages, { depth: null });
const { requestBody, modelData } = await llmCompletionsBodyFormat({
...body,
messages: rewriteMessages
+8 -7
View File
@@ -95,11 +95,11 @@ export const filterGPTMessageByMaxContext = async ({
export const loadRequestMessages = async ({
messages,
useVision = false,
origin
supportReason = false
}: {
messages: ChatCompletionMessageParam[];
useVision?: boolean;
origin?: string;
supportReason?: boolean;
}) => {
const parseSystemMessage = (
content: string | ChatCompletionContentPartText[]
@@ -265,12 +265,13 @@ export const loadRequestMessages = async ({
const formatAssistantItem = (
item: ChatCompletionAssistantMessageParam & {
reasoning_content?: string;
}
},
supportReason: boolean
) => {
return {
role: item.role,
content: item.content || undefined,
reasoning_content: item.reasoning_content || undefined,
reasoning_content: supportReason ? item.reasoning_content || undefined : undefined,
function_call: item.function_call || undefined,
name: item.name || undefined,
refusal: item.refusal || undefined,
@@ -411,8 +412,8 @@ export const loadRequestMessages = async ({
: (formatContent as ChatCompletionContentPartText[])
};
} else if (item.role === ChatCompletionRequestMessageRoleEnum.Assistant) {
if (item.tool_calls || item.function_call || item.reasoning_content) {
return formatAssistantItem(item);
if (item.tool_calls || item.function_call) {
return formatAssistantItem(item, supportReason);
}
const parseContent = parseAssistantContent(item.content);
@@ -433,7 +434,7 @@ export const loadRequestMessages = async ({
if (!formatContent) return;
return {
...formatAssistantItem(item),
...formatAssistantItem(item, supportReason),
content: formatContent
};
} else {
@@ -52,3 +52,5 @@ declare global {
var systemActiveDesensitizedModels: SystemModelItemType[];
var systemDefaultModel: SystemDefaultModelType;
}
export {};
+8
View File
@@ -0,0 +1,8 @@
import type { AppTemplateSchemaType } from '@fastgpt/global/core/app/type';
declare global {
var appTemplates: AppTemplateSchemaType[];
var templatesRefreshTime: number;
}
export {};
@@ -74,8 +74,3 @@ export const getAppTemplatesAndLoadThem = async (refresh = false) => {
export const isCommercialTemaplte = (templateId: string) => {
return templateId.startsWith(AppToolSourceEnum.commercial);
};
declare global {
var appTemplates: AppTemplateSchemaType[];
var templatesRefreshTime: number;
}
+1
View File
@@ -85,6 +85,7 @@
"@types/lodash": "catalog:",
"@types/mime-types": "catalog:",
"@types/multer": "^1.4.10",
"@types/node": "catalog:",
"@types/node-cron": "^3.0.11",
"@types/papaparse": "5.3.7",
"@types/pg": "^8.6.6",
+1 -1
View File
@@ -3,5 +3,5 @@
"compilerOptions": {
"moduleResolution": "bundler"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.d.ts"]
}
+3
View File
@@ -632,6 +632,9 @@ importers:
'@types/multer':
specifier: ^1.4.10
version: 1.4.12
'@types/node':
specifier: 'catalog:'
version: 20.17.24
'@types/node-cron':
specifier: ^3.0.11
version: 3.0.11
+1 -1
Submodule pro updated: ee1b1d779d...1dc6ead607
+1 -1
View File
@@ -28,6 +28,6 @@
"#fastgpt/app/test/*": ["./*"],
}
},
"include": ["**/*.test.ts"],
"include": ["**/*.test.ts", "../../../packages/service/**/*.d.ts"],
"exclude": ["**/node_modules"]
}
+2 -1
View File
@@ -13,7 +13,8 @@
"**/*.ts",
"**/*.tsx",
"../../packages/**/*.ts",
"../../packages/**/*.tsx"
"../../packages/**/*.tsx",
"../../packages/**/*.d.ts"
],
"exclude": [
"**/*.test.ts",
+1 -1
View File
@@ -28,6 +28,6 @@
"#fastgpt/marketplace/test/*": ["./*"],
}
},
"include": ["**/*.test.ts"],
"include": ["**/*.test.ts", "../../../packages/service/**/*.d.ts"],
"exclude": ["**/node_modules"]
}
+7 -1
View File
@@ -6,7 +6,13 @@
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "../../packages/**/*.ts"],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"../../packages/**/*.ts",
"../../packages/**/*.d.ts"
],
"exclude": [
"**/*.test.ts",
"../../packages/**/vitest.config.ts",