mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
fix: replace require with dynamic imports and fix unused parameter
Co-Authored-By: Han Xiao <han.xiao@jina.ai>
This commit is contained in:
parent
40fef7b793
commit
34e3111a9e
@ -1,17 +1,4 @@
|
||||
import { GoogleAIWrapper, LocalLLMClient } from '../utils/llm-client';
|
||||
import { llmClient } from '../config';
|
||||
|
||||
jest.mock('../config', () => {
|
||||
let mockConfig = { llmClient: null };
|
||||
return {
|
||||
get llmClient() {
|
||||
return mockConfig.llmClient;
|
||||
},
|
||||
__setMockConfig: (config: { llmClient: any }) => {
|
||||
mockConfig = config;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
describe('LLM Client', () => {
|
||||
const originalEnv = process.env;
|
||||
@ -25,23 +12,19 @@ describe('LLM Client', () => {
|
||||
process.env = originalEnv;
|
||||
});
|
||||
|
||||
it('should use GoogleAIWrapper by default', () => {
|
||||
it('should use GoogleAIWrapper by default', async () => {
|
||||
process.env.LLM_PROVIDER = 'gemini';
|
||||
process.env.GEMINI_API_KEY = 'test-key';
|
||||
jest.isolateModules(() => {
|
||||
const { llmClient } = require('../config');
|
||||
expect(llmClient).toBeInstanceOf(GoogleAIWrapper);
|
||||
});
|
||||
const { llmClient } = await import('../config');
|
||||
expect(llmClient).toBeInstanceOf(GoogleAIWrapper);
|
||||
});
|
||||
|
||||
it('should use LocalLLMClient when configured', () => {
|
||||
it('should use LocalLLMClient when configured', async () => {
|
||||
process.env.LLM_PROVIDER = 'local';
|
||||
process.env.LOCAL_LLM_HOSTNAME = 'localhost';
|
||||
process.env.LOCAL_LLM_PORT = '8000';
|
||||
process.env.LOCAL_LLM_MODEL = 'test-model';
|
||||
jest.isolateModules(() => {
|
||||
const { llmClient } = require('../config');
|
||||
expect(llmClient).toBeInstanceOf(LocalLLMClient);
|
||||
});
|
||||
const { llmClient } = await import('../config');
|
||||
expect(llmClient).toBeInstanceOf(LocalLLMClient);
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,7 +3,7 @@ import { LLMClient, LLMClientConfig } from '../../../utils/llm-client';
|
||||
export class MockLLMClient implements LLMClient {
|
||||
constructor(private mockResponse: string = '{"queries": ["test query"]}') {}
|
||||
|
||||
getGenerativeModel(_config: LLMClientConfig) {
|
||||
getGenerativeModel(_: LLMClientConfig) {
|
||||
return {
|
||||
generateContent: async () => ({
|
||||
response: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user