mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
removed code that linter was mad about
This commit is contained in:
parent
1eb73a1413
commit
226825d630
@ -1,14 +1,12 @@
|
|||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import {exec} from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import {promisify} from 'util';
|
import { promisify } from 'util';
|
||||||
import {getResponse} from '../agent';
|
import { getResponse } from '../agent';
|
||||||
import {generateObject} from 'ai';
|
import { generateObject } from 'ai';
|
||||||
import {GEMINI_API_KEY} from '../config';
|
import { GEMINI_API_KEY } from '../config';
|
||||||
import {z} from 'zod';
|
import { z } from 'zod';
|
||||||
import {AnswerAction, TrackerContext} from "../types";
|
import { AnswerAction, TrackerContext } from "../types";
|
||||||
import {createGoogleGenerativeAI} from "@ai-sdk/google";
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
||||||
import {TokenTracker} from "../utils/token-tracker";
|
|
||||||
import {ActionTracker} from "../utils/action-tracker";
|
|
||||||
|
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
|
|
||||||
@ -86,7 +84,7 @@ function printStats(stats: EvaluationStats): void {
|
|||||||
|
|
||||||
async function getCurrentGitCommit(): Promise<string> {
|
async function getCurrentGitCommit(): Promise<string> {
|
||||||
try {
|
try {
|
||||||
const {stdout} = await execAsync('git rev-parse --short HEAD');
|
const { stdout } = await execAsync('git rev-parse --short HEAD');
|
||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error getting git commit:', error);
|
console.error('Error getting git commit:', error);
|
||||||
@ -136,7 +134,7 @@ async function batchEvaluate(inputFile: string): Promise<void> {
|
|||||||
|
|
||||||
// Process each question
|
// Process each question
|
||||||
for (let i = 0; i < questions.length; i++) {
|
for (let i = 0; i < questions.length; i++) {
|
||||||
const {question, answer: expectedAnswer} = questions[i];
|
const { question, answer: expectedAnswer } = questions[i];
|
||||||
console.log(`\nProcessing question ${i + 1}/${questions.length}: ${question}`);
|
console.log(`\nProcessing question ${i + 1}/${questions.length}: ${question}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -146,12 +144,6 @@ async function batchEvaluate(inputFile: string): Promise<void> {
|
|||||||
context
|
context
|
||||||
} = await getResponse(question) as { result: AnswerAction; context: TrackerContext };
|
} = await getResponse(question) as { result: AnswerAction; context: TrackerContext };
|
||||||
|
|
||||||
// Get response using the streaming agent
|
|
||||||
// const {
|
|
||||||
// result: response,
|
|
||||||
// context
|
|
||||||
// } = await getResponseStreamingAgent(question) as { result: AnswerAction; context: TrackerContext };
|
|
||||||
|
|
||||||
const actualAnswer = response.answer;
|
const actualAnswer = response.answer;
|
||||||
|
|
||||||
// Evaluate the response
|
// Evaluate the response
|
||||||
@ -184,27 +176,6 @@ async function batchEvaluate(inputFile: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getResponseStreamingAgent(query: string) {
|
|
||||||
const res = await fetch("http://localhost:3000/chat", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {"Content-Type": "application/json"},
|
|
||||||
body: JSON.stringify({query})
|
|
||||||
})
|
|
||||||
const text = await res.text()
|
|
||||||
return {
|
|
||||||
result: {
|
|
||||||
think: '',
|
|
||||||
action: 'answer',
|
|
||||||
answer: text.split("RESPONSE_START")[1].split("RESPONSE_END")[0].trim(),
|
|
||||||
references: []
|
|
||||||
},
|
|
||||||
context: {
|
|
||||||
tokenTracker: new TokenTracker(),
|
|
||||||
actionTracker: new ActionTracker()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate and print statistics
|
// Calculate and print statistics
|
||||||
const stats = calculateStats(results, modelName);
|
const stats = calculateStats(results, modelName);
|
||||||
printStats(stats);
|
printStats(stats);
|
||||||
@ -229,4 +200,4 @@ if (require.main === module) {
|
|||||||
batchEvaluate(inputFile).catch(console.error);
|
batchEvaluate(inputFile).catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
export {batchEvaluate};
|
export { batchEvaluate };
|
||||||
Loading…
x
Reference in New Issue
Block a user