From c514da353d2173d4e5ac68cb41143b565e4fd4eb Mon Sep 17 00:00:00 2001 From: Dillon Laird Date: Tue, 15 Oct 2024 18:55:01 -0700 Subject: [PATCH] limit context length and amount of debugging VA does --- vision_agent/agent/vision_agent.py | 3 ++- vision_agent/agent/vision_agent_prompts.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/vision_agent/agent/vision_agent.py b/vision_agent/agent/vision_agent.py index b302c366..64a8ff49 100644 --- a/vision_agent/agent/vision_agent.py +++ b/vision_agent/agent/vision_agent.py @@ -98,8 +98,9 @@ def _clean_response(response: str) -> str: def run_conversation(orch: LMM, chat: List[Message]) -> Dict[str, Any]: chat = copy.deepcopy(chat) + # only add 10 most recent messages in the chat to not go over token limit conversation = "" - for chat_i in chat: + for chat_i in chat[-10:]: if chat_i["role"] == "user": conversation += f"USER: {chat_i['content']}\n\n" elif chat_i["role"] == "observation": diff --git a/vision_agent/agent/vision_agent_prompts.py b/vision_agent/agent/vision_agent_prompts.py index 66d6614e..228cb592 100644 --- a/vision_agent/agent/vision_agent_prompts.py +++ b/vision_agent/agent/vision_agent_prompts.py @@ -1,7 +1,7 @@ VA_CODE = """ **Role**: You are a helpful agent that assists users with writing code. -**Taks**: As a conversational agent, you are required to understand the user's request and provide a helpful response. Use a Chain-of-Thought approach to break down the problem, create a plan, and then provide a response. Ensure that your response is clear, concise, and helpful. You can use an interactive Python (Jupyter Notebook) environment, executing code with . You are given access to an `artifacts` object which contains files shared between you and the user. `artifacts` will be automatically saved only AFTER you execute python code. +**Taks**: As a conversational agent, you are required to understand the user's request and provide a helpful response. Use a Chain-of-Thought approach to break down the problem, create a plan, and then provide a response. Ensure that your response is clear, concise, and helpful. You can use an interactive Python (Jupyter Notebook) environment, executing code with . You are given access to an `artifacts` object which contains files shared between you and the user. `artifacts` will be automatically saved only AFTER you execute python code. The user can see all `artifacts`. print("Hello World!") @@ -26,11 +26,11 @@ **Instructions**: 1. **Understand and Clarify**: Make sure you understand the task, ask clarifying questions if the task is not clear. -2. **Code Generation**: Only use code provided in the Documentation in your tags. Only use `edit_vision_code` to modify code written by `generate_vision_code`. +2. **Code Generation**: Only use code provided in the Documentation in your tags. Only use `edit_vision_code` to modify code written by `generate_vision_code`. DO NOT run `edit_vision_code` or `edit_code_artifact` more than 2 times in a row and instead ask the user for help. 3. **Execute**: Do only what the user asked you to do and no more. If you need to ask the user a question or show your results to the user, set to `true`. 4. **Artifacts**: Files are only saved in `artifacts` after , do not try to access artifacts until you observe that they are loaded. -4. **Response**: Keep your responses short and concise. Provide the user only with the information they need to continue the conversation. -5. **Output**: You can only respond with , , , and tags. +5. **Response**: Keep your responses short and concise. Provide the user only with the information they need to continue the conversation. +6. **Output**: You can only respond with , , , and tags. Your thoughts here... Your response to the user here...