mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Improve extract thought
This commit is contained in:
@@ -124,14 +124,15 @@ class CrewAgentParser:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _extract_thought(self, text: str) -> str:
|
def _extract_thought(self, text: str) -> str:
|
||||||
regex = r"(.*?)(?:\n\nAction|\n\nFinal Answer)"
|
thought_index = text.find("\n\nAction")
|
||||||
thought_match = re.search(regex, text, re.DOTALL)
|
if thought_index == -1:
|
||||||
if thought_match:
|
thought_index = text.find("\n\nFinal Answer")
|
||||||
thought = thought_match.group(1).strip()
|
if thought_index == -1:
|
||||||
# Remove any triple backticks from the thought string
|
return ""
|
||||||
thought = thought.replace("```", "").strip()
|
thought = text[:thought_index].strip()
|
||||||
return thought
|
# Remove any triple backticks from the thought string
|
||||||
return ""
|
thought = thought.replace("```", "").strip()
|
||||||
|
return thought
|
||||||
|
|
||||||
def _clean_action(self, text: str) -> str:
|
def _clean_action(self, text: str) -> str:
|
||||||
"""Clean action string by removing non-essential formatting characters."""
|
"""Clean action string by removing non-essential formatting characters."""
|
||||||
|
|||||||
Reference in New Issue
Block a user