bluenevus commited on
Commit
dd98907
·
verified ·
1 Parent(s): 4a7d57e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -16
app.py CHANGED
@@ -3,24 +3,12 @@ from datetime import datetime, timedelta
3
  import google.generativeai as genai
4
  from github import Github, GithubException
5
  import docx
6
- import re
7
 
8
- def extract_repo_name(github_url):
9
- # Use regex to extract the username and repo name from the URL
10
- match = re.search(r'github\.com/([^/]+)/([^/]+)', github_url)
11
- if match:
12
- return f"{match.group(1)}/{match.group(2)}"
13
- return None
14
-
15
- def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
16
  try:
17
  g = Github(github_token)
18
 
19
- repo_name = extract_repo_name(github_url)
20
- if not repo_name:
21
- return "Error: Invalid GitHub URL format.", None
22
-
23
- repo = g.get_repo(repo_name)
24
 
25
  start_date = datetime.strptime(start_date, "%Y-%m-%d")
26
  end_date = datetime.strptime(end_date, "%Y-%m-%d")
@@ -78,7 +66,7 @@ def generate_release_notes(github_url, github_token, gemini_api_key, start_date,
78
  if e.status == 401:
79
  return "Error: Invalid GitHub token or insufficient permissions.", None
80
  elif e.status == 404:
81
- return f"Error: Repository not found. Please check the GitHub URL. Attempted to access: {repo_name}", None
82
  else:
83
  return f"GitHub API error: {str(e)}", None
84
  except Exception as e:
@@ -90,7 +78,7 @@ default_start_date = default_end_date - timedelta(days=30)
90
  iface = gr.Interface(
91
  fn=generate_release_notes,
92
  inputs=[
93
- gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/MicroHealthLLC/maiko-assistant"),
94
  gr.Textbox(label="GitHub Personal Access Token", type="password"),
95
  gr.Textbox(label="Gemini API Key", type="password"),
96
  gr.Textbox(
 
3
  import google.generativeai as genai
4
  from github import Github, GithubException
5
  import docx
 
6
 
7
+ def generate_release_notes(github_repo, github_token, gemini_api_key, start_date, end_date):
 
 
 
 
 
 
 
8
  try:
9
  g = Github(github_token)
10
 
11
+ repo = g.get_repo(github_repo)
 
 
 
 
12
 
13
  start_date = datetime.strptime(start_date, "%Y-%m-%d")
14
  end_date = datetime.strptime(end_date, "%Y-%m-%d")
 
66
  if e.status == 401:
67
  return "Error: Invalid GitHub token or insufficient permissions.", None
68
  elif e.status == 404:
69
+ return f"Error: Repository not found. Please check the GitHub repository name. Attempted to access: {github_repo}", None
70
  else:
71
  return f"GitHub API error: {str(e)}", None
72
  except Exception as e:
 
78
  iface = gr.Interface(
79
  fn=generate_release_notes,
80
  inputs=[
81
+ gr.Textbox(label="GitHub Repository Name", placeholder="MicroHealthLLC/maiko-assistant"),
82
  gr.Textbox(label="GitHub Personal Access Token", type="password"),
83
  gr.Textbox(label="Gemini API Key", type="password"),
84
  gr.Textbox(