| 31 | |
| 32 | @app.command() |
| 33 | def list(arg: Annotated[ListChoice, typer.Argument]): |
| 34 | from letta.client.client import create_client |
| 35 | |
| 36 | client = create_client() |
| 37 | table = ColorTable(theme=Themes.OCEAN) |
| 38 | if arg == ListChoice.agents: |
| 39 | """List all agents""" |
| 40 | table.field_names = ["Name", "LLM Model", "Embedding Model", "Embedding Dim", "Persona", "Human", "Data Source", "Create Time"] |
| 41 | for agent in tqdm(client.list_agents()): |
| 42 | # TODO: add this function |
| 43 | sources = client.list_attached_sources(agent_id=agent.id) |
| 44 | source_names = [source.name for source in sources if source is not None] |
| 45 | table.add_row( |
| 46 | [ |
| 47 | agent.name, |
| 48 | agent.llm_config.model, |
| 49 | agent.embedding_config.embedding_model, |
| 50 | agent.embedding_config.embedding_dim, |
| 51 | agent.memory.get_block("persona").value[:100] + "...", |
| 52 | agent.memory.get_block("human").value[:100] + "...", |
| 53 | ",".join(source_names), |
| 54 | letta.helpers.datetime_helpers.format_datetime(agent.created_at), |
| 55 | ] |
| 56 | ) |
| 57 | print(table) |
| 58 | elif arg == ListChoice.humans: |
| 59 | """List all humans""" |
| 60 | table.field_names = ["Name", "Text"] |
| 61 | for human in client.list_humans(): |
| 62 | table.add_row([human.template_name, human.value.replace("\n", "")[:100]]) |
| 63 | elif arg == ListChoice.personas: |
| 64 | """List all personas""" |
| 65 | table.field_names = ["Name", "Text"] |
| 66 | for persona in client.list_personas(): |
| 67 | table.add_row([persona.template_name, persona.value.replace("\n", "")[:100]]) |
| 68 | print(table) |
| 69 | elif arg == ListChoice.sources: |
| 70 | """List all data sources""" |
| 71 | |
| 72 | # create table |
| 73 | table.field_names = ["Name", "Description", "Embedding Model", "Embedding Dim", "Created At"] |
| 74 | # TODO: eventually look accross all storage connections |
| 75 | # TODO: add data source stats |
| 76 | # TODO: connect to agents |
| 77 | |
| 78 | # get all sources |
| 79 | for source in client.list_sources(): |
| 80 | # get attached agents |
| 81 | table.add_row( |
| 82 | [ |
| 83 | source.name, |
| 84 | source.description, |
| 85 | source.embedding_config.embedding_model, |
| 86 | source.embedding_config.embedding_dim, |
| 87 | letta.helpers.datetime_helpers.format_datetime(source.created_at), |
| 88 | ] |
| 89 | ) |
| 90 | |