mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2026-03-22 07:29:35 +08:00
fix: improve JSON parsing and increase test timeouts
Co-Authored-By: Han Xiao <han.xiao@jina.ai>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { dedupQueries } from '../dedup';
|
||||
|
||||
jest.setTimeout(10000);
|
||||
|
||||
describe('dedupQueries', () => {
|
||||
it('should remove duplicate queries', async () => {
|
||||
const queries = ['typescript tutorial', 'typescript tutorial', 'javascript basics'];
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { analyzeSteps } from '../error-analyzer';
|
||||
|
||||
jest.setTimeout(10000);
|
||||
|
||||
describe('analyzeSteps', () => {
|
||||
it('should analyze error steps', async () => {
|
||||
const { response } = await analyzeSteps(['Step 1: Search failed', 'Step 2: Invalid query']);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { evaluateAnswer } from '../evaluator';
|
||||
import { TokenTracker } from '../../utils/token-tracker';
|
||||
|
||||
jest.setTimeout(10000);
|
||||
|
||||
describe('evaluateAnswer', () => {
|
||||
it('should evaluate answer definitiveness', async () => {
|
||||
const tokenTracker = new TokenTracker();
|
||||
|
||||
@@ -27,8 +27,10 @@ async function generateResponse(provider: AIProvider, prompt: string, providerTy
|
||||
}
|
||||
});
|
||||
const response = await result.response;
|
||||
const text = response.text();
|
||||
const jsonMatch = text.match(/```json\s*(\{[\s\S]*?\})\s*```/) || text.match(/(\{[\s\S]*\})/);
|
||||
return {
|
||||
text: response.text(),
|
||||
text: jsonMatch ? jsonMatch[1].trim() : text,
|
||||
tokens: response.usageMetadata?.totalTokenCount || 0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -114,8 +114,10 @@ async function generateResponse(provider: AIProvider, prompt: string, providerTy
|
||||
}
|
||||
});
|
||||
const response = await result.response;
|
||||
const text = response.text();
|
||||
const jsonMatch = text.match(/```json\s*(\{[\s\S]*?\})\s*```/) || text.match(/(\{[\s\S]*\})/);
|
||||
return {
|
||||
text: response.text(),
|
||||
text: jsonMatch ? jsonMatch[1].trim() : text,
|
||||
tokens: response.usageMetadata?.totalTokenCount || 0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,8 +25,10 @@ async function generateResponse(provider: AIProvider, prompt: string, providerTy
|
||||
}
|
||||
});
|
||||
const response = await result.response;
|
||||
const text = response.text();
|
||||
const jsonMatch = text.match(/```json\s*(\{[\s\S]*?\})\s*```/) || text.match(/(\{[\s\S]*\})/);
|
||||
return {
|
||||
text: response.text(),
|
||||
text: jsonMatch ? jsonMatch[1].trim() : text,
|
||||
tokens: response.usageMetadata?.totalTokenCount || 0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,8 +105,10 @@ async function generateResponse(provider: AIProvider, prompt: string, providerTy
|
||||
}
|
||||
});
|
||||
const response = await result.response;
|
||||
const text = response.text();
|
||||
const jsonMatch = text.match(/```json\s*(\{[\s\S]*?\})\s*```/) || text.match(/(\{[\s\S]*\})/);
|
||||
return {
|
||||
text: response.text(),
|
||||
text: jsonMatch ? jsonMatch[1].trim() : text,
|
||||
tokens: response.usageMetadata?.totalTokenCount || 0
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user