From 048ca5dec7a331fc46947c70aed5efe0a553e55e Mon Sep 17 00:00:00 2001 From: Torantulino Date: Wed, 29 Mar 2023 00:17:44 +0100 Subject: [PATCH] Turns of debug print. Full context is no longer printed to console each time, now optional for debugging. --- AutonomousAI/main.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/AutonomousAI/main.py b/AutonomousAI/main.py index e3220ecc..4ddce1ba 100644 --- a/AutonomousAI/main.py +++ b/AutonomousAI/main.py @@ -25,7 +25,7 @@ def create_chat_message(role, content): """ return {"role": role, "content": content} -def chat_with_ai(prompt, user_input, full_message_history, permanent_memory, token_limit): +def chat_with_ai(prompt, user_input, full_message_history, permanent_memory, token_limit, debug = False): """ Interact with the OpenAI API, sending the prompt, user input, message history, and permanent memory. @@ -44,13 +44,14 @@ def chat_with_ai(prompt, user_input, full_message_history, permanent_memory, tok current_context.extend([create_chat_message("user", user_input)]) # Debug print the current context - print("---------------------------") - print("Current Context:") - for message in current_context: - # Skip printing the prompt - if message["role"] == "system" and message["content"] == prompt: - continue - print(f"{message['role'].capitalize()}: {message['content']}") + if debug: + print("------------ CONTEXT SENT TO AI ---------------") + for message in current_context: + # Skip printing the prompt + if message["role"] == "system" and message["content"] == prompt: + continue + print(f"{message['role'].capitalize()}: {message['content']}") + print("----------- END OF CONTEXT ----------------") response = openai.ChatCompletion.create( model="gpt-4",