mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-06 05:40:38 +08:00
Merge pull request #1426 from Codium-ai/tr/ask_fix
fix: sanitize Ask tool answers to prevent markdown formatting issues
This commit is contained in:
@ -79,13 +79,17 @@ class PR_LineQuestions:
|
|||||||
line_end=line_end,
|
line_end=line_end,
|
||||||
side=side)
|
side=side)
|
||||||
if self.patch_with_lines:
|
if self.patch_with_lines:
|
||||||
response = await retry_with_fallback_models(self._get_prediction, model_type=ModelType.WEAK)
|
model_answer = await retry_with_fallback_models(self._get_prediction, model_type=ModelType.WEAK)
|
||||||
|
# sanitize the answer so that no line will start with "/"
|
||||||
|
model_answer_sanitized = model_answer.strip().replace("\n/", "\n /")
|
||||||
|
if model_answer_sanitized.startswith("/"):
|
||||||
|
model_answer_sanitized = " " + model_answer_sanitized
|
||||||
|
|
||||||
get_logger().info('Preparing answer...')
|
get_logger().info('Preparing answer...')
|
||||||
if comment_id:
|
if comment_id:
|
||||||
self.git_provider.reply_to_comment_from_comment_id(comment_id, response)
|
self.git_provider.reply_to_comment_from_comment_id(comment_id, model_answer_sanitized)
|
||||||
else:
|
else:
|
||||||
self.git_provider.publish_comment(response)
|
self.git_provider.publish_comment(model_answer_sanitized)
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -117,6 +117,10 @@ class PRQuestions:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
def _prepare_pr_answer(self) -> str:
|
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 /")
|
||||||
|
|
||||||
answer_str = f"### **Ask**❓\n{self.question_str}\n\n"
|
answer_str = f"### **Ask**❓\n{self.question_str}\n\n"
|
||||||
answer_str += f"### **Answer:**\n{self.prediction.strip()}\n\n"
|
answer_str += f"### **Answer:**\n{model_answer_sanitized}\n\n"
|
||||||
return answer_str
|
return answer_str
|
||||||
|
Reference in New Issue
Block a user