* partial * working schema builder, tested that it matches the hand-written schemas * correct another schema diff * refactor * basic working test * refactored preset creation to use yaml files * added docstring-parser * add code for dynamic function linking in agent loading * pretty schema diff printer * support pulling from ~/.memgpt/functions/*.py * clean * allow looking for system prompts in ~/.memgpt/system_prompts * create ~/.memgpt/system_prompts if it doesn't exist * pull presets from ~/.memgpt/presets in addition to examples folder * add support for loading agent configs that have additional keys --------- Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
27 lines
1009 B
Python
27 lines
1009 B
Python
import os
|
|
|
|
from memgpt.constants import MEMGPT_DIR
|
|
|
|
|
|
def get_system_text(key):
|
|
filename = f"{key}.txt"
|
|
file_path = os.path.join(os.path.dirname(__file__), "system", filename)
|
|
|
|
# first look in prompts/system/*.txt
|
|
if os.path.exists(file_path):
|
|
with open(file_path, "r") as file:
|
|
return file.read().strip()
|
|
else:
|
|
# try looking in ~/.memgpt/system_prompts/*.txt
|
|
user_system_prompts_dir = os.path.join(MEMGPT_DIR, "system_prompts")
|
|
# create directory if it doesn't exist
|
|
if not os.path.exists(user_system_prompts_dir):
|
|
os.makedirs(user_system_prompts_dir)
|
|
# look inside for a matching system prompt
|
|
file_path = os.path.join(user_system_prompts_dir, filename)
|
|
if os.path.exists(file_path):
|
|
with open(file_path, "r") as file:
|
|
return file.read().strip()
|
|
else:
|
|
raise FileNotFoundError(f"No file found for key {key}, path={file_path}")
|