Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,10 @@ import docx
|
|
| 7 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
| 8 |
try:
|
| 9 |
g = Github(github_token)
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
| 13 |
end_date = datetime.strptime(end_date, "%Y-%m-%d")
|
|
@@ -65,7 +68,7 @@ def generate_release_notes(github_url, github_token, gemini_api_key, start_date,
|
|
| 65 |
if e.status == 401:
|
| 66 |
return "Error: Invalid GitHub token or insufficient permissions.", None
|
| 67 |
elif e.status == 404:
|
| 68 |
-
return f"Error: Repository not found. Please check the GitHub URL. Attempted to access: {
|
| 69 |
else:
|
| 70 |
return f"GitHub API error: {str(e)}", None
|
| 71 |
except Exception as e:
|
|
@@ -77,7 +80,7 @@ default_start_date = default_end_date - timedelta(days=30)
|
|
| 77 |
iface = gr.Interface(
|
| 78 |
fn=generate_release_notes,
|
| 79 |
inputs=[
|
| 80 |
-
gr.Textbox(label="GitHub Repository
|
| 81 |
gr.Textbox(label="GitHub Personal Access Token", type="password"),
|
| 82 |
gr.Textbox(label="Gemini API Key", type="password"),
|
| 83 |
gr.Textbox(
|
|
|
|
| 7 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
| 8 |
try:
|
| 9 |
g = Github(github_token)
|
| 10 |
+
|
| 11 |
+
# Extract the repository name from the full URL
|
| 12 |
+
repo_name = '/'.join(github_url.split('/')[-2:])
|
| 13 |
+
repo = g.get_repo(repo_name)
|
| 14 |
|
| 15 |
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
| 16 |
end_date = datetime.strptime(end_date, "%Y-%m-%d")
|
|
|
|
| 68 |
if e.status == 401:
|
| 69 |
return "Error: Invalid GitHub token or insufficient permissions.", None
|
| 70 |
elif e.status == 404:
|
| 71 |
+
return f"Error: Repository not found. Please check the GitHub URL. Attempted to access: {repo_name}", None
|
| 72 |
else:
|
| 73 |
return f"GitHub API error: {str(e)}", None
|
| 74 |
except Exception as e:
|
|
|
|
| 80 |
iface = gr.Interface(
|
| 81 |
fn=generate_release_notes,
|
| 82 |
inputs=[
|
| 83 |
+
gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/MicroHealthLLC/maiko-assistant"),
|
| 84 |
gr.Textbox(label="GitHub Personal Access Token", type="password"),
|
| 85 |
gr.Textbox(label="Gemini API Key", type="password"),
|
| 86 |
gr.Textbox(
|