Compare commits

...

2 Commits

Author SHA1 Message Date
Lorenze Jay
7529f0a0d6 Merge branch 'main' into speed-up-extract-thought 2025-02-26 11:46:55 -08:00
Brandon Hancock
302b6528d6 Improve extract thought 2025-02-25 12:02:18 -05:00

View File

@@ -124,14 +124,15 @@ class CrewAgentParser:
)
def _extract_thought(self, text: str) -> str:
regex = r"(.*?)(?:\n\nAction|\n\nFinal Answer)"
thought_match = re.search(regex, text, re.DOTALL)
if thought_match:
thought = thought_match.group(1).strip()
# Remove any triple backticks from the thought string
thought = thought.replace("```", "").strip()
return thought
return ""
thought_index = text.find("\n\nAction")
if thought_index == -1:
thought_index = text.find("\n\nFinal Answer")
if thought_index == -1:
return ""
thought = text[:thought_index].strip()
# Remove any triple backticks from the thought string
thought = thought.replace("```", "").strip()
return thought
def _clean_action(self, text: str) -> str:
"""Clean action string by removing non-essential formatting characters."""