mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-28 01:28:14 +00:00
drop trailing set
This commit is contained in:
@@ -94,8 +94,13 @@ class CrewAgentParser:
|
|||||||
|
|
||||||
elif includes_answer:
|
elif includes_answer:
|
||||||
final_answer = text.split(FINAL_ANSWER_ACTION)[-1].strip()
|
final_answer = text.split(FINAL_ANSWER_ACTION)[-1].strip()
|
||||||
# Remove all backticks (```) from the final answer
|
# Check whether the final answer ends with triple backticks.
|
||||||
final_answer = final_answer.replace("```", "").strip()
|
if final_answer.endswith("```"):
|
||||||
|
# Count occurrences of triple backticks in the final answer.
|
||||||
|
count = final_answer.count("```")
|
||||||
|
# If count is odd then it's an unmatched trailing set; remove it.
|
||||||
|
if count % 2 != 0:
|
||||||
|
final_answer = final_answer[:-3].rstrip()
|
||||||
return AgentFinish(thought, final_answer, text)
|
return AgentFinish(thought, final_answer, text)
|
||||||
|
|
||||||
if not re.search(r"Action\s*\d*\s*:[\s]*(.*?)", text, re.DOTALL):
|
if not re.search(r"Action\s*\d*\s*:[\s]*(.*?)", text, re.DOTALL):
|
||||||
|
|||||||
Reference in New Issue
Block a user