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

chore: remove the admin client and tests #1923

Merged
merged 4 commits into from
Oct 22, 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
24 changes: 3 additions & 21 deletions examples/memgpt_rest_client.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
import json

from letta import Admin, create_client
from letta.memory import ChatMemory
from letta import create_client
from letta.schemas.memory import ChatMemory

"""
Make sure you run the Letta server before running this example.
```
export MEMGPT_SERVER_PASS=your_token
letta server
```
"""


def main():
# Create an admin client
admin = Admin(base_url="http://localhost:8283", token="your_token")

# Create a user + token
create_user_response = admin.create_user()
user_id = create_user_response.user_id
token = create_user_response.api_key
print(f"Created user: {user_id} with token: {token}")

# List available keys
get_keys_response = admin.get_keys(user_id=user_id)
print(f"User {user_id} has keys: {get_keys_response}")

# Connect to the server as a user
client = create_client(base_url="http://localhost:8283", token=token)
client = create_client(base_url="http://localhost:8283")

# Create an agent
agent_state = client.create_agent(name="my_agent", memory=ChatMemory(human="My name is Sarah.", persona="I am a friendly AI."))
Expand All @@ -42,10 +28,6 @@ def main():
client.delete_agent(agent_id=agent_state.id)
print(f"Deleted agent: {agent_state.name} with ID {str(agent_state.id)}")

# Delete user
admin.delete_user(user_id=user_id)
print(f"Deleted user: {user_id} with token: {token}")


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError

# NOTE: THIS file it out of date for >=0.5.0

# If modifying these scopes, delete the file token.json.
SCOPES = ["https://www.googleapis.com/auth/gmail.readonly"]
TOKEN_PATH = os.path.expanduser("~/.letta/gmail_token.json")
Expand Down
9 changes: 7 additions & 2 deletions letta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
__version__ = "0.5.0"

# import clients
from letta.client.admin import Admin
from letta.client.client import LocalClient, RESTClient, create_client

# imports for easier access
Expand All @@ -13,7 +12,13 @@
from letta.schemas.job import Job
from letta.schemas.letta_message import LettaMessage
from letta.schemas.llm_config import LLMConfig
from letta.schemas.memory import ArchivalMemorySummary, Memory, RecallMemorySummary
from letta.schemas.memory import (
ArchivalMemorySummary,
BasicBlockMemory,
ChatMemory,
Memory,
RecallMemorySummary,
)
from letta.schemas.message import Message
from letta.schemas.openai.chat_completion_response import UsageStatistics
from letta.schemas.organization import Organization
Expand Down
4 changes: 2 additions & 2 deletions letta/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def add_tool(
"""Add or update a tool from a Python file."""
from letta.client.client import create_client

client = create_client(base_url=os.getenv("MEMGPT_BASE_URL"), token=os.getenv("MEMGPT_SERVER_PASS"))
client = create_client()

# 1. Parse the Python file
with open(filename, "r", encoding="utf-8") as file:
Expand Down Expand Up @@ -145,7 +145,7 @@ def list_tools():
"""List all available tools."""
from letta.client.client import create_client

client = create_client(base_url=os.getenv("MEMGPT_BASE_URL"), token=os.getenv("MEMGPT_SERVER_PASS"))
client = create_client()

tools = client.list_tools()
for tool in tools:
Expand Down
171 changes: 0 additions & 171 deletions letta/client/admin.py

This file was deleted.

13 changes: 13 additions & 0 deletions letta/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,19 @@ 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:
"""
Get an agent by its name

Args:
agent_name (str): Name of the agent

Returns:
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)

def get_agent(self, agent_id: str) -> AgentState:
"""
Get an agent's state by its ID.
Expand Down
Loading
Loading