Rename code tool arg previous_iteration_history' to context'

This commit is contained in:
Debanjum 2024-10-28 21:12:16 -07:00
parent 06aeca2670
commit d865994062
3 changed files with 10 additions and 10 deletions

View file

@ -903,10 +903,12 @@ For example:
{{"codes": ["print('Hello, World!')", "print('Goodbye, World!')"]}} {{"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. 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: Context:
{previous_iterations_history} ---
{context}
Chat History: Chat History:
---
{chat_history} {chat_history}
User: {query} User: {query}

View file

@ -28,7 +28,7 @@ SANDBOX_URL = os.getenv("KHOJ_TERRARIUM_URL", "http://localhost:8080")
async def run_code( async def run_code(
query: str, query: str,
conversation_history: dict, conversation_history: dict,
previous_iterations_history: str, context: str,
location_data: LocationData, location_data: LocationData,
user: KhojUser, user: KhojUser,
send_status_func: Optional[Callable] = None, send_status_func: Optional[Callable] = None,
@ -46,7 +46,7 @@ async def run_code(
codes = await generate_python_code( codes = await generate_python_code(
query, query,
conversation_history, conversation_history,
previous_iterations_history, context,
location_data, location_data,
user, user,
query_images, query_images,
@ -75,7 +75,7 @@ async def run_code(
async def generate_python_code( async def generate_python_code(
q: str, q: str,
conversation_history: dict, conversation_history: dict,
previous_iterations_history: str, context: str,
location_data: LocationData, location_data: LocationData,
user: KhojUser, user: KhojUser,
query_images: List[str] = None, query_images: List[str] = None,
@ -96,7 +96,7 @@ async def generate_python_code(
current_date=utc_date, current_date=utc_date,
query=q, query=q,
chat_history=chat_history, chat_history=chat_history,
previous_iterations_history=previous_iterations_history, context=context,
location=location, location=location,
username=username, username=username,
personality_context=personality_context, personality_context=personality_context,

View file

@ -986,13 +986,11 @@ async def chat(
## Gather Code Results ## Gather Code Results
if ConversationCommand.Code in conversation_commands and pending_research: if ConversationCommand.Code in conversation_commands and pending_research:
try: try:
previous_iteration_history = ( context = f"# Iteration 1:\n#---\nNotes:\n{compiled_references}\n\nOnline Results:{online_results}"
f"# Iteration 1:\n#---\nNotes:\n{compiled_references}\n\nOnline Results:{online_results}"
)
async for result in run_code( async for result in run_code(
defiltered_query, defiltered_query,
meta_log, meta_log,
previous_iteration_history, context,
location, location,
user, user,
partial(send_event, ChatEvent.STATUS), partial(send_event, ChatEvent.STATUS),