bluenevus's picture
Update app.py
23fc6d3 verified
raw
history blame
1.91 kB
import gradio as gr
from datetime import datetime, timedelta
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
# Convert start_date and end_date to datetime objects if they're not already
if isinstance(start_date, str):
start_date = datetime.fromisoformat(start_date).date()
elif isinstance(start_date, datetime):
start_date = start_date.date()
if isinstance(end_date, str):
end_date = datetime.fromisoformat(end_date).date()
elif isinstance(end_date, datetime):
end_date = end_date.date()
# Your existing function implementation here
# ...
return f"Generated release notes for {github_url} from {start_date} to {end_date}"
# Set default dates
default_end_date = datetime.now()
default_start_date = default_end_date - timedelta(days=7) # One week ago
# 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.DateTime(
label="Start Date",
value=default_start_date.date(),
type="date",
interactive=True,
visible=True
),
gr.DateTime(
label="End Date",
value=default_end_date.date(),
type="date",
interactive=True,
visible=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."
)
# Launch the app with a public link
iface.launch(share=True)