feat: graceful skip without API key + finalize workflows (container/memory caps, ARM64)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,10 @@ def main() -> int:
|
||||
return 2
|
||||
|
||||
kind = KINDS[sys.argv[1]]
|
||||
ok, why = llm.configured()
|
||||
if not ok:
|
||||
print(f"[ai_explain] KI inaktiv ({why}) — Erklärung sauber übersprungen, kein Fehler.")
|
||||
return 0
|
||||
with open(sys.argv[2], encoding="utf-8", errors="replace") as fh:
|
||||
text = fh.read()
|
||||
if len(text) > LOG_CAP:
|
||||
|
||||
@@ -74,6 +74,11 @@ def main() -> int:
|
||||
print("[ai_review] PR vom Bot selbst — übersprungen.")
|
||||
return 0
|
||||
|
||||
ok, why = llm.configured()
|
||||
if not ok:
|
||||
print(f"[ai_review] KI inaktiv ({why}) — Schritt sauber übersprungen, kein Fehler.")
|
||||
return 0
|
||||
|
||||
diff = filter_diff(gitea_api.get_pr_diff(owner, repo, pr["index"]))
|
||||
if not diff:
|
||||
print("[ai_review] Leerer/gefilterter Diff — nichts zu reviewen.")
|
||||
|
||||
@@ -23,6 +23,22 @@ import urllib.error
|
||||
import urllib.request
|
||||
|
||||
|
||||
def configured():
|
||||
"""(ok, grund) — ob das gewählte Backend nutzbar konfiguriert ist.
|
||||
|
||||
Erlaubt den Workflows, den KI-Schritt sauber zu ÜBERSPRINGEN (exit 0) statt
|
||||
zu failen, solange z.B. noch kein ANTHROPIC_API_KEY hinterlegt ist.
|
||||
"""
|
||||
provider = os.environ.get("AI_PROVIDER", "anthropic").lower()
|
||||
if provider == "anthropic":
|
||||
if not os.environ.get("ANTHROPIC_API_KEY"):
|
||||
return False, "ANTHROPIC_API_KEY ist nicht gesetzt"
|
||||
return True, ""
|
||||
if provider == "ollama":
|
||||
return True, "" # Erreichbarkeit wird beim eigentlichen Call geprüft
|
||||
return False, f"unbekannter AI_PROVIDER: {provider!r}"
|
||||
|
||||
|
||||
def complete(system: str, user: str, *, max_tokens: int = 1500) -> str:
|
||||
"""Schickt (system, user) ans konfigurierte Backend, gibt reinen Text zurück."""
|
||||
provider = os.environ.get("AI_PROVIDER", "anthropic").lower()
|
||||
|
||||
Reference in New Issue
Block a user