Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: fix broken example after modifying client to return pydantic objects (#1174)
Sarah Wooders9af1ceb11ef6
diff --git a/examples/memgpt_client.py b/examples/memgpt_client.pyindex b92ad54fc..6f5280b9c 100644--- a/examples/memgpt_client.py+++ b/examples/memgpt_client.py@@ -1,3 +1,4 @@+import jsonfrom memgpt import create_client, Adminfrom memgpt.constants import DEFAULT_PRESET, DEFAULT_HUMAN, DEFAULT_PERSONAfrom memgpt.utils import get_human_text, get_persona_text@@ -17,9 +18,15 @@ def main():admin = Admin(base_url="http://localhost:8283", token="your_token")# Create a user + token- user_id, token = admin.create_user()+ create_user_response = admin.create_user()+ user_id = create_user_response.user_id+ token = create_user_response.api_keyprint(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.api_key_list}")+# Connect to the server as a userclient = create_client(base_url="http://localhost:8283", token=token)@@ -27,14 +34,15 @@ def main():agent_info = client.create_agent(name="my_agent",preset=DEFAULT_PRESET,- persona_name=get_persona_text(DEFAULT_PERSONA),- human_name=get_human_text(DEFAULT_HUMAN),+ persona=get_persona_text(DEFAULT_PERSONA),+ human=get_human_text(DEFAULT_HUMAN),)print(f"Created agent: {agent_info.name} with ID {str(agent_info.id)}")# Send a message to the agent- messages = client.user_message(agent_id=agent_info.id, message="Hello, agent!")- print(f"Recieved response: {messages}")+ send_message_response = client.user_message(agent_id=agent_info.id, message="Hello, agent!")+ messages = send_message_response.messages+ print(f"Recieved response: \n{json.dumps(messages, indent=4)}")# TODO: get agent memory