Update app.py
Browse files
app.py
CHANGED
|
@@ -249,79 +249,81 @@ def process_media(file_path, is_url=False):
|
|
| 249 |
|
| 250 |
@app.callback(
|
| 251 |
[Output('summary-status', 'children'),
|
|
|
|
| 252 |
Output('download-transcription', 'data')],
|
| 253 |
-
Input('btn-summarize', 'n_clicks'),
|
|
|
|
|
|
|
| 254 |
State('transcription-preview', 'children'),
|
| 255 |
prevent_initial_call=True
|
| 256 |
)
|
| 257 |
-
def
|
| 258 |
-
|
| 259 |
-
|
|
|
|
| 260 |
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
Summary:
|
| 267 |
-
"""
|
| 268 |
-
|
| 269 |
-
try:
|
| 270 |
-
summary_response = openai.ChatCompletion.create(
|
| 271 |
-
model="gpt-3.5-turbo",
|
| 272 |
-
messages=[
|
| 273 |
-
{"role": "system", "content": "You are an AI assistant skilled in summarizing conversations."},
|
| 274 |
-
{"role": "user", "content": summary_prompt}
|
| 275 |
-
]
|
| 276 |
-
)
|
| 277 |
|
| 278 |
-
|
| 279 |
-
return "", dcc.send_string(summary, "transcript_summary.txt")
|
| 280 |
-
except Exception as e:
|
| 281 |
-
logger.error(f"Error generating summary: {str(e)}")
|
| 282 |
-
return f"An error occurred while generating the summary: {str(e)}", None
|
| 283 |
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
Output('download-transcription', 'data', allow_duplicate=True)],
|
| 287 |
-
Input('btn-minutes', 'n_clicks'),
|
| 288 |
-
State('transcription-preview', 'children'),
|
| 289 |
-
prevent_initial_call=True
|
| 290 |
-
)
|
| 291 |
-
def generate_meeting_minutes(n_clicks, transcript):
|
| 292 |
-
if n_clicks is None or not transcript:
|
| 293 |
-
return "", None
|
| 294 |
-
|
| 295 |
-
minutes_prompt = f"""
|
| 296 |
-
Please transform the following transcript into structured meeting minutes. Include the following sections:
|
| 297 |
-
1. Meeting Title
|
| 298 |
-
2. Date and Time (if mentioned)
|
| 299 |
-
3. Attendees (if mentioned)
|
| 300 |
-
4. Agenda Items
|
| 301 |
-
5. Key Decisions
|
| 302 |
-
6. Action Items
|
| 303 |
-
7. Next Steps
|
| 304 |
-
|
| 305 |
-
Transcript:
|
| 306 |
-
{transcript}
|
| 307 |
-
|
| 308 |
-
Meeting Minutes:
|
| 309 |
-
"""
|
| 310 |
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
@app.callback(
|
| 327 |
[Output('output-media-upload', 'children'),
|
|
|
|
| 249 |
|
| 250 |
@app.callback(
|
| 251 |
[Output('summary-status', 'children'),
|
| 252 |
+
Output('minutes-status', 'children'),
|
| 253 |
Output('download-transcription', 'data')],
|
| 254 |
+
[Input('btn-summarize', 'n_clicks'),
|
| 255 |
+
Input('btn-minutes', 'n_clicks'),
|
| 256 |
+
Input('btn-download', 'n_clicks')],
|
| 257 |
State('transcription-preview', 'children'),
|
| 258 |
prevent_initial_call=True
|
| 259 |
)
|
| 260 |
+
def handle_document_actions(summarize_clicks, minutes_clicks, download_clicks, transcript):
|
| 261 |
+
ctx = dash.callback_context
|
| 262 |
+
if not ctx.triggered:
|
| 263 |
+
return "", "", None
|
| 264 |
|
| 265 |
+
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
| 266 |
+
|
| 267 |
+
if button_id == 'btn-summarize':
|
| 268 |
+
summary_prompt = f"""
|
| 269 |
+
Please provide a detailed summary of the following transcript. Include the main topics discussed and key points. Format it for readability:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
|
| 271 |
+
{transcript}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
|
| 273 |
+
Summary:
|
| 274 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
+
try:
|
| 277 |
+
summary_response = openai.ChatCompletion.create(
|
| 278 |
+
model="gpt-3.5-turbo",
|
| 279 |
+
messages=[
|
| 280 |
+
{"role": "system", "content": "You are an AI assistant skilled in summarizing conversations."},
|
| 281 |
+
{"role": "user", "content": summary_prompt}
|
| 282 |
+
]
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
summary = summary_response['choices'][0]['message']['content']
|
| 286 |
+
return "", "", dcc.send_string(summary, "transcript_summary.txt")
|
| 287 |
+
except Exception as e:
|
| 288 |
+
logger.error(f"Error generating summary: {str(e)}")
|
| 289 |
+
return f"An error occurred while generating the summary: {str(e)}", "", None
|
| 290 |
+
|
| 291 |
+
elif button_id == 'btn-minutes':
|
| 292 |
+
minutes_prompt = f"""
|
| 293 |
+
Please transform the following transcript into structured meeting minutes. Include the following sections:
|
| 294 |
+
1. Meeting Title
|
| 295 |
+
2. Date and Time (if mentioned)
|
| 296 |
+
3. Attendees (if mentioned)
|
| 297 |
+
4. Agenda Items
|
| 298 |
+
5. Key Decisions
|
| 299 |
+
6. Action Items
|
| 300 |
+
7. Next Steps
|
| 301 |
+
|
| 302 |
+
Transcript:
|
| 303 |
+
{transcript}
|
| 304 |
+
|
| 305 |
+
Meeting Minutes:
|
| 306 |
+
"""
|
| 307 |
|
| 308 |
+
try:
|
| 309 |
+
minutes_response = openai.ChatCompletion.create(
|
| 310 |
+
model="gpt-3.5-turbo",
|
| 311 |
+
messages=[
|
| 312 |
+
{"role": "system", "content": "You are an AI assistant skilled in creating structured meeting minutes from transcripts."},
|
| 313 |
+
{"role": "user", "content": minutes_prompt}
|
| 314 |
+
]
|
| 315 |
+
)
|
| 316 |
+
|
| 317 |
+
minutes = minutes_response['choices'][0]['message']['content']
|
| 318 |
+
return "", "", dcc.send_string(minutes, "meeting_minutes.txt")
|
| 319 |
+
except Exception as e:
|
| 320 |
+
logger.error(f"Error generating meeting minutes: {str(e)}")
|
| 321 |
+
return "", f"An error occurred while generating meeting minutes: {str(e)}", None
|
| 322 |
+
|
| 323 |
+
elif button_id == 'btn-download':
|
| 324 |
+
return "", "", dcc.send_bytes(generated_file.getvalue(), "diarized_transcription.txt")
|
| 325 |
+
|
| 326 |
+
return "", "", None
|
| 327 |
|
| 328 |
@app.callback(
|
| 329 |
[Output('output-media-upload', 'children'),
|