Update app.py
Browse files
app.py
CHANGED
@@ -1,33 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
-
import os
|
3 |
-
from github import Github
|
4 |
from datetime import datetime, timedelta
|
5 |
-
import google.generativeai as genai
|
6 |
|
7 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
# Initialize GitHub client
|
13 |
-
g = Github(github_token)
|
14 |
-
|
15 |
-
# Extract repository name from URL
|
16 |
-
repo_name = github_url.split('/')[-1].replace('.git', '')
|
17 |
-
repo = g.get_repo(f"MicroHealthLLC/{repo_name}")
|
18 |
-
|
19 |
-
# Fetch commits
|
20 |
-
commits = repo.get_commits(since=start_date, until=end_date)
|
21 |
-
|
22 |
-
# Prepare commit messages for AI analysis
|
23 |
-
commit_messages = [commit.commit.message for commit in commits]
|
24 |
-
commit_text = "\n".join(commit_messages)
|
25 |
-
|
26 |
-
# Generate release notes using Gemini
|
27 |
-
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."
|
28 |
-
response = model.generate_content(prompt)
|
29 |
-
|
30 |
-
return response.text
|
31 |
|
32 |
# Set default dates
|
33 |
default_end_date = datetime.now()
|
@@ -44,18 +21,33 @@ iface = gr.Interface(
|
|
44 |
label="Start Date",
|
45 |
value=default_start_date.isoformat(),
|
46 |
type="datetime",
|
47 |
-
include_time=True
|
|
|
|
|
48 |
),
|
49 |
gr.DateTime(
|
50 |
label="End Date",
|
51 |
value=default_end_date.isoformat(),
|
52 |
type="datetime",
|
53 |
-
include_time=True
|
|
|
|
|
54 |
)
|
55 |
],
|
56 |
outputs=gr.Textbox(label="Generated Release Notes"),
|
57 |
title="Automated Release Notes Generator",
|
58 |
-
description="Generate release notes based on GitHub commits using Gemini AI. Select start and end dates to define the time range for commits."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
)
|
60 |
|
61 |
# Launch the app
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from datetime import datetime, timedelta
|
|
|
3 |
|
4 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
5 |
+
# Your existing function implementation here
|
6 |
+
# ...
|
7 |
+
return "Generated release notes would appear here."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Set default dates
|
10 |
default_end_date = datetime.now()
|
|
|
21 |
label="Start Date",
|
22 |
value=default_start_date.isoformat(),
|
23 |
type="datetime",
|
24 |
+
include_time=True,
|
25 |
+
interactive=True,
|
26 |
+
visible=True
|
27 |
),
|
28 |
gr.DateTime(
|
29 |
label="End Date",
|
30 |
value=default_end_date.isoformat(),
|
31 |
type="datetime",
|
32 |
+
include_time=True,
|
33 |
+
interactive=True,
|
34 |
+
visible=True
|
35 |
)
|
36 |
],
|
37 |
outputs=gr.Textbox(label="Generated Release Notes"),
|
38 |
title="Automated Release Notes Generator",
|
39 |
+
description="Generate release notes based on GitHub commits using Gemini AI. Select start and end dates to define the time range for commits.",
|
40 |
+
allow_flagging="never",
|
41 |
+
theme="default",
|
42 |
+
analytics_enabled=False,
|
43 |
+
show_progress="full",
|
44 |
+
queue=False,
|
45 |
+
batch=False,
|
46 |
+
max_batch_size=4,
|
47 |
+
api_name=None,
|
48 |
+
scroll_to_output=True,
|
49 |
+
preprocess=True,
|
50 |
+
postprocess=True
|
51 |
)
|
52 |
|
53 |
# Launch the app
|