Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make runtime error warnings.warn instead #2088

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions letta/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import secrets
import warnings
from typing import List, Optional

from sqlalchemy import JSON, Column, DateTime, Index, String, TypeDecorator
Expand Down Expand Up @@ -353,8 +354,14 @@ def create_agent(self, agent: AgentState):
raise ValueError(f"Agent with name {agent.name} already exists")
fields = vars(agent)
fields["memory"] = agent.memory.to_dict()
del fields["_internal_memory"]
del fields["tags"]
if "_internal_memory" in fields:
del fields["_internal_memory"]
else:
warnings.warn(f"Agent {agent.id} has no _internal_memory field")
if "tags" in fields:
del fields["tags"]
else:
warnings.warn(f"Agent {agent.id} has no tags field")
session.add(AgentModel(**fields))
session.commit()

Expand All @@ -364,8 +371,14 @@ def update_agent(self, agent: AgentState):
fields = vars(agent)
if isinstance(agent.memory, Memory): # TODO: this is nasty but this whole class will soon be removed so whatever
fields["memory"] = agent.memory.to_dict()
del fields["_internal_memory"]
del fields["tags"]
if "_internal_memory" in fields:
del fields["_internal_memory"]
else:
warnings.warn(f"Agent {agent.id} has no _internal_memory field")
if "tags" in fields:
del fields["tags"]
else:
warnings.warn(f"Agent {agent.id} has no tags field")
session.query(AgentModel).filter(AgentModel.id == agent.id).update(fields)
session.commit()

Expand Down
Loading