mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
feat: Add debug logs to git_provider and pr_description modules
This commit is contained in:
@ -75,15 +75,18 @@ class GitProvider(ABC):
|
|||||||
def get_user_description(self) -> str:
|
def get_user_description(self) -> str:
|
||||||
description = (self.get_pr_description_full() or "").strip()
|
description = (self.get_pr_description_full() or "").strip()
|
||||||
description_lowercase = description.lower()
|
description_lowercase = description.lower()
|
||||||
|
get_logger().debug(f"Existing description\n{description}")
|
||||||
|
|
||||||
# if the existing description wasn't generated by the pr-agent, just return it as-is
|
# if the existing description wasn't generated by the pr-agent, just return it as-is
|
||||||
if not self._is_generated_by_pr_agent(description_lowercase):
|
if not self._is_generated_by_pr_agent(description_lowercase):
|
||||||
|
get_logger().debug(f"Existing description was not generated by the pr-agent")
|
||||||
return description
|
return description
|
||||||
|
|
||||||
# if the existing description was generated by the pr-agent, but it doesn't contain a user description,
|
# if the existing description was generated by the pr-agent, but it doesn't contain a user description,
|
||||||
# return nothing (empty string) because it means there is no user description
|
# return nothing (empty string) because it means there is no user description
|
||||||
user_description_header = "## user description"
|
user_description_header = "## user description"
|
||||||
if user_description_header not in description_lowercase:
|
if user_description_header not in description_lowercase:
|
||||||
|
get_logger().debug(f"Existing description was generated by the pr-agent, but it doesn't contain a user description")
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
# otherwise, extract the original user description from the existing pr-agent description and return it
|
# otherwise, extract the original user description from the existing pr-agent description and return it
|
||||||
@ -106,6 +109,7 @@ class GitProvider(ABC):
|
|||||||
if original_user_description.lower().startswith(user_description_header):
|
if original_user_description.lower().startswith(user_description_header):
|
||||||
original_user_description = original_user_description[len(user_description_header):].strip()
|
original_user_description = original_user_description[len(user_description_header):].strip()
|
||||||
|
|
||||||
|
get_logger().debug(f"Extracted user description from existing description\n{original_user_description}")
|
||||||
return original_user_description
|
return original_user_description
|
||||||
|
|
||||||
def _possible_headers(self):
|
def _possible_headers(self):
|
||||||
|
@ -99,6 +99,7 @@ class PRDescription:
|
|||||||
else:
|
else:
|
||||||
pr_title, pr_body, = self._prepare_pr_answer()
|
pr_title, pr_body, = self._prepare_pr_answer()
|
||||||
full_markdown_description = f"## Title\n\n{pr_title}\n\n___\n{pr_body}"
|
full_markdown_description = f"## Title\n\n{pr_title}\n\n___\n{pr_body}"
|
||||||
|
get_logger().debug(f"full_markdown_description:\n{full_markdown_description}")
|
||||||
|
|
||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
get_logger().info(f"Pushing answer {self.pr_id}")
|
get_logger().info(f"Pushing answer {self.pr_id}")
|
||||||
@ -165,10 +166,6 @@ class PRDescription:
|
|||||||
system_prompt = environment.from_string(get_settings().pr_description_prompt.system).render(variables)
|
system_prompt = environment.from_string(get_settings().pr_description_prompt.system).render(variables)
|
||||||
user_prompt = environment.from_string(get_settings().pr_description_prompt.user).render(variables)
|
user_prompt = environment.from_string(get_settings().pr_description_prompt.user).render(variables)
|
||||||
|
|
||||||
if get_settings().config.verbosity_level >= 2:
|
|
||||||
get_logger().info(f"\nSystem prompt:\n{system_prompt}")
|
|
||||||
get_logger().info(f"\nUser prompt:\n{user_prompt}")
|
|
||||||
|
|
||||||
response, finish_reason = await self.ai_handler.chat_completion(
|
response, finish_reason = await self.ai_handler.chat_completion(
|
||||||
model=model,
|
model=model,
|
||||||
temperature=0.2,
|
temperature=0.2,
|
||||||
|
Reference in New Issue
Block a user