sammoftah commited on
Commit
640ce83
·
verified ·
1 Parent(s): 1541bc8

Add no-token fallback

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -18,6 +18,39 @@ client = InferenceClient(model="meta-llama/Llama-3.3-70B-Instruct")
18
 
19
  def triage_issue(issue_text: str) -> dict:
20
  """Analyze and triage a GitHub issue"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  prompt = f"""You are a GitHub issue triager. Analyze this issue and provide structured triage information.
23
 
 
18
 
19
  def triage_issue(issue_text: str) -> dict:
20
  """Analyze and triage a GitHub issue"""
21
+ if not os.getenv("HF_TOKEN"):
22
+ text = issue_text.lower()
23
+ labels = []
24
+ if any(word in text for word in ["crash", "error", "bug", "broken", "fails", "failure"]):
25
+ labels.append("bug")
26
+ if any(word in text for word in ["slow", "latency", "performance", "timeout"]):
27
+ labels.append("performance")
28
+ if any(word in text for word in ["docs", "readme", "documentation"]):
29
+ labels.append("documentation")
30
+ if any(word in text for word in ["feature", "request", "support", "add"]):
31
+ labels.append("feature")
32
+ if not labels:
33
+ labels = ["question"]
34
+
35
+ priority = "P1" if any(word in text for word in ["data loss", "security", "cannot login", "down", "crash"]) else "P2"
36
+ severity = "High" if priority == "P1" else "Medium"
37
+ title = issue_text.strip().splitlines()[0][:90] if issue_text.strip() else "Issue report"
38
+ return {
39
+ "title": title,
40
+ "labels": labels[:4],
41
+ "priority": priority,
42
+ "severity": severity,
43
+ "category": "Backend" if any(word in text for word in ["api", "database", "server"]) else "Frontend" if any(word in text for word in ["ui", "button", "page"]) else "Other",
44
+ "estimated_effort": "Medium (1-3 days)" if priority == "P1" else "Small (< 1 day)",
45
+ "suggested_assignee": "Maintainer review",
46
+ "reasoning": {
47
+ "label_reasoning": "Deterministic fallback based on issue keywords because HF_TOKEN is not configured.",
48
+ "priority_reasoning": "Priority estimated from impact words such as crash, security, or data loss.",
49
+ "effort_reasoning": "Fallback estimate; refine after reproduction."
50
+ },
51
+ "related_areas": ["triage", "reproduction"],
52
+ "next_steps": ["Reproduce the issue", "Confirm expected behavior", "Assign owner", "Add regression test if this is a bug"]
53
+ }
54
 
55
  prompt = f"""You are a GitHub issue triager. Analyze this issue and provide structured triage information.
56