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: Fix letta delete-agent #1940

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions letta/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,12 @@ def run(

def delete_agent(
agent_name: Annotated[str, typer.Option(help="Specify agent to delete")],
user_id: Annotated[Optional[str], typer.Option(help="User ID to associate with the agent.")] = None,
):
"""Delete an agent from the database"""
# use client ID is no user_id provided
config = LettaConfig.load()
MetadataStore(config)
client = create_client(user_id=user_id)
client = create_client()
agent = client.get_agent_by_name(agent_name)
if not agent:
typer.secho(f"Couldn't find agent named '{agent_name}' to delete", fg=typer.colors.RED)
Expand Down
4 changes: 2 additions & 2 deletions letta/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ def delete_agent(self, agent_id: str):
"""
self.server.delete_agent(user_id=self.user_id, agent_id=agent_id)

def get_agent_by_name(self, agent_name: str, user_id: str) -> AgentState:
def get_agent_by_name(self, agent_name: str) -> AgentState:
"""
Get an agent by its name

Expand All @@ -1788,7 +1788,7 @@ def get_agent_by_name(self, agent_name: str, user_id: str) -> AgentState:
agent_state (AgentState): State of the agent
"""
self.interface.clear()
return self.server.get_agent(agent_name=agent_name, user_id=user_id, agent_id=None)
return self.server.get_agent(agent_name=agent_name, user_id=self.user_id, agent_id=None)

def get_agent(self, agent_id: str) -> AgentState:
"""
Expand Down
4 changes: 2 additions & 2 deletions letta/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,9 +1222,9 @@ def get_source_id(self, source_name: str, user_id: str) -> str:
raise ValueError("Source does not exist")
return existing_source.id

def get_agent(self, user_id: str, agent_id: str, agent_name: Optional[str] = None):
def get_agent(self, user_id: str, agent_id: Optional[str] = None, agent_name: Optional[str] = None):
"""Get the agent state"""
return self.ms.get_agent(agent_id=agent_id, user_id=user_id)
return self.ms.get_agent(agent_id=agent_id, agent_name=agent_name, user_id=user_id)

# def get_user(self, user_id: str) -> User:
# """Get the user"""
Expand Down
Loading