Skip to content

Commit

Permalink
fix: sanitize Ask tool answers to prevent markdown formatting issues …
Browse files Browse the repository at this point in the history
…with leading slashes
  • Loading branch information
mrT23 committed Dec 30, 2024
1 parent 014b1f2 commit 8463c4f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pr_agent/tools/pr_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ def _prepare_pr_answer(self) -> str:
model_answer = self.prediction.strip()
# sanitize the answer so that no line will start with "/"
model_answer_sanitized = model_answer.replace("\n/", "\n /")
if model_answer_sanitized.startswith("/"):
model_answer_sanitized = " " + model_answer_sanitized
if model_answer_sanitized != model_answer:
get_logger().debug(f"Sanitized model answer",
artifact={"model_answer": model_answer, "sanitized_answer": model_answer_sanitized})


answer_str = f"### **Ask**❓\n{self.question_str}\n\n"
answer_str += f"### **Answer:**\n{model_answer_sanitized}\n\n"
Expand Down

0 comments on commit 8463c4f

Please sign in to comment.