Configure max allowed iterations in research mode via env var

This commit is contained in:
Debanjum
2025-03-18 17:01:14 +05:30
parent 2ab8e711d3
commit 931f555cf8
2 changed files with 8 additions and 1 deletions

View File

@@ -45,6 +45,11 @@ on:
required: false required: false
default: 'gemini-2.0-flash' default: 'gemini-2.0-flash'
type: string type: string
max_research_iterations:
description: 'Maximum number of iterations in research mode'
required: false
default: 5
type: number
jobs: jobs:
eval: eval:
@@ -110,6 +115,7 @@ jobs:
KHOJ_URL: "http://localhost:42110" KHOJ_URL: "http://localhost:42110"
KHOJ_DEFAULT_CHAT_MODEL: ${{ github.event_name == 'workflow_dispatch' && inputs.chat_model || 'gemini-2.0-flash' }} KHOJ_DEFAULT_CHAT_MODEL: ${{ github.event_name == 'workflow_dispatch' && inputs.chat_model || 'gemini-2.0-flash' }}
KHOJ_LLM_SEED: "42" KHOJ_LLM_SEED: "42"
KHOJ_RESEARCH_ITERATIONS: ${{ github.event_name == 'workflow_dispatch' && inputs.max_research_iterations || 5 }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
SERPER_DEV_API_KEY: ${{ matrix.dataset != 'math500' && secrets.SERPER_DEV_API_KEY }} SERPER_DEV_API_KEY: ${{ matrix.dataset != 'math500' && secrets.SERPER_DEV_API_KEY }}
OLOSTEP_API_KEY: ${{ matrix.dataset != 'math500' && secrets.OLOSTEP_API_KEY }} OLOSTEP_API_KEY: ${{ matrix.dataset != 'math500' && secrets.OLOSTEP_API_KEY }}

View File

@@ -1,4 +1,5 @@
import logging import logging
import os
from datetime import datetime from datetime import datetime
from typing import Callable, Dict, List, Optional from typing import Callable, Dict, List, Optional
@@ -160,7 +161,7 @@ async def execute_information_collection(
query_files: str = None, query_files: str = None,
): ):
current_iteration = 0 current_iteration = 0
MAX_ITERATIONS = 5 MAX_ITERATIONS = int(os.getenv("KHOJ_RESEARCH_ITERATIONS", 5))
previous_iterations: List[InformationCollectionIteration] = [] previous_iterations: List[InformationCollectionIteration] = []
while current_iteration < MAX_ITERATIONS: while current_iteration < MAX_ITERATIONS:
online_results: Dict = dict() online_results: Dict = dict()