Add feature to override _ask_human_input function in Task (#2419)

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-03-20 08:44:15 +00:00
parent fe0813e831
commit 0ff73d22d7
6 changed files with 82 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
import pytest
from unittest.mock import patch, MagicMock
from crewai.task import Task
def test_task_custom_human_input_parameter():
"""Test that the Task class accepts the ask_human_input parameter."""
# Custom human input function
def custom_input_func(final_answer):
return "Custom feedback"
# Create a task with the custom function
task = Task(
description="Test task",
expected_output="Test output",
human_input=True,
ask_human_input=custom_input_func
)
# Verify the parameter was stored correctly
assert task.ask_human_input == custom_input_func
assert callable(task.ask_human_input)