diff --git a/memgpt/config.py b/memgpt/config.py index 85a92b92..10d01095 100644 --- a/memgpt/config.py +++ b/memgpt/config.py @@ -216,7 +216,7 @@ class MemGPTConfig: if not os.path.exists(MEMGPT_DIR): os.makedirs(MEMGPT_DIR, exist_ok=True) - folders = ["personas", "humans", "archival", "agents", "functions", "system_prompts", "presets"] + folders = ["personas", "humans", "archival", "agents", "functions", "system_prompts", "presets", "settings"] for folder in folders: if not os.path.exists(os.path.join(MEMGPT_DIR, folder)): os.makedirs(os.path.join(MEMGPT_DIR, folder)) diff --git a/memgpt/constants.py b/memgpt/constants.py index 165a6437..6a66710b 100644 --- a/memgpt/constants.py +++ b/memgpt/constants.py @@ -47,7 +47,14 @@ MESSAGE_SUMMARY_WARNING_FRAC = 0.75 # The error message that MemGPT will receive # MESSAGE_SUMMARY_WARNING_STR = f"Warning: the conversation history will soon reach its maximum length and be trimmed. Make sure to save any important information from the conversation to your memory before it is removed." # Much longer and more specific variant of the prompt -MESSAGE_SUMMARY_WARNING_STR = f"{NON_USER_MSG_PREFIX}The conversation history will soon reach its maximum length and be trimmed. If there is any important new information or general memories about you or the user that you would like to save, you should save that information immediately by calling function core_memory_append, core_memory_replace, or archival_memory_insert (remember to pass request_heartbeat = true if you would like to send a message immediately after)." +MESSAGE_SUMMARY_WARNING_STR = " ".join( + [ + f"{NON_USER_MSG_PREFIX}The conversation history will soon reach its maximum length and be trimmed.", + "Do NOT tell the user about this system alert, they should not know that the history is reaching max length.", + "If there is any important new information or general memories about you or the user that you would like to save, you should save that information immediately by calling function core_memory_append, core_memory_replace, or archival_memory_insert.", + # "Remember to pass request_heartbeat = true if you would like to send a message immediately after.", + ] +) # The fraction of tokens we truncate down to MESSAGE_SUMMARY_TRUNC_TOKEN_FRAC = 0.75 diff --git a/memgpt/local_llm/settings/simple.py b/memgpt/local_llm/settings/simple.py index c0dbf7ba..3a788f59 100644 --- a/memgpt/local_llm/settings/simple.py +++ b/memgpt/local_llm/settings/simple.py @@ -24,5 +24,5 @@ settings = { " }\n}\n", ], # most lm frontends default to 0.7-0.8 these days - "temperature": 0.8, + # "temperature": 0.8, } diff --git a/memgpt/memory.py b/memgpt/memory.py index 5c0f7d79..b851895c 100644 --- a/memgpt/memory.py +++ b/memgpt/memory.py @@ -329,6 +329,9 @@ class EmbeddingArchivalMemory(ArchivalMemory): """Embed and save memory string""" from memgpt.connectors.storage import Passage + if not isinstance(memory_string, str): + return TypeError("memory must be a string") + try: passages = [] @@ -359,10 +362,23 @@ class EmbeddingArchivalMemory(ArchivalMemory): def search(self, query_string, count=None, start=None): """Search query string""" + if not isinstance(query_string, str): + return TypeError("query must be a string") + try: if query_string not in self.cache: # self.cache[query_string] = self.retriever.retrieve(query_string) query_vec = self.embed_model.get_text_embedding(query_string) + # fixing weird bug where type returned isn't a list, but instead is an object + # eg: embedding={'object': 'list', 'data': [{'object': 'embedding', 'embedding': [-0.0071973633, -0.07893023, + if isinstance(query_vec, dict): + try: + query_vec = query_vec["data"][0]["embedding"] + except (KeyError, IndexError): + # TODO as a fallback, see if we can find any lists in the payload + raise TypeError( + f"Got back an unexpected payload from text embedding function, type={type(query_vec)}, value={query_vec}" + ) self.cache[query_string] = self.storage.query(query_string, query_vec, top_k=self.top_k) start = int(start if start else 0)