feat: 階段一 - 基本流程串接骨架
- 重寫 action.yaml:支援所有 LLM providers 的 inputs - 重寫 Dockerfile:python:3.11-slim + git - 重寫 entrypoint.sh:啟動 app/main.py - app/config.py:環境變數與 LLM 自動偵測 - app/llm.py:OpenAI-compatible 統一介面 - app/gitea.py:PR diff 取得與 comment 發布 - app/roles.py:從 prompts/roles/*.yaml 載入角色 - app/main.py:pipeline 骨架,log 每個主要階段 - app/prompts/roles/:五個角色定義(Aria/Rex/Zara/Leo/Maya)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import requests
|
||||
from config import GITEA_TOKEN, GITEA_SERVER_URL, GITEA_REPOSITORY, PR_NUMBER
|
||||
|
||||
|
||||
def _headers():
|
||||
return {"Authorization": f"token {GITEA_TOKEN}", "Content-Type": "application/json"}
|
||||
|
||||
|
||||
def _api(path: str) -> str:
|
||||
return f"{GITEA_SERVER_URL.rstrip('/')}/api/v1{path}"
|
||||
|
||||
|
||||
def get_pr_diff() -> str:
|
||||
"""取得 PR 的 git diff 內容"""
|
||||
url = _api(f"/repos/{GITEA_REPOSITORY}/pulls/{PR_NUMBER}.diff")
|
||||
resp = requests.get(url, headers=_headers(), timeout=60)
|
||||
resp.raise_for_status()
|
||||
return resp.text
|
||||
|
||||
|
||||
def post_comment(body: str) -> dict:
|
||||
"""在 PR 發布 comment"""
|
||||
url = _api(f"/repos/{GITEA_REPOSITORY}/issues/{PR_NUMBER}/comments")
|
||||
resp = requests.post(url, headers=_headers(), json={"body": body}, timeout=30)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
Reference in New Issue
Block a user