From 528a6343e20b559b71ffabab602ade1a56f2659d Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Sat, 22 Feb 2025 00:28:10 +0800 Subject: [PATCH] fix: overlength gen --- jina-ai/config.json | 10 +++++----- src/agent.ts | 2 +- src/tools/dedup.ts | 2 +- src/tools/evaluator.ts | 6 +++--- src/tools/query-rewriter.ts | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/jina-ai/config.json b/jina-ai/config.json index 52ea6784..ef95a92c 100644 --- a/jina-ai/config.json +++ b/jina-ai/config.json @@ -39,15 +39,15 @@ "maxTokens": 8000 }, "tools": { - "coder": { "temperature": 0.7 }, + "coder": { "temperature": 0.7, "maxTokens": 1000 }, "searchGrounding": { "temperature": 0 }, "dedup": { "temperature": 0.1 }, - "evaluator": {}, - "errorAnalyzer": {}, - "queryRewriter": { "temperature": 0.1 }, + "evaluator": {"maxTokens": 500}, + "errorAnalyzer": {"maxTokens": 500}, + "queryRewriter": { "temperature": 0.1, "maxTokens": 500 }, "agent": { "temperature": 0.7 }, "agentBeastMode": { "temperature": 0.7 }, - "fallback": { "temperature": 0 } + "fallback": { "temperature": 0, "maxTokens": 1000} } }, "openai": { diff --git a/src/agent.ts b/src/agent.ts index 00cabe79..24cf3993 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -30,7 +30,7 @@ function getSchema(allowReflect: boolean, allowRead: boolean, allowAnswer: boole const actions: string[] = []; const properties: Record = { action: z.enum(['placeholder']), // Will update later with actual actions - think: z.string().describe(`Explain why choose this action, what's the chain-of-thought behind choosing this action, use the first-person narrative.`) + think: z.string().describe(`Explain why choose this action, what's the chain-of-thought behind choosing this action, use the first-person narrative.`).max(500) }; if (allowSearch) { diff --git a/src/tools/dedup.ts b/src/tools/dedup.ts index 9f61fb6b..5eb4b744 100644 --- a/src/tools/dedup.ts +++ b/src/tools/dedup.ts @@ -4,7 +4,7 @@ import {ObjectGeneratorSafe} from "../utils/safe-generator"; const responseSchema = z.object({ - think: z.string().describe('Strategic reasoning about the overall deduplication approach'), + think: z.string().describe('Strategic reasoning about the overall deduplication approach').max(500), unique_queries: z.array(z.string().describe('Unique query that passed the deduplication process, must be less than 30 characters')) .describe('Array of semantically unique queries').max(3) }); diff --git a/src/tools/evaluator.ts b/src/tools/evaluator.ts index e68bdfd5..5603af4a 100644 --- a/src/tools/evaluator.ts +++ b/src/tools/evaluator.ts @@ -9,7 +9,7 @@ import {ActionTracker} from "../utils/action-tracker"; const baseSchema = { pass: z.boolean().describe('Whether the answer passes the evaluation criteria defined by the evaluator'), - think: z.string().describe('Explanation the thought process why the answer does not pass the evaluation criteria') + think: z.string().describe('Explanation the thought process why the answer does not pass the evaluation criteria').max(500) }; const definitiveSchema = z.object({ @@ -263,8 +263,8 @@ Answer: ${JSON.stringify(answer)}`; const questionEvaluationSchema = z.object({ needsFreshness: z.boolean().describe('Whether the question requires freshness check'), needsPlurality: z.boolean().describe('Whether the question requires plurality check'), - think: z.string().describe('Explanation of why these checks are needed or not needed'), - languageStyle: z.string().describe('The language being used and the overall vibe/mood of the question'), + think: z.string().describe('Explanation of why these checks are needed').max(500), + languageStyle: z.string().describe('The language being used and the overall vibe/mood of the question').max(50), }); function getQuestionEvaluationPrompt(question: string): string { diff --git a/src/tools/query-rewriter.ts b/src/tools/query-rewriter.ts index aa48dd4f..5584b23e 100644 --- a/src/tools/query-rewriter.ts +++ b/src/tools/query-rewriter.ts @@ -5,7 +5,7 @@ import {ObjectGeneratorSafe} from "../utils/safe-generator"; const responseSchema = z.object({ - think: z.string().describe('Strategic reasoning about query complexity and search approach'), + think: z.string().describe('Strategic reasoning about query complexity and search approach').max(500), queries: z.array(z.string().describe('keyword-based search query, 2-3 words preferred, total length < 30 characters')) .min(1) .max(3)