mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
Fix GitLab protections function and return value in PR questions
This commit is contained in:
@ -116,13 +116,14 @@ class PRQuestions:
|
|||||||
model=model, temperature=get_settings().config.temperature, system=system_prompt, user=user_prompt)
|
model=model, temperature=get_settings().config.temperature, system=system_prompt, user=user_prompt)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def gitlab_protctions(self, model_answer: str) -> str:
|
def gitlab_protections(self, model_answer: str) -> str:
|
||||||
github_quick_actions_MR = ["/approve", "/close", "/merge", "/reopen", "/unapprove", "/title", "/assign",
|
github_quick_actions_MR = ["/approve", "/close", "/merge", "/reopen", "/unapprove", "/title", "/assign",
|
||||||
"/copy_metadata", "/target_branch"]
|
"/copy_metadata", "/target_branch"]
|
||||||
if any(action in model_answer for action in github_quick_actions_MR):
|
if any(action in model_answer for action in github_quick_actions_MR):
|
||||||
str_err = "Model answer contains GitHub quick actions, which are not supported in GitLab"
|
str_err = "Model answer contains GitHub quick actions, which are not supported in GitLab"
|
||||||
get_logger().error(str_err)
|
get_logger().error(str_err)
|
||||||
return str_err
|
return str_err
|
||||||
|
return model_answer
|
||||||
|
|
||||||
def _prepare_pr_answer(self) -> str:
|
def _prepare_pr_answer(self) -> str:
|
||||||
model_answer = self.prediction.strip()
|
model_answer = self.prediction.strip()
|
||||||
@ -130,7 +131,7 @@ class PRQuestions:
|
|||||||
model_answer_sanitized = model_answer.replace("\n/", "\n /")
|
model_answer_sanitized = model_answer.replace("\n/", "\n /")
|
||||||
model_answer_sanitized = model_answer_sanitized.replace("\r/", "\r /")
|
model_answer_sanitized = model_answer_sanitized.replace("\r/", "\r /")
|
||||||
if isinstance(self.git_provider, GitLabProvider):
|
if isinstance(self.git_provider, GitLabProvider):
|
||||||
model_answer_sanitized = self.gitlab_protctions(model_answer_sanitized)
|
model_answer_sanitized = self.gitlab_protections(model_answer_sanitized)
|
||||||
if model_answer_sanitized.startswith("/"):
|
if model_answer_sanitized.startswith("/"):
|
||||||
model_answer_sanitized = " " + model_answer_sanitized
|
model_answer_sanitized = " " + model_answer_sanitized
|
||||||
if model_answer_sanitized != model_answer:
|
if model_answer_sanitized != model_answer:
|
||||||
|
Reference in New Issue
Block a user