mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-05 17:22:36 +00:00
refactor: Improve feedback message formatting
- Use i18n for feedback message formatting - Enhance method documentation - Improve code organization Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -574,6 +574,9 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
|||||||
) -> AgentFinish:
|
) -> AgentFinish:
|
||||||
"""Process feedback for regular use with potential multiple iterations.
|
"""Process feedback for regular use with potential multiple iterations.
|
||||||
|
|
||||||
|
This method handles the iterative feedback process where the agent continues
|
||||||
|
to improve its answer based on user feedback until no more changes are needed.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
current_answer (AgentFinish): The current answer from the agent
|
current_answer (AgentFinish): The current answer from the agent
|
||||||
initial_feedback (str): The initial feedback from the user
|
initial_feedback (str): The initial feedback from the user
|
||||||
@@ -582,7 +585,7 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
|||||||
AgentFinish: The final answer after processing all feedback iterations
|
AgentFinish: The final answer after processing all feedback iterations
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
FeedbackProcessingError: If feedback processing fails
|
FeedbackProcessingError: If feedback processing or validation fails
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
feedback = initial_feedback
|
feedback = initial_feedback
|
||||||
@@ -590,12 +593,10 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
|||||||
|
|
||||||
while self.ask_for_human_input:
|
while self.ask_for_human_input:
|
||||||
# Add feedback message with user role using standard formatter
|
# Add feedback message with user role using standard formatter
|
||||||
self.messages.append(self._format_msg(
|
feedback_msg = self._i18n.slice("feedback_message").format(feedback=feedback)
|
||||||
f"Feedback: {feedback}",
|
self.messages.append(self._format_msg(feedback_msg, role="user"))
|
||||||
role="user"
|
|
||||||
))
|
|
||||||
response = self._get_llm_feedback_response(feedback)
|
|
||||||
|
|
||||||
|
response = self._get_llm_feedback_response(feedback)
|
||||||
if not self._feedback_requires_changes(response):
|
if not self._feedback_requires_changes(response):
|
||||||
self.ask_for_human_input = False
|
self.ask_for_human_input = False
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user