mirror of
https://github.com/cpacker/MemGPT.git
synced 2025-06-03 04:30:22 +00:00

Co-authored-by: Shubham Naik <shubham.naik10@gmail.com> Co-authored-by: Matthew Zhou <mattzh1314@gmail.com> Co-authored-by: Matt Zhou <mattzhou@Matts-MacBook-Pro.local> Co-authored-by: Shubham Naik <shub@memgpt.ai>
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import pytest
|
|
|
|
from letta import create_client
|
|
from letta.schemas.message import Message
|
|
from letta.utils import assistant_function_to_tool, json_dumps
|
|
from tests.utils import wipe_config
|
|
|
|
|
|
def hello_world(self) -> str:
|
|
"""Test function for agent to gain access to
|
|
|
|
Returns:
|
|
str: A message for the world
|
|
"""
|
|
return "hello, world!"
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def agent():
|
|
"""Create a test agent that we can call functions on"""
|
|
wipe_config()
|
|
global client
|
|
# create letta client
|
|
client = create_client()
|
|
|
|
agent_state = client.create_agent()
|
|
|
|
return client.server._get_or_load_agent(agent_id=agent_state.id)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def ai_function_call():
|
|
return Message(
|
|
**assistant_function_to_tool(
|
|
{
|
|
"role": "assistant",
|
|
"text": "I will now call hello world", # TODO: change to `content` once `Message` is updated
|
|
"function_call": {
|
|
"name": "hello_world",
|
|
"arguments": json_dumps({}),
|
|
},
|
|
}
|
|
)
|
|
)
|