|
|
|
import gradio as gr |
|
from datetime import datetime, timedelta |
|
import requests |
|
|
|
def get_subdirectories(url): |
|
response = requests.get(url) |
|
links = response.text.split('<a href="') |
|
subdirectories = [link.split('"')[0] for link in links if link.startswith('/docs/gradio/')] |
|
return subdirectories |
|
|
|
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date): |
|
|
|
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() |
|
|
|
|
|
base_url = "https://www.gradio.app" |
|
subdirectories = get_subdirectories(base_url + "/docs/gradio/") |
|
full_urls = [base_url + subdir for subdir in subdirectories] |
|
|
|
|
|
|
|
return f"Generated release notes for {github_url} from {start_date} to {end_date}\n\nSubdirectories:\n" + "\n".join(full_urls) |
|
|
|
|
|
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.Date( |
|
label="Start Date", |
|
value=default_start_date.date(), |
|
), |
|
gr.Date( |
|
label="End Date", |
|
value=default_end_date.date(), |
|
) |
|
], |
|
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() |