Delete a source from the archival memory.
(option: str, name: str)
| 195 | |
| 196 | @app.command() |
| 197 | def delete(option: str, name: str): |
| 198 | """Delete a source from the archival memory.""" |
| 199 | from letta.client.client import create_client |
| 200 | |
| 201 | client = create_client(base_url=os.getenv("MEMGPT_BASE_URL"), token=os.getenv("MEMGPT_API_KEY")) |
| 202 | try: |
| 203 | # delete from metadata |
| 204 | if option == "source": |
| 205 | # delete metadata |
| 206 | source_id = client.get_source_id(name) |
| 207 | assert source_id is not None, f"Source {name} does not exist" |
| 208 | client.delete_source(source_id) |
| 209 | elif option == "agent": |
| 210 | agent_id = client.get_agent_id(name) |
| 211 | assert agent_id is not None, f"Agent {name} does not exist" |
| 212 | client.delete_agent(agent_id=agent_id) |
| 213 | elif option == "human": |
| 214 | human_id = client.get_human_id(name) |
| 215 | assert human_id is not None, f"Human {name} does not exist" |
| 216 | client.delete_human(human_id) |
| 217 | elif option == "persona": |
| 218 | persona_id = client.get_persona_id(name) |
| 219 | assert persona_id is not None, f"Persona {name} does not exist" |
| 220 | client.delete_persona(persona_id) |
| 221 | else: |
| 222 | raise ValueError(f"Option {option} not implemented") |
| 223 | |
| 224 | typer.secho(f"Deleted {option} '{name}'", fg=typer.colors.GREEN) |
| 225 | |
| 226 | except Exception as e: |
| 227 | typer.secho(f"Failed to delete {option}'{name}'\n{e}", fg=typer.colors.RED) |
no test coverage detected