Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import google.generativeai as genai
|
|
4 |
from github import Github, GithubException
|
5 |
import docx
|
6 |
import re
|
|
|
7 |
|
8 |
def generate_release_notes(github_repo, github_token, gemini_api_key, start_date, end_date):
|
9 |
try:
|
@@ -68,10 +69,15 @@ def generate_release_notes(github_repo, github_token, gemini_api_key, start_date
|
|
68 |
elif line:
|
69 |
doc.add_paragraph(line)
|
70 |
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
return release_notes,
|
75 |
|
76 |
except GithubException as e:
|
77 |
if e.status == 401:
|
@@ -106,7 +112,7 @@ iface = gr.Interface(
|
|
106 |
outputs=[
|
107 |
gr.Textbox(label="Generated Release Notes"),
|
108 |
gr.File(label="Download Release Notes (DOCX)"),
|
109 |
-
gr.File(label="Download Release Notes (Markdown)"
|
110 |
],
|
111 |
title="Automated Release Notes Generator",
|
112 |
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.",
|
|
|
4 |
from github import Github, GithubException
|
5 |
import docx
|
6 |
import re
|
7 |
+
import tempfile
|
8 |
|
9 |
def generate_release_notes(github_repo, github_token, gemini_api_key, start_date, end_date):
|
10 |
try:
|
|
|
69 |
elif line:
|
70 |
doc.add_paragraph(line)
|
71 |
|
72 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.docx') as temp_docx:
|
73 |
+
doc.save(temp_docx.name)
|
74 |
+
docx_path = temp_docx.name
|
75 |
+
|
76 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.md', mode='w', encoding='utf-8') as temp_md:
|
77 |
+
temp_md.write(release_notes)
|
78 |
+
md_path = temp_md.name
|
79 |
|
80 |
+
return release_notes, docx_path, md_path
|
81 |
|
82 |
except GithubException as e:
|
83 |
if e.status == 401:
|
|
|
112 |
outputs=[
|
113 |
gr.Textbox(label="Generated Release Notes"),
|
114 |
gr.File(label="Download Release Notes (DOCX)"),
|
115 |
+
gr.File(label="Download Release Notes (Markdown)")
|
116 |
],
|
117 |
title="Automated Release Notes Generator",
|
118 |
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.",
|