feat: various fixes (#2320)
Co-authored-by: Shubham Naik <shub@memgpt.ai> Co-authored-by: Matt Zhou <mattzh1314@gmail.com> Co-authored-by: Shubham Naik <shubham.naik10@gmail.com> Co-authored-by: Caren Thomas <caren@letta.com> Co-authored-by: cpacker <packercharles@gmail.com>
This commit is contained in:
@@ -43,7 +43,7 @@ def run_server():
|
||||
|
||||
@pytest.fixture(
|
||||
params=[{"server": False}, {"server": True}], # whether to use REST API server
|
||||
# params=[{"server": True}], # whether to use REST API server
|
||||
# params=[{"server": False}], # whether to use REST API server
|
||||
scope="module",
|
||||
)
|
||||
def client(request):
|
||||
@@ -341,7 +341,9 @@ def test_messages(client: Union[LocalClient, RESTClient], agent: AgentState):
|
||||
|
||||
def test_send_system_message(client: Union[LocalClient, RESTClient], agent: AgentState):
|
||||
"""Important unit test since the Letta API exposes sending system messages, but some backends don't natively support it (eg Anthropic)"""
|
||||
send_system_message_response = client.send_message(agent_id=agent.id, message="Event occurred: The user just logged off.", role="system")
|
||||
send_system_message_response = client.send_message(
|
||||
agent_id=agent.id, message="Event occurred: The user just logged off.", role="system"
|
||||
)
|
||||
assert send_system_message_response, "Sending message failed"
|
||||
|
||||
|
||||
@@ -390,7 +392,7 @@ def test_function_always_error(client: Union[LocalClient, RESTClient]):
|
||||
"""
|
||||
Always throw an error.
|
||||
"""
|
||||
return 5/0
|
||||
return 5 / 0
|
||||
|
||||
tool = client.create_or_update_tool(func=always_error)
|
||||
agent = client.create_agent(tool_ids=[tool.id])
|
||||
@@ -406,12 +408,13 @@ def test_function_always_error(client: Union[LocalClient, RESTClient]):
|
||||
|
||||
assert response_message, "ToolReturnMessage message not found in response"
|
||||
assert response_message.status == "error"
|
||||
|
||||
if isinstance(client, RESTClient):
|
||||
assert response_message.tool_return == "Error executing function always_error: ZeroDivisionError: division by zero"
|
||||
else:
|
||||
response_json = json.loads(response_message.tool_return)
|
||||
assert response_json['status'] == "Failed"
|
||||
assert response_json['message'] == "Error executing function always_error: ZeroDivisionError: division by zero"
|
||||
assert response_json["status"] == "Failed"
|
||||
assert response_json["message"] == "Error executing function always_error: ZeroDivisionError: division by zero"
|
||||
|
||||
client.delete_agent(agent_id=agent.id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user