mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 23:58:34 +00:00
updating tests
This commit is contained in:
@@ -302,7 +302,11 @@ class AgentReasoning:
|
||||
Returns:
|
||||
str: The agent's backstory or a default value.
|
||||
"""
|
||||
return getattr(self.agent, "backstory", "No backstory provided")
|
||||
try:
|
||||
backstory = getattr(self.agent, "backstory", "No backstory provided")
|
||||
return backstory
|
||||
except Exception as e:
|
||||
return "No backstory provided"
|
||||
|
||||
def __create_reasoning_prompt(self) -> str:
|
||||
"""
|
||||
@@ -313,7 +317,7 @@ class AgentReasoning:
|
||||
"""
|
||||
available_tools = self.__format_available_tools()
|
||||
|
||||
return self.i18n.retrieve("reasoning", "create_plan_prompt").format(
|
||||
prompt = self.i18n.retrieve("reasoning", "create_plan_prompt").format(
|
||||
role=self.agent.role,
|
||||
goal=self.agent.goal,
|
||||
backstory=self.__get_agent_backstory(),
|
||||
@@ -321,6 +325,7 @@ class AgentReasoning:
|
||||
expected_output=self.task.expected_output,
|
||||
tools=available_tools
|
||||
)
|
||||
return prompt
|
||||
|
||||
def __format_available_tools(self) -> str:
|
||||
"""
|
||||
|
||||
@@ -791,7 +791,7 @@ def test_reasoning_events_attach_to_correct_task():
|
||||
|
||||
@crewai_event_bus.on(TaskStartedEvent)
|
||||
def handle_task_start(source, event):
|
||||
received_events.append(('task_started', source.id))
|
||||
received_events.append(('task_started', str(source.id)))
|
||||
|
||||
@crewai_event_bus.on(AgentReasoningStartedEvent)
|
||||
def handle_reasoning_start(source, event):
|
||||
@@ -799,7 +799,7 @@ def test_reasoning_events_attach_to_correct_task():
|
||||
|
||||
@crewai_event_bus.on(TaskCompletedEvent)
|
||||
def handle_task_complete(source, event):
|
||||
received_events.append(('task_completed', source.id))
|
||||
received_events.append(('task_completed', str(source.id)))
|
||||
|
||||
# Create agent with reasoning enabled
|
||||
reasoning_agent = Agent(
|
||||
@@ -829,7 +829,7 @@ def test_reasoning_events_attach_to_correct_task():
|
||||
# Mock the LLM to provide reasoning responses
|
||||
def mock_llm_call(messages, *args, **kwargs):
|
||||
if any("create a detailed plan" in str(msg) for msg in messages):
|
||||
return "Test plan\n\nREADY: I'm ready to execute."
|
||||
return "Test plan\n\nREADY: I am ready to execute the task."
|
||||
return "Test execution result"
|
||||
|
||||
reasoning_agent.llm.call = mock_llm_call
|
||||
|
||||
Reference in New Issue
Block a user