|
import gradio as gr |
|
from datetime import datetime, timedelta |
|
|
|
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date): |
|
|
|
|
|
try: |
|
start = datetime.strptime(start_date, "%Y-%m-%d") |
|
end = datetime.strptime(end_date, "%Y-%m-%d") |
|
days = (end - start).days |
|
|
|
notes = f"Release Notes for {github_url}\n" |
|
notes += f"Period: From {start_date} to {end_date} ({days} days)\n\n" |
|
notes += "1. New Features:\n - Feature A added\n - Feature B implemented\n\n" |
|
notes += "2. Bug Fixes:\n - Fixed issue with login\n - Resolved performance problem in module X\n\n" |
|
notes += "3. Improvements:\n - Enhanced user interface\n - Optimized database queries\n\n" |
|
notes += "Note: This is a simulated output. Actual implementation would use GitHub API and Gemini AI." |
|
|
|
return notes |
|
except ValueError: |
|
return "Error: Invalid date format. Please use YYYY-MM-DD." |
|
|
|
|
|
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", placeholder="https://github.com/username/repo.git"), |
|
gr.Textbox(label="GitHub Personal Access Token", type="password"), |
|
gr.Textbox(label="Gemini API Key", type="password"), |
|
gr.Textbox( |
|
label="Start Date", |
|
placeholder="YYYY-MM-DD", |
|
value=default_start_date.strftime("%Y-%m-%d"), |
|
), |
|
gr.Textbox( |
|
label="End Date", |
|
placeholder="YYYY-MM-DD", |
|
value=default_end_date.strftime("%Y-%m-%d"), |
|
) |
|
], |
|
outputs=gr.Textbox(label="Generated Release Notes"), |
|
title="Automated Release Notes Generator", |
|
description="Generate release notes based on GitHub commits using Gemini AI. Enter start and end dates (YYYY-MM-DD) to define the time range for commits.", |
|
allow_flagging="never", |
|
theme="default", |
|
analytics_enabled=False, |
|
) |
|
|
|
|
|
iface.launch() |