From d865994062956fb3ed9585fa121a07438859d797 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Mon, 28 Oct 2024 21:12:16 -0700 Subject: [PATCH] Rename code tool arg `previous_iteration_history' to `context' --- src/khoj/processor/conversation/prompts.py | 6 ++++-- src/khoj/processor/tools/run_code.py | 8 ++++---- src/khoj/routers/api_chat.py | 6 ++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/khoj/processor/conversation/prompts.py b/src/khoj/processor/conversation/prompts.py index 97b8eaa5..ae97f610 100644 --- a/src/khoj/processor/conversation/prompts.py +++ b/src/khoj/processor/conversation/prompts.py @@ -903,10 +903,12 @@ For example: {{"codes": ["print('Hello, World!')", "print('Goodbye, World!')"]}} Now it's your turn to construct python programs to answer the user's question. Provide them as a list of strings in a JSON object. Do not say anything else. -Data from Previous Iterations: -{previous_iterations_history} +Context: +--- +{context} Chat History: +--- {chat_history} User: {query} diff --git a/src/khoj/processor/tools/run_code.py b/src/khoj/processor/tools/run_code.py index 40e157ff..27801390 100644 --- a/src/khoj/processor/tools/run_code.py +++ b/src/khoj/processor/tools/run_code.py @@ -28,7 +28,7 @@ SANDBOX_URL = os.getenv("KHOJ_TERRARIUM_URL", "http://localhost:8080") async def run_code( query: str, conversation_history: dict, - previous_iterations_history: str, + context: str, location_data: LocationData, user: KhojUser, send_status_func: Optional[Callable] = None, @@ -46,7 +46,7 @@ async def run_code( codes = await generate_python_code( query, conversation_history, - previous_iterations_history, + context, location_data, user, query_images, @@ -75,7 +75,7 @@ async def run_code( async def generate_python_code( q: str, conversation_history: dict, - previous_iterations_history: str, + context: str, location_data: LocationData, user: KhojUser, query_images: List[str] = None, @@ -96,7 +96,7 @@ async def generate_python_code( current_date=utc_date, query=q, chat_history=chat_history, - previous_iterations_history=previous_iterations_history, + context=context, location=location, username=username, personality_context=personality_context, diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index 6cf4df7c..e9d60a1b 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -986,13 +986,11 @@ async def chat( ## Gather Code Results if ConversationCommand.Code in conversation_commands and pending_research: try: - previous_iteration_history = ( - f"# Iteration 1:\n#---\nNotes:\n{compiled_references}\n\nOnline Results:{online_results}" - ) + context = f"# Iteration 1:\n#---\nNotes:\n{compiled_references}\n\nOnline Results:{online_results}" async for result in run_code( defiltered_query, meta_log, - previous_iteration_history, + context, location, user, partial(send_event, ChatEvent.STATUS),