Update app.py
Browse files
app.py
CHANGED
@@ -2,17 +2,18 @@ import gradio as gr
|
|
2 |
from datetime import datetime, timedelta
|
3 |
import google.generativeai as genai
|
4 |
from github import Github, GithubException
|
|
|
5 |
|
6 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
7 |
try:
|
8 |
# Initialize GitHub client with the token
|
9 |
g = Github(github_token)
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
owner =
|
15 |
-
repo_name =
|
16 |
|
17 |
# Get the repository
|
18 |
repo = g.get_repo(f"{owner}/{repo_name}")
|
@@ -67,7 +68,7 @@ default_start_date = default_end_date - timedelta(days=7) # One week ago
|
|
67 |
iface = gr.Interface(
|
68 |
fn=generate_release_notes,
|
69 |
inputs=[
|
70 |
-
gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/username/repo"),
|
71 |
gr.Textbox(label="GitHub Personal Access Token", type="password"),
|
72 |
gr.Textbox(label="Gemini API Key", type="password"),
|
73 |
gr.Textbox(
|
|
|
2 |
from datetime import datetime, timedelta
|
3 |
import google.generativeai as genai
|
4 |
from github import Github, GithubException
|
5 |
+
from urllib.parse import urlparse
|
6 |
|
7 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
8 |
try:
|
9 |
# Initialize GitHub client with the token
|
10 |
g = Github(github_token)
|
11 |
|
12 |
+
# Parse the full GitHub URL
|
13 |
+
parsed_url = urlparse(github_url)
|
14 |
+
path_parts = parsed_url.path.strip('/').split('/')
|
15 |
+
owner = path_parts[0]
|
16 |
+
repo_name = path_parts[1].rstrip('.git')
|
17 |
|
18 |
# Get the repository
|
19 |
repo = g.get_repo(f"{owner}/{repo_name}")
|
|
|
68 |
iface = gr.Interface(
|
69 |
fn=generate_release_notes,
|
70 |
inputs=[
|
71 |
+
gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/username/repo.git"),
|
72 |
gr.Textbox(label="GitHub Personal Access Token", type="password"),
|
73 |
gr.Textbox(label="Gemini API Key", type="password"),
|
74 |
gr.Textbox(
|