andreinigo commited on
Commit
1b52241
·
1 Parent(s): 55fd076

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -45
app.py CHANGED
@@ -114,7 +114,7 @@ def break_up_file(tokens, chunk_size, overlap_size):
114
  yield from break_up_file(tokens[chunk_size-overlap_size:], chunk_size, overlap_size)
115
 
116
 
117
- def break_up_file_to_chunks(filename, chunk_size=2000, overlap_size=100):
118
  with open(filename, 'r') as f:
119
  text = f.read()
120
  tokens = word_tokenize(text)
@@ -127,24 +127,6 @@ def convert_to_prompt_text(tokenized_text):
127
  return prompt_text
128
 
129
 
130
- def markdown_to_docx(md_text, output_file):
131
- # Convert the Markdown text to HTML
132
- html_text = markdown.markdown(md_text)
133
-
134
- # Create a new Document object
135
- doc = Document()
136
-
137
- # Parse the HTML and add its content to the .docx document
138
- for p in html_text.split('</p>'):
139
- if '<p>' in p:
140
- clean_p = p.replace('<p>', '').strip()
141
- if clean_p:
142
- doc.add_paragraph(clean_p)
143
-
144
- # Save the document to the specified file
145
- doc.save(output_file)
146
-
147
-
148
  @backoff.on_exception(backoff.expo, openai.error.RateLimitError)
149
  @backoff.on_exception(backoff.expo, openai.error.APIConnectionError)
150
  def summarize_meeting(filepath):
@@ -161,12 +143,12 @@ def summarize_meeting(filepath):
161
 
162
  messages = [
163
  {"role": "system", "content": "Summarize this meeting transcript in the same language as the user's input."}]
164
- messages.append({"role": "user", "content": "Summarize this meeting transcript in the same language as the meeting transcript. Meeting Transcript:" + prompt_request})
165
 
166
  response = openai.ChatCompletion.create(
167
- model="gpt-3.5-turbo",
168
  messages=messages,
169
- temperature=.5,
170
  top_p=1,
171
  frequency_penalty=0,
172
  presence_penalty=0
@@ -177,30 +159,20 @@ def summarize_meeting(filepath):
177
 
178
  # Consolidate these meeting summaries.
179
  prompt_request = str(prompt_response)
180
- tokens_PR = word_tokenize(prompt_request)
181
- count_tokens_PR = len(tokens_PR)
182
 
183
- if count_tokens_PR <2000:
184
- # Summarize the text of the meeting transcripts.
185
- messages = [{"role": "system", "content": "Consolidate, and summarize the text of the meeting transcripts. The output format should be markdown in the same language as the user's input. Start with a brief summary of the meeting, continue with bullets outlining the most important points of discussion. Finally, provide a table to show the list of action items with 3 columns: Action, Assigned Person, Due Date."}]
186
- messages.append({"role": "user", "content": "Consolidate, and summarize the text of the meeting transcripts. The output format should be markdown in the same language as the meeting summary. Start with a brief summary of the meeting, continue with bullets outlining the most important points of discussion. Finally, provide a table to show the list of action items with 3 columns: Action, Assigned Person, Due Date. Meeting summary:"+ prompt_request})
187
- response = openai.ChatCompletion.create(
188
- model="gpt-3.5-turbo",
189
- messages=messages,
190
- temperature=.3,
191
- top_p=1,
192
- frequency_penalty=0,
193
- presence_penalty=0
194
- )
195
-
196
- summary_text = response["choices"][0]["message"]['content'].strip()
197
- #outfilepath = "Resumen-Minuta-" + datetime.now().strftime("%d-%m-%Y-%H-%M") + ".docx"
198
- # Convert the summary to a .docx file with the name "Resumen-Minuta-<download-date>.docx"
199
- #markdown_to_docx(
200
- # summary_text, outfilepath)
201
- else:
202
- summary_text = "Error: Contacta al administrador de Minuteevo."
203
-
204
 
205
  return summary_text
206
 
 
114
  yield from break_up_file(tokens[chunk_size-overlap_size:], chunk_size, overlap_size)
115
 
116
 
117
+ def break_up_file_to_chunks(filename, chunk_size=4000, overlap_size=100):
118
  with open(filename, 'r') as f:
119
  text = f.read()
120
  tokens = word_tokenize(text)
 
127
  return prompt_text
128
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  @backoff.on_exception(backoff.expo, openai.error.RateLimitError)
131
  @backoff.on_exception(backoff.expo, openai.error.APIConnectionError)
132
  def summarize_meeting(filepath):
 
143
 
144
  messages = [
145
  {"role": "system", "content": "Summarize this meeting transcript in the same language as the user's input."}]
146
+ messages.append({"role": "user", "content": prompt_request})
147
 
148
  response = openai.ChatCompletion.create(
149
+ model="gpt-4",
150
  messages=messages,
151
+ temperature=.4,
152
  top_p=1,
153
  frequency_penalty=0,
154
  presence_penalty=0
 
159
 
160
  # Consolidate these meeting summaries.
161
  prompt_request = str(prompt_response)
 
 
162
 
163
+ # Summarize the text of the meeting transcripts.
164
+ messages = [{"role": "system", "content": "Consolidate, and summarize the text of the meeting transcripts. The output format should be markdown in the same language as the user's input. Start with a brief summary of the meeting, continue with bullets outlining the most important points of discussion. Finally, provide a table to show the list of action items with 3 columns: Action, Assigned Person, Due Date."}]
165
+ messages.append({"role": "user", "content": prompt_request})
166
+ response = openai.ChatCompletion.create(
167
+ model="gpt-4",
168
+ messages=messages,
169
+ temperature=.3,
170
+ top_p=1,
171
+ frequency_penalty=0,
172
+ presence_penalty=0
173
+ )
174
+
175
+ summary_text = response["choices"][0]["message"]['content'].strip()
 
 
 
 
 
 
 
 
176
 
177
  return summary_text
178