Skip to content

Commit e925a4e

Browse files
committed
fix: unit tests
1 parent 7bfb4ee commit e925a4e

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

.coveragerc

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ omit =
88
**/tests/*
99
**/__init__.py
1010
**/*pb2*.py
11+
**/run_host.py
1112
setup.py
1213
exclude_lines =
1314
pragma: no cover

tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ def check_docs(c):
3939
@task
4040
def lint(c):
4141
c.run("cd vanilla_aiagents && black vanilla_aiagents/")
42-
c.run("cd vanilla_aiagents && docformatter -i -r -s pep257 --black vanilla_aiagents/")
42+
c.run("cd vanilla_aiagents && docformatter -i -r -s pep257 --black vanilla_aiagents/")

vanilla_aiagents/tests/test_team.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Annotated
12
import unittest
23
import os, logging, sys
34

@@ -29,7 +30,7 @@ def setUp(self):
2930

3031
def test_transitions(self):
3132
# Telling the agents to set context variables implies calling a pre-defined function call
32-
first = Agent(id="first", llm=self.llm, description="Agent that sets context variables", system_message = """You are part of an AI process
33+
first = Agent(id="first", llm=self.llm, description="Agent that sets context variables", system_message="""You are part of an AI process
3334
Your task is to set a context for the next agent to continue the conversation.
3435
3536
DO set context variable "CHANNEL" to "voice" and "LANGUAGE" to "en"
@@ -38,7 +39,7 @@ def test_transitions(self):
3839
""")
3940

4041
# Second agent might have its system message extended automatically with the context from the ongoing conversation
41-
second = Agent(id="second", llm=self.llm, description="Agent that uses context variables to answer", system_message = """You are part of an AI process
42+
second = Agent(id="second", llm=self.llm, description="Agent that uses context variables to answer", system_message="""You are part of an AI process
4243
Your task is to continue the conversation based on the context set by the previous agent.
4344
When asked, you can use variable provide in CONTEXT to generate the response.
4445
@@ -58,15 +59,15 @@ def test_transitions(self):
5859
self.assertIn("voice", workflow.conversation.messages[3]["content"], "Expected second agent to recognize context variable CHANNEL")
5960

6061
def test_use_tools(self):
61-
first = Agent(id="first", llm=self.llm, description="Agent1", system_message = """You are part of an AI process
62+
first = Agent(id="first", llm=self.llm, description="Agent1", system_message="""You are part of an AI process
6263
Your task is to support the user inquiry by providing the user profile.
6364
""")
6465

6566
@first.register_tool(name="get_user_profile", description="Get the user profile")
6667
def get_user_profile():
6768
return "User profile: {\"name\": \"John\", \"age\": 30}"
6869

69-
second = Agent(id="second", llm=self.llm, description="Agent2", system_message = """You are part of an AI process
70+
second = Agent(id="second", llm=self.llm, description="Agent2", system_message="""You are part of an AI process
7071
Your task is to support the user inquiry by providing the user balance.
7172
""")
7273

@@ -84,24 +85,24 @@ def get_user_balance():
8485
self.assertEqual(second.id, workflow.conversation.messages[-1]["name"], "Expected user balance to be provided")
8586

8687
def test_not_use_structured_output(self):
87-
first = Agent(id="first", llm=self.llm, description="Agent1", system_message = """You are part of an AI process
88-
Your task is to support the user inquiry by providing the user profile.
88+
first = Agent(id="first", llm=self.llm, description="Agent1", system_message="""You are part of an AI process
89+
Your task is to support the user inquiry.
8990
""")
9091

9192
@first.register_tool(name="get_user_profile", description="Get the user profile")
92-
def get_user_profile():
93+
def get_user_profile() -> Annotated[str, "The user profile, containing name and age"]:
9394
return "User profile: {\"name\": \"John\", \"age\": 30}"
9495

95-
second = Agent(id="second", llm=self.llm, description="Agent2", system_message = """You are part of an AI process
96-
Your task is to support the user inquiry by providing the user balance.
96+
second = Agent(id="second", llm=self.llm, description="Agent2", system_message="""You are part of an AI process
97+
Your task is to support the user inquiry.
9798
""")
9899

99100
@second.register_tool(name="get_user_balance", description="Get the user balance")
100-
def get_user_balance():
101+
def get_user_balance() -> Annotated[str, "The user balance in USD"]:
101102
return "User balance: $100"
102103

103-
flow = Team(id="flow", description="", members=[first, second], llm=self.llm,
104-
stop_callback=lambda x: len(x) > 3,
104+
flow = Team(id="flow", description="", members=[first, second], llm=self.llm,
105+
stop_callback=lambda messages: len(messages) == 3,
105106
include_tools_descriptions=True,
106107
use_structured_output=False)
107108
workflow = Workflow(askable=flow)

0 commit comments

Comments
 (0)