From dff7a444aa7ff76dc429234f0745e69bbda3430d Mon Sep 17 00:00:00 2001 From: cpacker Date: Mon, 16 Oct 2023 20:48:24 -0700 Subject: [PATCH] gpt35 adjustments --- memgpt/agent.py | 6 +++-- memgpt/presets.py | 7 ++++++ memgpt/prompts/system/memgpt_base.txt | 2 +- memgpt/prompts/system/memgpt_chat.txt | 2 +- memgpt/prompts/system/memgpt_doc.txt | 2 +- memgpt/system.py | 34 +++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 5 deletions(-) diff --git a/memgpt/agent.py b/memgpt/agent.py index 593b5e75..24493401 100644 --- a/memgpt/agent.py +++ b/memgpt/agent.py @@ -64,7 +64,8 @@ def initialize_message_sequence( first_user_message = get_login_event() # event letting MemGPT know the user just logged in if include_initial_boot_message: - initial_boot_messages = get_initial_boot_messages('startup_with_send_message') + # initial_boot_messages = get_initial_boot_messages('startup_with_send_message') + initial_boot_messages = get_initial_boot_messages('startup_with_send_message_gpt35') messages = [ {"role": "system", "content": full_system_message}, ] + initial_boot_messages + [ @@ -445,7 +446,8 @@ class AgentAsync(object): if contains_special_characters(monologue): printd(f"First message internal monologue contained special characters: {response_message}") return False - if 'functions' in monologue or 'send_message' in monologue or 'inner thought' in monologue.lower(): + # if 'functions' in monologue or 'send_message' in monologue or 'inner thought' in monologue.lower(): + if 'functions' in monologue or 'send_message' in monologue: # Sometimes the syntax won't be correct and internal syntax will leak into message.context printd(f"First message internal monologue contained reserved words: {response_message}") return False diff --git a/memgpt/presets.py b/memgpt/presets.py index 9a65725e..a59edeae 100644 --- a/memgpt/presets.py +++ b/memgpt/presets.py @@ -22,6 +22,13 @@ def use_preset(preset_name, model, persona, human, interface, persistence_manage printd(f"Available functions:\n", [x['name'] for x in available_functions]) assert len(functions) == len(available_functions) + if 'gpt-4' not in model: + # use a simpler system message for gpt-3.5 + # preset_name = 'memgpt_gpt35_chat' + # preset_name = 'memgpt_gpt35_literal' + preset_name = 'memgpt_gpt35_extralong' + # pass + return AgentAsync( model=model, system=gpt_system.get_system_text(preset_name), diff --git a/memgpt/prompts/system/memgpt_base.txt b/memgpt/prompts/system/memgpt_base.txt index ed70a4e9..47f5f93f 100644 --- a/memgpt/prompts/system/memgpt_base.txt +++ b/memgpt/prompts/system/memgpt_base.txt @@ -29,7 +29,7 @@ Your core memory unit will be initialized with a chosen by the user, a Recall memory (ie conversation history): Even though you can only see recent messages in your immediate context, you can search over your entire message history from a database. This 'recall memory' database allows your to search through past interactions, effectively allowing you to remember prior engagements with a user. -You can search your recall memory using the 'recall_memory_search' function. +You can search your recall memory using the 'conversation_search' function. Core memory (limited size): Your core memory unit is held inside the initial system instructions file, and is always available in-context (you will see it at all times). diff --git a/memgpt/prompts/system/memgpt_chat.txt b/memgpt/prompts/system/memgpt_chat.txt index ac10264d..56658a44 100644 --- a/memgpt/prompts/system/memgpt_chat.txt +++ b/memgpt/prompts/system/memgpt_chat.txt @@ -38,7 +38,7 @@ Your core memory unit will be initialized with a chosen by the user, a Recall memory (ie conversation history): Even though you can only see recent messages in your immediate context, you can search over your entire message history from a database. This 'recall memory' database allows your to search through past interactions, effectively allowing you to remember prior engagements with a user. -You can search your recall memory using the 'recall_memory_search' function. +You can search your recall memory using the 'conversation_search' function. Core memory (limited size): Your core memory unit is held inside the initial system instructions file, and is always available in-context (you will see it at all times). diff --git a/memgpt/prompts/system/memgpt_doc.txt b/memgpt/prompts/system/memgpt_doc.txt index a33ad034..237c4a35 100644 --- a/memgpt/prompts/system/memgpt_doc.txt +++ b/memgpt/prompts/system/memgpt_doc.txt @@ -30,7 +30,7 @@ Your core memory unit will be initialized with a chosen by the user, a Recall memory (ie conversation history): Even though you can only see recent messages in your immediate context, you can search over your entire message history from a database. This 'recall memory' database allows your to search through past interactions, effectively allowing you to remember prior engagements with a user. -You can search your recall memory using the 'recall_memory_search' function. +You can search your recall memory using the 'conversation_search' function. Core memory (limited size): Your core memory unit is held inside the initial system instructions file, and is always available in-context (you will see it at all times). diff --git a/memgpt/system.py b/memgpt/system.py index 98d9988b..2dc93a09 100644 --- a/memgpt/system.py +++ b/memgpt/system.py @@ -23,12 +23,46 @@ def get_initial_boot_messages(version='startup'): "arguments": "{\n \"message\": \"" + f"{INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG}" + "\"\n}" } }, + # obligatory function return message { "role": "function", "name": "send_message", "content": package_function_response(True, None) } + ] + + elif version == 'startup_with_send_message_gpt35': + messages = [ + # first message includes both inner monologue and function call to send_message + # { + # "role": "assistant", + # "content": INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT, + # "function_call": { + # "name": "send_message", + # "arguments": "{\n \"message\": \"" + f"{INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG}" + "\"\n}" + # } + # }, + # # obligatory function return message + # { + # "role": "function", + # "name": "send_message", + # "content": package_function_response(True, None) + # }, + # first message includes both inner monologue and function call to send_message + { + "role": "assistant", + "content": "*inner thoughts* Still waiting on the user. Sending a message with function.", + "function_call": { + "name": "send_message", + "arguments": "{\n \"message\": \"" + f"Hi, is anyone there?" + "\"\n}" + } + }, # obligatory function return message + { + "role": "function", + "name": "send_message", + "content": package_function_response(True, None) + } ] else: