Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: remove test for unmerged function adding code

Sarah Wooders99e2ae5c86d7
diff --git a/tests/test_agent_function_update.py b/tests/test_agent_function_update.py
index 26914f1a0..5c545f0de 100644
--- a/tests/test_agent_function_update.py
+++ b/tests/test_agent_function_update.py
@@ -1,14 +1,12 @@
import inspect
import os
-import uuid
import pytest
from memgpt import create_client
from memgpt.functions.functions import USER_FUNCTIONS_DIR
from memgpt.schemas.message import Message
-from memgpt.settings import settings
-from memgpt.utils import assistant_function_to_tool, json_dumps, json_loads
+from memgpt.utils import assistant_function_to_tool, json_dumps
from tests.utils import create_config, wipe_config
@@ -34,16 +32,9 @@ def agent():
# create memgpt client
client = create_client()
- # ensure user exists
- user_id = uuid.UUID(TEST_MEMGPT_CONFIG.anon_clientid)
- if not client.server.get_user(user_id=user_id):
- client.server.create_user({"id": user_id})
+ agent_state = client.create_agent()
- agent_state = client.create_agent(
- preset=settings.preset,
- )
-
- return client.server._get_or_load_agent(user_id=user_id, agent_id=agent_state.id)
+ return client.server._get_or_load_agent(agent_id=agent_state.id)
@pytest.fixture(scope="module")
@@ -58,7 +49,7 @@ def ai_function_call():
**assistant_function_to_tool(
{
"role": "assistant",
- "content": "I will now call hello world",
+ "text": "I will now call hello world", # TODO: change to `content` once `Message` is updated
"function_call": {
"name": "hello_world",
"arguments": json_dumps({}),
@@ -68,53 +59,54 @@ def ai_function_call():
)
-def test_add_function_happy(agent, hello_world_function, ai_function_call):
- agent.add_function("hello_world")
-
- assert "hello_world" in [f_schema["name"] for f_schema in agent.functions]
- assert "hello_world" in agent.functions_python.keys()
-
- msgs, heartbeat_req, function_failed = agent._handle_ai_response(ai_function_call)
- content = json_loads(msgs[-1].to_openai_dict()["content"])
- assert content["message"] == "hello, world!"
- assert content["status"] == "OK"
- assert not function_failed
-
-
-def test_add_function_already_loaded(agent, hello_world_function):
- agent.add_function("hello_world")
- # no exception for duplicate loading
- agent.add_function("hello_world")
-
-
-def test_add_function_not_exist(agent):
- # pytest assert exception
- with pytest.raises(ValueError):
- agent.add_function("non_existent")
-
-
-def test_remove_function_happy(agent, hello_world_function):
- agent.add_function("hello_world")
-
- # ensure function is loaded
- assert "hello_world" in [f_schema["name"] for f_schema in agent.functions]
- assert "hello_world" in agent.functions_python.keys()
-
- agent.remove_function("hello_world")
-
- assert "hello_world" not in [f_schema["name"] for f_schema in agent.functions]
- assert "hello_world" not in agent.functions_python.keys()
-
-
-def test_remove_function_not_exist(agent):
- # do not raise error
- agent.remove_function("non_existent")
-
-
-def test_remove_base_function_fails(agent):
- with pytest.raises(ValueError):
- agent.remove_function("send_message")
-
+# TODO: add back once implementation completed
+# def test_add_function_happy(agent, hello_world_function, ai_function_call):
+# agent.add_function("hello_world")
+#
+# assert "hello_world" in [f_schema["name"] for f_schema in agent.functions]
+# assert "hello_world" in agent.functions_python.keys()
+#
+# msgs, heartbeat_req, function_failed = agent._handle_ai_response(ai_function_call)
+# content = json_loads(msgs[-1].to_openai_dict()["content"])
+# assert content["message"] == "hello, world!"
+# assert content["status"] == "OK"
+# assert not function_failed
+
+
+# def test_add_function_already_loaded(agent, hello_world_function):
+# agent.add_function("hello_world")
+# # no exception for duplicate loading
+# agent.add_function("hello_world")
+#
+#
+# def test_add_function_not_exist(agent):
+# # pytest assert exception
+# with pytest.raises(ValueError):
+# agent.add_function("non_existent")
+#
+#
+# def test_remove_function_happy(agent, hello_world_function):
+# agent.add_function("hello_world")
+#
+# # ensure function is loaded
+# assert "hello_world" in [f_schema["name"] for f_schema in agent.functions]
+# assert "hello_world" in agent.functions_python.keys()
+#
+# agent.remove_function("hello_world")
+#
+# assert "hello_world" not in [f_schema["name"] for f_schema in agent.functions]
+# assert "hello_world" not in agent.functions_python.keys()
+#
+#
+# def test_remove_function_not_exist(agent):
+# # do not raise error
+# agent.remove_function("non_existent")
+#
+#
+# def test_remove_base_function_fails(agent):
+# with pytest.raises(ValueError):
+# agent.remove_function("send_message")
+#
if __name__ == "__main__":
pytest.main(["-vv", os.path.abspath(__file__)])