Spaces:
Sleeping
Sleeping
Update appaaa.py
Browse files
appaaa.py
CHANGED
@@ -205,16 +205,17 @@ async def respond(
|
|
205 |
return f"ℹ️ Current GitHub connection: {github_client.config.username}/{github_client.config.repository}"
|
206 |
else:
|
207 |
return "ℹ️ Not connected to GitHub"
|
208 |
-
|
209 |
parts = args.split(maxsplit=2) # Allow spaces in token
|
210 |
if len(parts) < 3:
|
211 |
raise ValueError("Format: /github <username> <repo> <token>")
|
212 |
-
|
213 |
github_client = GitHubIntegration(GitHubConfig(
|
214 |
username=parts[0],
|
215 |
repository=parts[1],
|
216 |
api_token=SecretStr(parts[2])
|
217 |
))
|
|
|
218 |
return "✅ GitHub configured successfully"
|
219 |
except Exception as e:
|
220 |
github_client = None
|
@@ -229,6 +230,7 @@ async def respond(
|
|
229 |
- `/write_documentation [topic]`: Write documentation for a given topic.
|
230 |
- `/translate_code [code] to [target language]`: Translate code to another language.
|
231 |
- `/analyze [issue number]`: Analyze a GitHub issue.
|
|
|
232 |
"""
|
233 |
yield help_message # Yield the pre-formatted help message
|
234 |
|
@@ -331,6 +333,21 @@ async def respond(
|
|
331 |
logging.error("Error analyzing issue: {}".format(e))
|
332 |
yield "Error analyzing issue: {}".format(e)
|
333 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
else:
|
335 |
# Handle other commands or provide a default response
|
336 |
yield "I'm not sure what you mean. Try using `/help` for a list of available commands."
|
@@ -358,7 +375,8 @@ iface = gr.Interface(
|
|
358 |
examples=[
|
359 |
"/generate Create a REST API with FastAPI",
|
360 |
"/analyze Memory leak in data processing pipeline",
|
361 |
-
"/github octocat hello-world ghp_12345"
|
|
|
362 |
],
|
363 |
inputs=[chat.textbox] # Point to chat input instead of model selector
|
364 |
)
|
|
|
205 |
return f"ℹ️ Current GitHub connection: {github_client.config.username}/{github_client.config.repository}"
|
206 |
else:
|
207 |
return "ℹ️ Not connected to GitHub"
|
208 |
+
|
209 |
parts = args.split(maxsplit=2) # Allow spaces in token
|
210 |
if len(parts) < 3:
|
211 |
raise ValueError("Format: /github <username> <repo> <token>")
|
212 |
+
|
213 |
github_client = GitHubIntegration(GitHubConfig(
|
214 |
username=parts[0],
|
215 |
repository=parts[1],
|
216 |
api_token=SecretStr(parts[2])
|
217 |
))
|
218 |
+
issues = await github_client.fetch_issues() # Fetch issues after successful connection
|
219 |
return "✅ GitHub configured successfully"
|
220 |
except Exception as e:
|
221 |
github_client = None
|
|
|
230 |
- `/write_documentation [topic]`: Write documentation for a given topic.
|
231 |
- `/translate_code [code] to [target language]`: Translate code to another language.
|
232 |
- `/analyze [issue number]`: Analyze a GitHub issue.
|
233 |
+
- `/list_issues`: List all issues in the connected repository.
|
234 |
"""
|
235 |
yield help_message # Yield the pre-formatted help message
|
236 |
|
|
|
333 |
logging.error("Error analyzing issue: {}".format(e))
|
334 |
yield "Error analyzing issue: {}".format(e)
|
335 |
|
336 |
+
elif command == "/list_issues":
|
337 |
+
try:
|
338 |
+
if not github_client:
|
339 |
+
return "❌ You need to connect to a GitHub repository first using `/github <username> <repo> <token>`."
|
340 |
+
if issues:
|
341 |
+
issue_list = "\n".join(
|
342 |
+
[f"- {issue['title']} (Issue #{issue['number']})" for issue in issues]
|
343 |
+
)
|
344 |
+
yield f"Issues in {github_client.config.username}/{github_client.config.repository}:\n{issue_list}"
|
345 |
+
else:
|
346 |
+
return "❌ No issues found in the connected repository."
|
347 |
+
except Exception as e:
|
348 |
+
logging.error("Error listing issues: {}".format(e))
|
349 |
+
yield "Error listing issues: {}".format(e)
|
350 |
+
|
351 |
else:
|
352 |
# Handle other commands or provide a default response
|
353 |
yield "I'm not sure what you mean. Try using `/help` for a list of available commands."
|
|
|
375 |
examples=[
|
376 |
"/generate Create a REST API with FastAPI",
|
377 |
"/analyze Memory leak in data processing pipeline",
|
378 |
+
"/github octocat hello-world ghp_12345",
|
379 |
+
"/list_issues"
|
380 |
],
|
381 |
inputs=[chat.textbox] # Point to chat input instead of model selector
|
382 |
)
|