chore: fix lint

This commit is contained in:
Yanlong Wang 2025-09-15 12:47:13 +08:00
parent 58af7eb3a8
commit 5e0363e5ce
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37
24 changed files with 28 additions and 26 deletions

View File

@ -14,7 +14,7 @@ module.exports = {
sourceType: 'module'
},
rules: {
'no-console': ['error', { allow: ['log', 'error'] }],
'no-console': ['error', { allow: ['log', 'error', 'warn'] }],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'off'
},

View File

@ -46,7 +46,6 @@ import { finalizeAnswer } from "./tools/finalizer";
import { buildImageReferences, buildReferences } from "./tools/build-ref";
import { logInfo, logError, logDebug, logWarning } from './logging';
import { researchPlan } from './tools/research-planner';
import { reduceAnswers } from './tools/reducer';
import { AxiosError } from 'axios';
import { dedupImagesWithEmbeddings, filterImages } from './utils/image-tools';
import { serpCluster } from './tools/serp-cluster';
@ -304,10 +303,11 @@ async function executeSearchQueries(
logDebug('Search query:', { query });
switch (searchProvider || SEARCH_PROVIDER) {
case 'jina':
case 'arxiv':
case 'arxiv': {
const num = meta ? undefined : 30;
results = (await search(query, searchProvider, num, meta, context.tokenTracker)).response.results || [];
break;
}
case 'duck':
results = (await duckSearch(query.q, { safeSearch: SafeSearchType.STRICT })).results;
break;

View File

@ -15,7 +15,7 @@ import { ActionTracker } from "./utils/action-tracker";
import { ObjectGeneratorSafe } from "./utils/safe-generator";
import { jsonSchema } from "ai"; // or another converter library
import { normalizeHostName } from "./utils/url-tools";
import { logInfo, logError, logDebug, logWarning } from './logging';
import { logInfo, logError, logDebug } from './logging';
import { body, validationResult } from 'express-validator';
const app = express();

View File

@ -2,7 +2,7 @@
import { Command } from 'commander';
import { getResponse } from './agent';
import { version } from '../package.json';
import { logInfo, logError, logDebug, logWarning } from './logging';
import { logInfo, logError } from './logging';
const program = new Command();

View File

@ -3,7 +3,7 @@ import { ProxyAgent, setGlobalDispatcher } from 'undici';
import { createGoogleGenerativeAI } from '@ai-sdk/google';
import { createOpenAI, OpenAIProviderSettings } from '@ai-sdk/openai';
import configJson from '../config.json';
import { logInfo, logError, logDebug, logWarning } from './logging';
import { logInfo, logError } from './logging';
// Load environment variables
dotenv.config();

View File

@ -7,7 +7,7 @@ import { GEMINI_API_KEY } from '../config';
import { z } from 'zod';
import { AnswerAction, TrackerContext } from "../types";
import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logInfo, logError } from '../logging';
const execAsync = promisify(exec);

View File

@ -1,6 +1,6 @@
import { BRAVE_API_KEY } from "../config";
import axiosClient from "../utils/axios-client";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logInfo } from '../logging';
import { BraveSearchResponse } from '../types';

View File

@ -2,7 +2,7 @@ import { generateText } from "ai";
import { getModel } from "../config";
import { TrackerContext } from "../types";
import { detectBrokenUnicodeViaFileIO } from "../utils/text-tools";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logError, logDebug, logWarning } from '../logging';
/**

View File

@ -1,7 +1,7 @@
import { ObjectGeneratorSafe } from "../utils/safe-generator";
import { CodeGenResponse, PromptPair, TrackerContext } from "../types";
import { Schemas } from "../utils/schemas";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logInfo, logDebug, logWarning } from '../logging';
interface SandboxResult {

View File

@ -1,4 +1,4 @@
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logWarning } from '../logging';
export function cosineSimilarity(vecA: number[], vecB: number[]): number {
if (vecA.length !== vecB.length) {

View File

@ -149,7 +149,7 @@ async function getBatchEmbeddingsWithRetry(
}
const receivedIndices = new Set(response.data.data.map(item => item.index));
const dimensionSize = response.data.data[0]?.embedding?.length || options.dimensions || 1024;
// const dimensionSize = response.data.data[0]?.embedding?.length || options.dimensions || 1024;
// Process successful embeddings
const successfulEmbeddings: number[][] = [];

View File

@ -1,7 +1,7 @@
import { ErrorAnalysisResponse, PromptPair, TrackerContext } from '../types';
import { ObjectGeneratorSafe } from "../utils/safe-generator";
import { Schemas } from "../utils/schemas";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logInfo, logError } from '../logging';
function getPrompt(diaryContext: string[]): PromptPair {

View File

@ -3,7 +3,7 @@ import { AnswerAction, EvaluationResponse, EvaluationType, KnowledgeItem, Prompt
import { ObjectGeneratorSafe } from "../utils/safe-generator";
import { Schemas } from "../utils/schemas";
import { getKnowledgeStr } from "../utils/text-tools";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logInfo, logError } from '../logging';
const TOOL_NAME = 'evaluator';

View File

@ -1,4 +1,4 @@
import { logDebug, logError, logInfo } from "../logging";
import { logError, logInfo } from "../logging";
import { TokenTracker } from "../utils/token-tracker";
import { cosineSimilarity } from "./cosine";
import { getEmbeddings } from "./embeddings";

View File

@ -1,7 +1,7 @@
import { TokenTracker } from "../utils/token-tracker";
import { JINA_API_KEY } from "../config";
import axiosClient from '../utils/axios-client';
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logError, logDebug } from '../logging';
const JINA_API_URL = 'https://api.jina.ai/v1/rerank';

View File

@ -1,7 +1,7 @@
import { PromptPair, SearchAction, SERPQuery, TrackerContext } from '../types';
import { ObjectGeneratorSafe } from "../utils/safe-generator";
import { Schemas } from "../utils/schemas";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logInfo, logError } from '../logging';
function getPrompt(query: string, think: string, context: string): PromptPair {

View File

@ -63,6 +63,7 @@ export async function readUrl(
return { response: data };
} catch (error: any) {
logDebug(`Read error: ${error.message}`);
throw error;
}
}

View File

@ -22,19 +22,21 @@ export function chunkText(text: string, options: ChunkOptions = {}): {
chunks = text.split(/(?<=[.!?。!?])/).filter(chunk => chunk.trim().length > 0);
break;
case 'characters':
case 'characters': {
const chunkSize = Number(options.value) || 1000;
for (let i = 0; i < text.length; i += chunkSize) {
chunks.push(text.slice(i, i + chunkSize));
}
break;
}
case 'regex':
case 'regex': {
if (!options.value || typeof options.value !== 'string') {
throw new Error('Regex pattern is required for regex chunking');
}
chunks = text.split(new RegExp(options.value)).filter(chunk => chunk.trim().length > 0);
break;
}
default:
throw new Error('Invalid chunking type');

View File

@ -1,6 +1,5 @@
import { SERPER_API_KEY } from "../config";
import axiosClient from "../utils/axios-client";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { SerperSearchResponse, SERPQuery } from '../types';

View File

@ -1,5 +1,5 @@
import axios, { AxiosRequestConfig } from 'axios';
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logError } from '../logging';
// Default timeout in milliseconds
const DEFAULT_TIMEOUT = 30000;

View File

@ -2,7 +2,7 @@ import { getEmbeddings } from '../tools/embeddings';
import { TokenTracker } from './token-tracker';
import { ImageObject, ImageReference } from '../types';
import { cosineSimilarity } from '../tools/cosine';
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logInfo, logError, logWarning } from '../logging';
import sharp from 'sharp';
export const downloadFile = async (uri: string) => {

View File

@ -2,7 +2,7 @@ import { AnswerAction, KnowledgeItem, Reference } from "../types";
import i18nJSON from './i18n.json';
import { JSDOM } from 'jsdom';
import fs from "fs/promises";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logError } from '../logging';
export function buildMdFromAnswer(answer: AnswerAction): string {
@ -916,7 +916,7 @@ export function extractNgrams(
// Second pass: calculate PMI and filter
const results: NgramResult[] = Array.from(ngramFreq.entries())
.filter(([ngram, freq]) => freq >= minFreq)
.filter(([, freq]) => freq >= minFreq)
.map(([ngram, freq]) => {
const pmi = isCJKText(ngram) ? 0 : calculatePMI(ngram, freq, wordFreq, totalNgrams);
return { ngram, freq, pmi };

View File

@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
import { TokenUsage } from '../types';
import { LanguageModelUsage } from "ai";
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logInfo } from '../logging';
export class TokenTracker extends EventEmitter {
private usages: TokenUsage[] = [];

View File

@ -562,7 +562,7 @@ export async function processURLs(
// Process images
if (withImages && data.images) {
const imageEntries = Object.entries(data.images || {});
imageEntries.forEach(async ([alt, url]) => {
imageEntries.forEach(async ([, url]) => {
const imageObject = await processImage(url, context.tokenTracker);
if (imageObject && !imageObjects.find(i => i.url === imageObject.url)) {
imageObjects.push(imageObject);