From 931f555cf80a459ff5e2fc3cb358d697f7a664db Mon Sep 17 00:00:00 2001 From: Debanjum Date: Tue, 18 Mar 2025 17:01:14 +0530 Subject: [PATCH] Configure max allowed iterations in research mode via env var --- .github/workflows/run_evals.yml | 6 ++++++ src/khoj/routers/research.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_evals.yml b/.github/workflows/run_evals.yml index 2c8e9688..11d86370 100644 --- a/.github/workflows/run_evals.yml +++ b/.github/workflows/run_evals.yml @@ -45,6 +45,11 @@ on: required: false default: 'gemini-2.0-flash' type: string + max_research_iterations: + description: 'Maximum number of iterations in research mode' + required: false + default: 5 + type: number jobs: eval: @@ -110,6 +115,7 @@ jobs: KHOJ_URL: "http://localhost:42110" KHOJ_DEFAULT_CHAT_MODEL: ${{ github.event_name == 'workflow_dispatch' && inputs.chat_model || 'gemini-2.0-flash' }} KHOJ_LLM_SEED: "42" + KHOJ_RESEARCH_ITERATIONS: ${{ github.event_name == 'workflow_dispatch' && inputs.max_research_iterations || 5 }} GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} SERPER_DEV_API_KEY: ${{ matrix.dataset != 'math500' && secrets.SERPER_DEV_API_KEY }} OLOSTEP_API_KEY: ${{ matrix.dataset != 'math500' && secrets.OLOSTEP_API_KEY }} diff --git a/src/khoj/routers/research.py b/src/khoj/routers/research.py index e040c928..07a66002 100644 --- a/src/khoj/routers/research.py +++ b/src/khoj/routers/research.py @@ -1,4 +1,5 @@ import logging +import os from datetime import datetime from typing import Callable, Dict, List, Optional @@ -160,7 +161,7 @@ async def execute_information_collection( query_files: str = None, ): current_iteration = 0 - MAX_ITERATIONS = 5 + MAX_ITERATIONS = int(os.getenv("KHOJ_RESEARCH_ITERATIONS", 5)) previous_iterations: List[InformationCollectionIteration] = [] while current_iteration < MAX_ITERATIONS: online_results: Dict = dict()