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.

fix block creation

Sarah Wooders983108a7beff
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6d9b7491d..626308cc2 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -5,7 +5,7 @@ repos:
- id: check-yaml
exclude: 'docs/.*|tests/data/.*|configs/.*'
- id: end-of-file-fixer
- exclude: 'docs/.*|tests/data/.*|letta/server/static_files/.*|.*/.*\.(scss|css|html)'
+ exclude: 'docs/.*|tests/data/.*|letta/server/static_files/.*'
- id: trailing-whitespace
exclude: 'docs/.*|tests/data/.*|letta/server/static_files/.*'
@@ -13,18 +13,21 @@ repos:
hooks:
- id: autoflake
name: autoflake
- entry: bash -c 'cd apps/core && poetry run autoflake --remove-all-unused-imports --remove-unused-variables --in-place --recursive --ignore-init-module-imports .'
+ entry: poetry run autoflake
language: system
types: [python]
+ args: ['--remove-all-unused-imports', '--remove-unused-variables', '--in-place', '--recursive', '--ignore-init-module-imports']
- id: isort
name: isort
- entry: bash -c 'cd apps/core && poetry run isort --profile black .'
+ entry: poetry run isort
language: system
types: [python]
+ args: ['--profile', 'black']
exclude: ^docs/
- id: black
name: black
- entry: bash -c 'cd apps/core && poetry run black --line-length 140 --target-version py310 --target-version py311 .'
+ entry: poetry run black
language: system
types: [python]
+ args: ['--line-length', '140', '--target-version', 'py310', '--target-version', 'py311']
exclude: ^docs/
diff --git a/tests/integration_test_offline_memory_agent.py b/tests/integration_test_offline_memory_agent.py
index 15d4161d5..b6ccbf63d 100644
--- a/tests/integration_test_offline_memory_agent.py
+++ b/tests/integration_test_offline_memory_agent.py
@@ -1,7 +1,7 @@
import pytest
from letta import BasicBlockMemory
-from letta.client.client import Block, create_client
+from letta.client.client import create_client
from letta.constants import DEFAULT_HUMAN, DEFAULT_PERSONA
from letta.offline_memory_agent import (
finish_rethinking_memory,
@@ -37,14 +37,14 @@ def test_ripple_edit(client, mock_e2b_api_key_none):
trigger_rethink_memory_tool = client.create_or_update_tool(trigger_rethink_memory)
send_message = client.server.tool_manager.get_tool_by_name(tool_name="send_message", actor=client.user)
- conversation_human_block = Block(name="human", label="human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
- conversation_persona_block = Block(name="persona", label="persona", value=get_persona_text(DEFAULT_PERSONA), limit=2000)
- offline_human_block = Block(name="human", label="human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
- offline_persona_block = Block(name="persona", label="persona", value=get_persona_text("offline_memory_persona"), limit=2000)
+ conversation_human_block = client.create_block(label="human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
+ conversation_persona_block = client.create_block(label="persona", value=get_persona_text(DEFAULT_PERSONA), limit=2000)
+ offline_human_block = client.create_block(label="human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
+ offline_persona_block = client.create_block(label="persona", value=get_persona_text("offline_memory_persona"), limit=2000)
# Figure 1. from Evaluating the Ripple Effects of Knowledge Editing in Language Models (Cohen et al., 2023)
# https://arxiv.org/pdf/2307.12976
- fact_block = Block(
+ fact_block = client.create_block(
name="fact_block",
label="fact_block",
value="""Messi resides in the Paris.
@@ -55,8 +55,27 @@ def test_ripple_edit(client, mock_e2b_api_key_none):
Victor Ulloa plays for Inter Miami""",
limit=2000,
)
-
- new_memory = Block(name="rethink_memory_block", label="rethink_memory_block", value="[empty]", limit=2000)
+ new_memory = client.create_block(name="rethink_memory_block", label="rethink_memory_block", value="[empty]", limit=2000)
+
+ # conversation_human_block = Block(name="human", label="human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
+ # conversation_persona_block = Block(name="persona", label="persona", value=get_persona_text(DEFAULT_PERSONA), limit=2000)
+ # offline_human_block = Block(name="human", label="human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
+ # offline_persona_block = Block(name="persona", label="persona", value=get_persona_text("offline_memory_persona"), limit=2000)
+
+ ## Figure 1. from Evaluating the Ripple Effects of Knowledge Editing in Language Models (Cohen et al., 2023)
+ ## https://arxiv.org/pdf/2307.12976
+ # fact_block = Block(
+ # name="fact_block",
+ # label="fact_block",
+ # value="""Messi resides in the Paris.
+ # Messi plays in the league Ligue 1.
+ # Messi plays for the team Paris Saint-Germain.
+ # The national team Messi plays for is the Argentina team.
+ # Messi is also known as Leo Messi
+ # Victor Ulloa plays for Inter Miami""",
+ # limit=2000,
+ # )
+ # new_memory = Block(name="rethink_memory_block", label="rethink_memory_block", value="[empty]", limit=2000)
conversation_memory = BasicBlockMemory(blocks=[conversation_persona_block, conversation_human_block, fact_block, new_memory])
offline_memory = BasicBlockMemory(blocks=[offline_persona_block, offline_human_block, fact_block, new_memory])
@@ -107,10 +126,13 @@ def test_chat_only_agent(client, mock_e2b_api_key_none):
rethink_memory = client.create_or_update_tool(rethink_memory_convo)
finish_rethinking_memory = client.create_or_update_tool(finish_rethinking_memory_convo)
- conversation_human_block = Block(name="chat_agent_human", label="chat_agent_human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
- conversation_persona_block = Block(
- name="chat_agent_persona", label="chat_agent_persona", value=get_persona_text(DEFAULT_PERSONA), limit=2000
- )
+ # conversation_human_block = Block(name="chat_agent_human", label="chat_agent_human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
+ # conversation_persona_block = Block(
+ # name="chat_agent_persona", label="chat_agent_persona", value=get_persona_text(DEFAULT_PERSONA), limit=2000
+ # )
+
+ conversation_human_block = client.create_block(label="chat_agent_human", value=get_human_text(DEFAULT_HUMAN), limit=2000)
+ conversation_persona_block = client.create_block(label="chat_agent_persona", value=get_persona_text(DEFAULT_PERSONA), limit=2000)
conversation_memory = BasicBlockMemory(blocks=[conversation_persona_block, conversation_human_block])
send_message = client.server.tool_manager.get_tool_by_name(tool_name="send_message", actor=client.user)