Skip to content

Commit

Permalink
fix summarizer
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahwooders committed Nov 26, 2024
1 parent 7a7e179 commit 28c361d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion letta/schemas/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ def get_block(self, label: str) -> Block:
# raise KeyError(f"Block field {label} does not exist (available sections = {', '.join(list(self.memory.keys()))})")
# else:
# return self.memory[label]
keys = []
for block in self.blocks:
if block.label == label:
return block
raise KeyError(f"Block field {label} does not exist (available sections = {', '.join(list(self.memory.keys()))})")
keys.append(block.label)
raise KeyError(f"Block field {label} does not exist (available sections = {', '.join(keys)})")

def get_blocks(self) -> List[Block]:
"""Return a list of the blocks held inside the memory object"""
Expand Down
8 changes: 6 additions & 2 deletions tests/integration_test_summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ def test_summarizer(config_filename):

# Create agent
agent_state = client.create_agent(name=agent_name, llm_config=llm_config, embedding_config=embedding_config)
tools = [client.get_tool(client.get_tool_id(name=tool_name)) for tool_name in agent_state.tools]
full_agent_state = client.get_agent(agent_id=agent_state.id)
letta_agent = Agent(
interface=StreamingRefreshCLIInterface(), agent_state=agent_state, tools=tools, first_message_verify_mono=False, user=client.user
interface=StreamingRefreshCLIInterface(),
agent_state=full_agent_state,
first_message_verify_mono=False,
user=client.user,
block_manager=client.server.block_manager,
)

# Make conversation
Expand Down
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def test_load_agent_with_nonexistent_tool_names_does_not_error(server: SyncServe
# Load the agent from the database and check that it doesn't error / tools are correct
saved_tools = server.get_tools_from_agent(agent_id=agent_state.id, user_id=user_id)
assert fake_tool_name not in agent_state.tool_names
assert set(BASE_TOOLS).issubset(set(agent_state.tools_names))
assert set(BASE_TOOLS).issubset(set(agent_state.tool_names))

# cleanup
server.delete_agent(user_id, agent_state.id)
Expand Down

0 comments on commit 28c361d

Please sign in to comment.