bluenevus commited on
Commit
623599c
·
verified ·
1 Parent(s): bc01d79

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from github import Github
4
+ from datetime import datetime
5
+ import google.generativeai as genai
6
+
7
+ def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
8
+ # Configure Gemini API
9
+ genai.configure(api_key=gemini_api_key)
10
+ model = genai.GenerativeModel('gemini-2.5-pro-preview-03-25')
11
+
12
+ # Initialize GitHub client
13
+ g = Github(github_token)
14
+
15
+ # Extract repository name from URL
16
+ repo_name = github_url.split('/')[-1].replace('.git', '')
17
+ repo = g.get_repo(f"MicroHealthLLC/{repo_name}")
18
+
19
+ # Convert dates to datetime objects
20
+ start_date = datetime.strptime(start_date, "%Y-%m-%d")
21
+ end_date = datetime.strptime(end_date, "%Y-%m-%d")
22
+
23
+ # Fetch commits
24
+ commits = repo.get_commits(since=start_date, until=end_date)
25
+
26
+ # Prepare commit messages for AI analysis
27
+ commit_messages = [commit.commit.message for commit in commits]
28
+ commit_text = "\n".join(commit_messages)
29
+
30
+ # Generate release notes using Gemini
31
+ prompt = f"Based on the following commit messages, generate comprehensive release notes:\n\n{commit_text}\n\nPlease categorize changes, summarize features, and identify key updates."
32
+ response = model.generate_content(prompt)
33
+
34
+ return response.text
35
+
36
+ # Create Gradio interface
37
+ iface = gr.Interface(
38
+ fn=generate_release_notes,
39
+ inputs=[
40
+ gr.Textbox(label="GitHub Repository URL (e.g., https://github.com/MicroHealthLLC/maiko-assistant.git)"),
41
+ gr.Textbox(label="GitHub Personal Access Token", type="password"),
42
+ gr.Textbox(label="Gemini API Key", type="password"),
43
+ gr.Textbox(label="Start Date (YYYY-MM-DD)"),
44
+ gr.Textbox(label="End Date (YYYY-MM-DD)")
45
+ ],
46
+ outputs=gr.Textbox(label="Generated Release Notes"),
47
+ title="Automated Release Notes Generator",
48
+ description="Generate release notes based on GitHub commits using Gemini AI."
49
+ )
50
+
51
+ # Launch the app
52
+ iface.launch()