Skip to content

Commit

Permalink
add core memory char limits to text shown in core memory (#508)
Browse files Browse the repository at this point in the history
* add core memory char limits to text shown in core memory

* include char limit in xml tag

* add flag to allow reverting to old version
  • Loading branch information
cpacker authored Nov 27, 2023
1 parent 4218801 commit 8bfda56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions memgpt/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ def initialize_memory(ai_notes, human_notes):
return memory


def construct_system_with_memory(system, memory, memory_edit_timestamp, archival_memory=None, recall_memory=None):
def construct_system_with_memory(system, memory, memory_edit_timestamp, archival_memory=None, recall_memory=None, include_char_count=True):
full_system_message = "\n".join(
[
system,
"\n",
f"### Memory [last modified: {memory_edit_timestamp}]",
f"### Memory [last modified: {memory_edit_timestamp.strip()}]",
f"{len(recall_memory) if recall_memory else 0} previous messages between you and the user are stored in recall memory (use functions to access them)",
f"{len(archival_memory) if archival_memory else 0} total memories you created are stored in archival memory (use functions to access them)",
"\nCore memory shown below (limited in size, additional information stored in archival / recall memory):",
"<persona>",
f'<persona characters="{len(memory.persona)}/{memory.persona_char_limit}">' if include_char_count else "<persona>",
memory.persona,
"</persona>",
"<human>",
f'<human characters="{len(memory.human)}/{memory.human_char_limit}">' if include_char_count else "<human>",
memory.human,
"</human>",
]
Expand Down

0 comments on commit 8bfda56

Please sign in to comment.