Files
code-review/app/roles.py
T
jiantw83 1324f1575d 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)
2026-05-11 07:23:06 +00:00

23 lines
657 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
import yaml
ROLES_DIR = "/action/app/prompts/roles"
def load_roles() -> list[dict]:
"""載入所有角色定義"""
roles = []
for fname in sorted(os.listdir(ROLES_DIR)):
if fname.endswith(".yaml"):
with open(os.path.join(ROLES_DIR, fname), "r", encoding="utf-8") as f:
roles.append(yaml.safe_load(f))
return roles
def get_role_intro(roles: list[dict]) -> str:
"""產生角色介紹文字(用於 comment"""
lines = ["## 🤖 AI Code Review 團隊", ""]
for r in roles:
lines.append(f"- **{r['name']}** ({r['role']}): {r['personality']}")
return "\n".join(lines)