bluenevus's picture
Create app.py
623599c verified
raw
history blame
1.94 kB
import gradio as gr
import os
from github import Github
from datetime import datetime
import google.generativeai as genai
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
# Configure Gemini API
genai.configure(api_key=gemini_api_key)
model = genai.GenerativeModel('gemini-2.5-pro-preview-03-25')
# Initialize GitHub client
g = Github(github_token)
# Extract repository name from URL
repo_name = github_url.split('/')[-1].replace('.git', '')
repo = g.get_repo(f"MicroHealthLLC/{repo_name}")
# Convert dates to datetime objects
start_date = datetime.strptime(start_date, "%Y-%m-%d")
end_date = datetime.strptime(end_date, "%Y-%m-%d")
# Fetch commits
commits = repo.get_commits(since=start_date, until=end_date)
# Prepare commit messages for AI analysis
commit_messages = [commit.commit.message for commit in commits]
commit_text = "\n".join(commit_messages)
# Generate release notes using Gemini
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."
response = model.generate_content(prompt)
return response.text
# Create Gradio interface
iface = gr.Interface(
fn=generate_release_notes,
inputs=[
gr.Textbox(label="GitHub Repository URL (e.g., https://github.com/MicroHealthLLC/maiko-assistant.git)"),
gr.Textbox(label="GitHub Personal Access Token", type="password"),
gr.Textbox(label="Gemini API Key", type="password"),
gr.Textbox(label="Start Date (YYYY-MM-DD)"),
gr.Textbox(label="End Date (YYYY-MM-DD)")
],
outputs=gr.Textbox(label="Generated Release Notes"),
title="Automated Release Notes Generator",
description="Generate release notes based on GitHub commits using Gemini AI."
)
# Launch the app
iface.launch()