bluenevus commited on
Commit
b302102
·
verified ·
1 Parent(s): 5044490

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -20
app.py CHANGED
@@ -3,7 +3,6 @@ from datetime import datetime, timedelta
3
  import google.generativeai as genai
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):
@@ -38,43 +37,46 @@ def generate_release_notes(github_repo, github_token, gemini_api_key, start_date
38
  Provide a concise summary for each item. Do not include any links, but keep issue numbers if present.
39
 
40
  Important formatting instructions:
41
- - Use proper Markdown syntax
42
- - Use # for main headers and ## for subheaders
43
- - Use - for list items
44
- - Keep the text structure simple and easy to read
45
  - Be sure to briefly explain the why and benefits of the change for average users that are non-technical
46
  """
47
 
48
  response = model.generate_content(prompt)
49
  release_notes = response.text
50
 
 
51
  doc = docx.Document()
52
  doc.add_heading('Release Notes', 0)
53
 
54
- current_list_style = None
55
  for line in release_notes.split('\n'):
56
  line = line.strip()
57
- if line.startswith('# '):
58
- doc.add_heading(line[2:], level=1)
59
- current_list_style = None
60
- elif line.startswith('## '):
61
- doc.add_heading(line[3:], level=2)
62
- current_list_style = None
63
- elif line.startswith('- '):
64
- if current_list_style is None:
65
- current_list_style = doc.add_paragraph().style
66
- current_list_style.name = 'List Bullet'
67
- current_list_style.font.size = docx.shared.Pt(11)
68
- doc.add_paragraph(line[2:], style=current_list_style)
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
 
3
  import google.generativeai as genai
4
  from github import Github, GithubException
5
  import docx
 
6
  import tempfile
7
 
8
  def generate_release_notes(github_repo, github_token, gemini_api_key, start_date, end_date):
 
37
  Provide a concise summary for each item. Do not include any links, but keep issue numbers if present.
38
 
39
  Important formatting instructions:
40
+ - Use plain text only, no special formatting
41
+ - Use section titles followed by a colon (e.g., "New Features:")
42
+ - Start each item on a new line
 
43
  - Be sure to briefly explain the why and benefits of the change for average users that are non-technical
44
  """
45
 
46
  response = model.generate_content(prompt)
47
  release_notes = response.text
48
 
49
+ # Create DOCX file
50
  doc = docx.Document()
51
  doc.add_heading('Release Notes', 0)
52
 
53
+ current_section = None
54
  for line in release_notes.split('\n'):
55
  line = line.strip()
56
+ if line.endswith(':'):
57
+ doc.add_heading(line, level=1)
58
+ current_section = None
 
 
 
 
 
 
 
 
 
59
  elif line:
60
+ if current_section is None:
61
+ current_section = doc.add_paragraph().style
62
+ current_section.name = 'List Bullet'
63
+ doc.add_paragraph(line, style=current_section)
64
 
65
  with tempfile.NamedTemporaryFile(delete=False, suffix='.docx') as temp_docx:
66
  doc.save(temp_docx.name)
67
  docx_path = temp_docx.name
68
 
69
+ # Create Markdown file
70
+ markdown_content = "# Release Notes\n\n"
71
+ for line in release_notes.split('\n'):
72
+ line = line.strip()
73
+ if line.endswith(':'):
74
+ markdown_content += f"\n## {line}\n\n"
75
+ elif line:
76
+ markdown_content += f"- {line}\n"
77
+
78
  with tempfile.NamedTemporaryFile(delete=False, suffix='.md', mode='w', encoding='utf-8') as temp_md:
79
+ temp_md.write(markdown_content)
80
  md_path = temp_md.name
81
 
82
  return release_notes, docx_path, md_path