mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Fix input interpolation bug (#369)
This commit is contained in:
@@ -680,3 +680,21 @@ def test_agent_definition_based_on_dict():
|
||||
assert agent.backstory == "test backstory"
|
||||
assert agent.verbose == True
|
||||
assert agent.tools == []
|
||||
|
||||
|
||||
def test_interpolate_inputs():
|
||||
agent = Agent(
|
||||
role="{topic} specialist",
|
||||
goal="Figure {goal} out",
|
||||
backstory="I am the master of {role}",
|
||||
)
|
||||
|
||||
agent.interpolate_inputs({"topic": "AI", "goal": "life", "role": "all things"})
|
||||
assert agent.role == "AI specialist"
|
||||
assert agent.goal == "Figure life out"
|
||||
assert agent.backstory == "I am the master of all things"
|
||||
|
||||
agent.interpolate_inputs({"topic": "Sales", "goal": "stuff", "role": "nothing"})
|
||||
assert agent.role == "Sales specialist"
|
||||
assert agent.goal == "Figure stuff out"
|
||||
assert agent.backstory == "I am the master of nothing"
|
||||
|
||||
@@ -462,3 +462,24 @@ def test_task_definition_based_on_dict():
|
||||
assert task.description == config["description"]
|
||||
assert task.expected_output == config["expected_output"]
|
||||
assert task.agent is None
|
||||
|
||||
|
||||
def test_interpolate_inputs():
|
||||
task = Task(
|
||||
description="Give me a list of 5 interesting ideas about {topic} to explore for an article, what makes them unique and interesting.",
|
||||
expected_output="Bullet point list of 5 interesting ideas about {topic}.",
|
||||
)
|
||||
|
||||
task.interpolate_inputs(inputs={"topic": "AI"})
|
||||
assert (
|
||||
task.description
|
||||
== "Give me a list of 5 interesting ideas about AI to explore for an article, what makes them unique and interesting."
|
||||
)
|
||||
assert task.expected_output == "Bullet point list of 5 interesting ideas about AI."
|
||||
|
||||
task.interpolate_inputs(inputs={"topic": "ML"})
|
||||
assert (
|
||||
task.description
|
||||
== "Give me a list of 5 interesting ideas about ML to explore for an article, what makes them unique and interesting."
|
||||
)
|
||||
assert task.expected_output == "Bullet point list of 5 interesting ideas about ML."
|
||||
|
||||
Reference in New Issue
Block a user