mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
test: update tests to use llm client wrapper
Co-Authored-By: Han Xiao <han.xiao@jina.ai>
This commit is contained in:
parent
dc2c0cae5f
commit
c639e57418
@ -1,6 +1,10 @@
|
||||
import { getResponse } from '../agent';
|
||||
import { setupTestLLMConfig } from '../tools/__tests__/test-helpers';
|
||||
|
||||
describe('getResponse', () => {
|
||||
beforeEach(() => {
|
||||
setupTestLLMConfig();
|
||||
});
|
||||
it('should handle search action', async () => {
|
||||
const result = await getResponse('What is TypeScript?', 1000);
|
||||
expect(result.result.action).toBeDefined();
|
||||
|
||||
@ -44,7 +44,7 @@ export const OPENAI_BASE_URL = process.env.OPENAI_BASE_URL;
|
||||
export const SEARCH_PROVIDER: 'brave' | 'jina' | 'duck' = 'jina'
|
||||
|
||||
export const llmConfig: LLMConfig = {
|
||||
provider: 'gemini',
|
||||
provider: process.env.NODE_ENV === 'test' ? 'gemini' : 'gemini', // Force Gemini in tests
|
||||
baseURL: OPENAI_BASE_URL,
|
||||
apiKey: OPENAI_API_KEY,
|
||||
model: 'gpt-3.5-turbo'
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import { dedupQueries } from '../dedup';
|
||||
import { setupTestLLMConfig } from './test-helpers';
|
||||
|
||||
describe('dedupQueries', () => {
|
||||
beforeEach(() => {
|
||||
setupTestLLMConfig();
|
||||
});
|
||||
it('should remove duplicate queries', async () => {
|
||||
const queries = ['typescript tutorial', 'typescript tutorial', 'javascript basics'];
|
||||
const { unique_queries } = await dedupQueries(queries, []);
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import { analyzeSteps } from '../error-analyzer';
|
||||
import { setupTestLLMConfig } from './test-helpers';
|
||||
|
||||
describe('analyzeSteps', () => {
|
||||
beforeEach(() => {
|
||||
setupTestLLMConfig();
|
||||
});
|
||||
it('should analyze error steps', async () => {
|
||||
const { response } = await analyzeSteps(['Step 1: Search failed', 'Step 2: Invalid query']);
|
||||
expect(response).toHaveProperty('recap');
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
import { evaluateAnswer } from '../evaluator';
|
||||
import { TokenTracker } from '../../utils/token-tracker';
|
||||
import { setupTestLLMConfig } from './test-helpers';
|
||||
|
||||
describe('evaluateAnswer', () => {
|
||||
beforeEach(() => {
|
||||
setupTestLLMConfig();
|
||||
});
|
||||
it('should evaluate answer definitiveness', async () => {
|
||||
const tokenTracker = new TokenTracker();
|
||||
const { response } = await evaluateAnswer(
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import { rewriteQuery } from '../query-rewriter';
|
||||
import { setupTestLLMConfig } from './test-helpers';
|
||||
|
||||
describe('rewriteQuery', () => {
|
||||
beforeEach(() => {
|
||||
setupTestLLMConfig();
|
||||
});
|
||||
it('should rewrite search query', async () => {
|
||||
const { queries } = await rewriteQuery({
|
||||
action: 'search',
|
||||
|
||||
7
src/tools/__tests__/test-helpers.ts
Normal file
7
src/tools/__tests__/test-helpers.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { llmConfig } from '../../config';
|
||||
|
||||
export const setupTestLLMConfig = () => {
|
||||
llmConfig.provider = 'gemini';
|
||||
delete llmConfig.baseURL;
|
||||
delete llmConfig.model;
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user