fix: misc fixes (#700)

* add folder generation

* disable default temp until more testing is done

* apply embedding payload patch to search, add input checking for better runtime error messages

* streamlined memory pressure warning now that heartbeats get forced
This commit is contained in:
Charles Packer
2023-12-25 01:29:13 -08:00
committed by GitHub
parent e758c75e81
commit 3ec8bb1465
4 changed files with 26 additions and 3 deletions

View File

@@ -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))

View File

@@ -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

View File

@@ -24,5 +24,5 @@ settings = {
" }\n}\n",
],
# most lm frontends default to 0.7-0.8 these days
"temperature": 0.8,
# "temperature": 0.8,
}

View File

@@ -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)