feat: Add referenced file footers to AI comments and correct Gitea PR 'synchronize' action to 'synchronized'.
This commit is contained in:
parent
d01d3850df
commit
7fa9bb5c26
|
|
@ -22,7 +22,7 @@ async def process_gitea_event(event_type: str, payload: dict):
|
||||||
ci_service = CIService(db)
|
ci_service = CIService(db)
|
||||||
if event_type == "pull_request":
|
if event_type == "pull_request":
|
||||||
action = payload.get("action")
|
action = payload.get("action")
|
||||||
if action in ["opened", "synchronize", "reopened"]:
|
if action in ["opened", "synchronized", "reopened"]:
|
||||||
logger.info(f"Starting background PR processing for action: {action}")
|
logger.info(f"Starting background PR processing for action: {action}")
|
||||||
await ci_service.handle_pr_event(payload)
|
await ci_service.handle_pr_event(payload)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,10 @@ PR_REVIEW_TASK = """
|
||||||
PR_REVIEW_OUTPUT_FORMAT = """
|
PR_REVIEW_OUTPUT_FORMAT = """
|
||||||
仅输出 Markdown 格式的响应,格式如下:
|
仅输出 Markdown 格式的响应,格式如下:
|
||||||
|
|
||||||
## 🔍 DeepAudit 评审摘要
|
## 🔍 AI Review 摘要
|
||||||
<简要总结变更内容及整体风险等级>
|
<简要总结变更内容及整体风险等级>
|
||||||
|
|
||||||
## 🛡️ 发现评审意见
|
## 🛡️ 评审意见
|
||||||
### [严重程度: 高/中/低] <意见标题>
|
### [严重程度: 高/中/低] <意见标题>
|
||||||
- **文件**: `<文件路径>`
|
- **文件**: `<文件路径>`
|
||||||
- **意见**: <描述具体问题或改进建议>
|
- **意见**: <描述具体问题或改进建议>
|
||||||
|
|
@ -101,7 +101,7 @@ PR_SYNC_TASK = """
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
CHAT_SYSTEM_PROMPT = """
|
CHAT_SYSTEM_PROMPT = """
|
||||||
你是 DeepAudit Bot,一个集成在 CI/CD 工作流中的得力 AI 助手。
|
你是 AI Code Review Bot,一个集成在 CI/CD 工作流中的得力 AI 助手。
|
||||||
你正在 PR 评论区与开发者交流。
|
你正在 PR 评论区与开发者交流。
|
||||||
用户提到了你 (@ai-bot) 以询问问题或请求澄清。
|
用户提到了你 (@ai-bot) 以询问问题或请求澄清。
|
||||||
你可以通过 RAG (检索增强生成) 访问代码库的相关片段,并能看到当前的 PR 差异。
|
你可以通过 RAG (检索增强生成) 访问代码库的相关片段,并能看到当前的 PR 差异。
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ class CIService:
|
||||||
repo_context = "\n".join([r.to_context_string() for r in context_results])
|
repo_context = "\n".join([r.to_context_string() for r in context_results])
|
||||||
|
|
||||||
# 5. 生成评审
|
# 5. 生成评审
|
||||||
if action == "synchronize":
|
if action == "synchronized":
|
||||||
# 增量同步模式:获取全部对话历史
|
# 增量同步模式:获取全部对话历史
|
||||||
history = await self._get_conversation_history(repo, pr_number)
|
history = await self._get_conversation_history(repo, pr_number)
|
||||||
|
|
||||||
|
|
@ -125,7 +125,10 @@ class CIService:
|
||||||
review_body = response["content"]
|
review_body = response["content"]
|
||||||
|
|
||||||
# 6. Post Comment
|
# 6. Post Comment
|
||||||
await self._post_gitea_comment(repo, pr_number, review_body)
|
# 附加上下文信息页脚
|
||||||
|
footer_parts = [f"`{r.file_path}`" for r in context_results]
|
||||||
|
footer = "\n\n---\n*本次评审参考了以下文件: " + (", ".join(footer_parts) if footer_parts else "无(使用了模型通用知识)") + "*"
|
||||||
|
await self._post_gitea_comment(repo, pr_number, review_body + footer)
|
||||||
|
|
||||||
# 7. Save Record
|
# 7. Save Record
|
||||||
review_record = PRReview(
|
review_record = PRReview(
|
||||||
|
|
@ -262,7 +265,7 @@ class CIService:
|
||||||
# 7. 回复
|
# 7. 回复
|
||||||
# 附加上下文信息页脚
|
# 附加上下文信息页脚
|
||||||
footer_parts = [f"`{r.file_path}`" for r in context_results]
|
footer_parts = [f"`{r.file_path}`" for r in context_results]
|
||||||
footer = "\n\n---\n*本次回答参考了以下文件上下文: " + (", ".join(footer_parts) if footer_parts else "无(使用了模型通用知识)") + "*"
|
footer = "\n\n---\n*本次回答参考了以下文件: " + (", ".join(footer_parts) if footer_parts else "无(使用了模型通用知识)") + "*"
|
||||||
await self._post_gitea_comment(repo, issue.get("number"), answer + footer)
|
await self._post_gitea_comment(repo, issue.get("number"), answer + footer)
|
||||||
|
|
||||||
# 6. Record (Optional, maybe just log)
|
# 6. Record (Optional, maybe just log)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue