Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

Merge branch 'main' into gpt35-patch

Charles Packer3c3a5ae0e2d0
diff --cc main.py
index 46e3618c4,5b41b20e2..585fa5192
--- a/main.py
+++ b/main.py
@@@ -16,11 -18,11 +18,11 @@@ import memgpt.presets as preset
import memgpt.constants as constants
import memgpt.personas.personas as personas
import memgpt.humans.humans as humans
- from memgpt.persistence_manager import InMemoryStateManager as persistence_manager
+ from memgpt.persistence_manager import InMemoryStateManager, InMemoryStateManagerWithPreloadedArchivalMemory, InMemoryStateManagerWithFaiss
FLAGS = flags.FLAGS
-flags.DEFINE_string("persona", default=personas.DEFAULT, required=False, help="Specify persona")
-flags.DEFINE_string("human", default=humans.DEFAULT, required=False, help="Specify human")
+flags.DEFINE_string("persona", default=None, required=False, help="Specify persona")
+flags.DEFINE_string("human", default=None, required=False, help="Specify human")
flags.DEFINE_string("model", default=constants.DEFAULT_MEMGPT_MODEL, required=False, help="Specify the LLM model")
flags.DEFINE_boolean("first", default=False, required=False, help="Use -first to send the first message in the sequence")
flags.DEFINE_boolean("debug", default=False, required=False, help="Use -debug to enable debugging output")
@@@ -41,16 -46,23 +46,31 @@@ async def main()
logging.getLogger().setLevel(logging.CRITICAL)
if FLAGS.debug:
logging.getLogger().setLevel(logging.DEBUG)
- print("Running... [exit by typing 'exit']")
-
+ print("Running... [exit by typing '/exit']")
++
+ if FLAGS.model != constants.DEFAULT_MEMGPT_MODEL:
- print(f"Warning - you are running MemGPT with {FLAGS.model}, which is not officially supported (yet). Expect bugs!")
++ print(f"Warning - you are running MemGPT with {FLAGS.model}, which is not officially supported (yet). Expect bugs!")
+
+ if FLAGS.archival_storage_faiss_path:
+ index, archival_database = utils.prepare_archival_index(FLAGS.archival_storage_faiss_path)
+ persistence_manager = InMemoryStateManagerWithFaiss(index, archival_database)
+ elif FLAGS.archival_storage_files:
+ archival_database = utils.prepare_archival_index_from_files(FLAGS.archival_storage_files)
+ print(f"Preloaded {len(archival_database)} chunks into archival memory.")
+ persistence_manager = InMemoryStateManagerWithPreloadedArchivalMemory(archival_database)
+ elif FLAGS.archival_storage_files_compute_embeddings:
+ faiss_save_dir = await utils.prepare_archival_index_from_files_compute_embeddings(FLAGS.archival_storage_files_compute_embeddings)
+ interface.important_message(f"To avoid computing embeddings next time, replace --archival_storage_files_compute_embeddings={FLAGS.archival_storage_files_compute_embeddings} with\n\t --archival_storage_faiss_path={faiss_save_dir} (if your files haven't changed).")
+ index, archival_database = utils.prepare_archival_index(faiss_save_dir)
+ persistence_manager = InMemoryStateManagerWithFaiss(index, archival_database)
+ else:
+ persistence_manager = InMemoryStateManager()
+
+ # Moved defaults out of FLAGS so that we can dynamically select the default persona based on model
+ chosen_human = FLAGS.human if FLAGS.human is not None else humans.DEFAULT
+ chosen_persona = FLAGS.persona if FLAGS.persona is not None else (personas.GPT35_DEFAULT if 'gpt-3.5' in flags.MODEL else personas.DEFAULT)
+
- memgpt_agent = presets.use_preset(presets.DEFAULT, FLAGS.model, personas.get_persona_text(chosen_persona), humans.get_human_text(chosen_human), interface, persistence_manager())
+ memgpt_agent = presets.use_preset(presets.DEFAULT, FLAGS.model, personas.get_persona_text(FLAGS.persona), humans.get_human_text(FLAGS.human), interface, persistence_manager)
print_messages = interface.print_messages
await print_messages(memgpt_agent.messages)
diff --cc memgpt/personas/personas.py
index a0d1ffb56,1013f8ff4..0d1a89db6
--- a/memgpt/personas/personas.py
+++ b/memgpt/personas/personas.py
@@@ -1,7 -1,6 +1,7 @@@
import os
- DEFAULT = 'sam'
+ DEFAULT = 'sam_pov'
+GPT35_DEFAULT = 'sam_simple_pov_gpt35'
def get_persona_text(key=DEFAULT):