mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 09:08:31 +00:00
Add markdown attribute to Task class for formatting responses in Markdown
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
53
tests/test_markdown_task.py
Normal file
53
tests/test_markdown_task.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""Test the markdown attribute in Task class."""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
|
||||
from crewai import Agent, Task
|
||||
|
||||
|
||||
def test_markdown_option_in_task_prompt():
|
||||
"""Test that when markdown=True, the task prompt includes markdown formatting instructions."""
|
||||
|
||||
researcher = Agent(
|
||||
role="Researcher",
|
||||
goal="Research a topic",
|
||||
backstory="You're a researcher specialized in providing well-formatted content.",
|
||||
allow_delegation=False,
|
||||
)
|
||||
|
||||
task = Task(
|
||||
description="Research advances in AI in 2023",
|
||||
expected_output="A summary of key AI advances in 2023",
|
||||
markdown=True,
|
||||
agent=researcher,
|
||||
)
|
||||
|
||||
prompt = task.prompt()
|
||||
|
||||
assert "Research advances in AI in 2023" in prompt
|
||||
assert "A summary of key AI advances in 2023" in prompt
|
||||
assert "Your final answer MUST be formatted in Markdown syntax." in prompt
|
||||
|
||||
|
||||
def test_markdown_option_not_in_task_prompt_by_default():
|
||||
"""Test that by default (markdown=False), the task prompt does not include markdown formatting instructions."""
|
||||
|
||||
researcher = Agent(
|
||||
role="Researcher",
|
||||
goal="Research a topic",
|
||||
backstory="You're a researcher specialized in providing well-formatted content.",
|
||||
allow_delegation=False,
|
||||
)
|
||||
|
||||
task = Task(
|
||||
description="Research advances in AI in 2023",
|
||||
expected_output="A summary of key AI advances in 2023",
|
||||
agent=researcher,
|
||||
)
|
||||
|
||||
prompt = task.prompt()
|
||||
|
||||
assert "Research advances in AI in 2023" in prompt
|
||||
assert "A summary of key AI advances in 2023" in prompt
|
||||
assert "Your final answer MUST be formatted in Markdown syntax." not in prompt
|
||||
Reference in New Issue
Block a user