|
24 | 24 | ALLOWED_LABELS = { |
25 | 25 | "0.kind bug report", |
26 | 26 | "0.kind feature request", |
| 27 | + "bug: login or signup", |
27 | 28 | "bot-processed", |
28 | 29 | } |
29 | 30 |
|
|
77 | 78 | # Structured Output Schema |
78 | 79 | # ============================================================================ |
79 | 80 |
|
| 81 | +SIGNUP_LOGIN_SYSTEM_PROMPT = """You are a GitHub issue classifier for Couchers.org, a couch surfing platform. |
| 82 | +
|
| 83 | +Your job is to determine whether a GitHub issue is related to signup or login. |
| 84 | +
|
| 85 | +This includes issues about: |
| 86 | +- Creating a new account / signing up / registration |
| 87 | +- Logging in / authentication |
| 88 | +- Email verification during signup |
| 89 | +- Account activation |
| 90 | +- Unable to sign in or sign up |
| 91 | +- Session expiry / being logged out unexpectedly |
| 92 | +
|
| 93 | +If the issue is related to any of these topics, respond with is_signup_or_login = true. |
| 94 | +Otherwise, respond with is_signup_or_login = false. |
| 95 | +
|
| 96 | +Provide brief reasoning for your decision.""" |
| 97 | + |
| 98 | + |
| 99 | +class SignupLoginDecision(BaseModel): |
| 100 | + """Structured output for signup/login classification.""" |
| 101 | + |
| 102 | + reasoning: str = Field( |
| 103 | + description="Brief explanation of why this is or isn't related to signup/login" |
| 104 | + ) |
| 105 | + |
| 106 | + is_signup_or_login: bool = Field( |
| 107 | + description="Whether the issue is related to signup or login" |
| 108 | + ) |
| 109 | + |
| 110 | + |
80 | 111 | class IssueAction(str, Enum): |
81 | 112 | """Actions the bot can take on an issue.""" |
82 | 113 | CLOSE = "close" |
@@ -137,6 +168,39 @@ def __init__(self): |
137 | 168 | self.repo = self.github_client.get_repo(self.repo_name) |
138 | 169 | self.issue = self.repo.get_issue(self.issue_number) |
139 | 170 |
|
| 171 | + def check_signup_login(self) -> SignupLoginDecision: |
| 172 | + """Use LLM to check if the issue is related to signup or login.""" |
| 173 | + prompt = f"""{SIGNUP_LOGIN_SYSTEM_PROMPT} |
| 174 | +
|
| 175 | +Analyze this GitHub issue: |
| 176 | +
|
| 177 | +**Title:** {self.issue_title} |
| 178 | +
|
| 179 | +**Body:** |
| 180 | +{self.issue_body or "(empty)"} |
| 181 | +
|
| 182 | +Respond only in JSON with the following format: |
| 183 | +
|
| 184 | +```json |
| 185 | +{json.dumps(SignupLoginDecision.model_json_schema())} |
| 186 | +``` |
| 187 | +""" |
| 188 | + |
| 189 | + print(f"\nChecking if issue #{self.issue_number} is related to signup/login...") |
| 190 | + decision_dict = self.llm.json_complete(prompt, response_format=SignupLoginDecision) |
| 191 | + decision = SignupLoginDecision(**decision_dict) |
| 192 | + |
| 193 | + print(f"Signup/Login: {decision.is_signup_or_login}") |
| 194 | + print(f"Reasoning: {decision.reasoning}") |
| 195 | + |
| 196 | + return decision |
| 197 | + |
| 198 | + def apply_signup_login_decision(self, decision: SignupLoginDecision): |
| 199 | + """Apply the signup/login label if applicable.""" |
| 200 | + if decision.is_signup_or_login: |
| 201 | + print(f"\nAdding 'bug: login or signup' label...") |
| 202 | + self.issue.add_to_labels("bug: login or signup") |
| 203 | + |
140 | 204 | def analyze_issue(self) -> BotDecision: |
141 | 205 | """Use LLM to analyze the issue and determine actions.""" |
142 | 206 | prompt = f"""{SYSTEM_PROMPT} |
@@ -242,6 +306,9 @@ def apply_decision(self, decision: BotDecision): |
242 | 306 | def run(self): |
243 | 307 | """Main execution flow.""" |
244 | 308 | try: |
| 309 | + signup_login_decision = self.check_signup_login() |
| 310 | + self.apply_signup_login_decision(signup_login_decision) |
| 311 | + |
245 | 312 | decision = self.analyze_issue() |
246 | 313 | self.apply_decision(decision) |
247 | 314 | except Exception as e: |
|
0 commit comments