|
import gradio as gr |
|
import os |
|
from github import Github |
|
from datetime import datetime, timedelta |
|
import google.generativeai as genai |
|
|
|
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date): |
|
|
|
genai.configure(api_key=gemini_api_key) |
|
model = genai.GenerativeModel('gemini-2.5-pro-preview-03-25') |
|
|
|
|
|
g = Github(github_token) |
|
|
|
|
|
repo_name = github_url.split('/')[-1].replace('.git', '') |
|
repo = g.get_repo(f"MicroHealthLLC/{repo_name}") |
|
|
|
|
|
commits = repo.get_commits(since=start_date, until=end_date) |
|
|
|
|
|
commit_messages = [commit.commit.message for commit in commits] |
|
commit_text = "\n".join(commit_messages) |
|
|
|
|
|
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 |
|
|
|
|
|
default_end_date = datetime.now() |
|
default_start_date = default_end_date - timedelta(days=7) |
|
|
|
|
|
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.DateTime( |
|
label="Start Date", |
|
value=default_start_date.isoformat(), |
|
type="datetime", |
|
include_time=True |
|
), |
|
gr.DateTime( |
|
label="End Date", |
|
value=default_end_date.isoformat(), |
|
type="datetime", |
|
include_time=True |
|
) |
|
], |
|
outputs=gr.Textbox(label="Generated Release Notes"), |
|
title="Automated Release Notes Generator", |
|
description="Generate release notes based on GitHub commits using Gemini AI. Select start and end dates to define the time range for commits." |
|
) |
|
|
|
|
|
iface.launch() |