chore: vitest support (#4026)

* chore: vitest

* chore: move test files

* chore: support vitest

* fix: exclude test files

* chore(ci): add test workflow

* feat: remove read env
This commit is contained in:
Finley Ge
2025-03-12 19:27:53 +08:00
committed by GitHub
parent 139e934345
commit bb30ca4859
32 changed files with 2393 additions and 892 deletions

52
test/setupModels.ts Normal file
View File

@@ -0,0 +1,52 @@
import { ModelTypeEnum } from 'packages/global/core/ai/model';
import { ModelProviderIdType } from 'packages/global/core/ai/provider';
export default async function setupModels() {
global.llmModelMap = new Map<string, any>();
global.llmModelMap.set('gpt-4o-mini', {
type: ModelTypeEnum.llm,
model: 'gpt-4o-mini',
name: 'gpt-4o-mini',
avatar: 'gpt-4o-mini',
isActive: true,
isDefault: true,
isCustom: false,
requestUrl: undefined,
requestAuth: undefined,
customCQPrompt: '',
customExtractPrompt: '',
defaultSystemChatPrompt: undefined,
fieldMap: undefined,
defaultConfig: undefined,
provider: 'OpenAI' as ModelProviderIdType,
functionCall: false,
toolChoice: false,
maxContext: 4096,
maxResponse: 4096,
quoteMaxToken: 2048
});
global.systemDefaultModel = {
llm: {
type: ModelTypeEnum.llm,
model: 'gpt-4o-mini',
name: 'gpt-4o-mini',
avatar: 'gpt-4o-mini',
isActive: true,
isDefault: true,
isCustom: false,
requestUrl: undefined,
requestAuth: undefined,
customCQPrompt: '',
customExtractPrompt: '',
defaultSystemChatPrompt: undefined,
fieldMap: undefined,
defaultConfig: undefined,
provider: 'OpenAI' as ModelProviderIdType,
functionCall: false,
toolChoice: false,
maxContext: 4096,
maxResponse: 4096,
quoteMaxToken: 2048
}
};
}