AhmadMustafa commited on
Commit
14ba4fb
·
1 Parent(s): 77f24d4

update: prompt for introductions

Browse files
Files changed (1) hide show
  1. app.py +45 -42
app.py CHANGED
@@ -311,7 +311,19 @@ Total takes: 2
311
  temperature=0.5,
312
  )
313
  else:
314
- prompt = f"""Call Details:
 
 
 
 
 
 
 
 
 
 
 
 
315
  User ID: {uid}
316
  Call ID: {cid}
317
  Speakers: {", ".join(speaker_mapping.values())}
@@ -322,54 +334,43 @@ Format requirements:
322
 
323
  1. SPEAKER FORMAT:
324
  **Speaker Name**
325
- 1. [Topic title <div id='topic' style="display: inline"> 22s at 12:30 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{750}}&et={{772}}&uid={{uid}})
326
- 2. [Topic title <div id='topic' style="display: inline"> 43s at 14:45 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{885}}&et={{928}}&uid={{uid}})
327
- 3. [Topic title <div id='topic' style="display: inline"> 58s at 16:20 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{980}}&et={{1038}}&uid={{uid}})
328
 
329
  2. TIMESTAMP RULES:
330
- - Start time (st): Must begin exactly when speaker starts discussing the specific topic
331
  - End time (et): Must end exactly when either:
332
  * The speaker completes their point, or
333
- * Before the next speaker begins
334
- - NO OVERLAP: Selected duration must NEVER include dialogue from other speakers
335
- - Duration limits: Minimum 20 seconds, maximum 1 minute 30 seconds
336
- - Time format: "Xs at HH:MM" where X = seconds
337
- - URL parameters: Convert display times to seconds
338
- Example: "25s at 10:13" → st=613&et=638
339
 
340
  3. FORMATTING RULES:
341
- - Speaker names: Use markdown bold (**Name**)
342
- - Topic titles: First word capitalized, rest lowercase
343
- - Each topic must be a clickable link with correct timestamp
344
- - URL format: {link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{start_time_in_sec}}&et={{end_time_in_sec}}&uid={{uid}})
345
 
346
  4. TOPIC SELECTION:
347
- - Prioritize engaging, viral-worthy content
348
- - Minimum 2 topics per speaker, aim for 3 if available (SKIP THE HOST if no compelling content)
349
- - Topics should be self-contained discussions within the timestamp
350
- - Skip speakers if fewer than 2 compelling topics found
351
  """
352
- completion = client.chat.completions.create(
353
- model="gpt-4o-mini",
354
- messages=[
355
- {
356
- "role": "system",
357
- "content": f"""You are analyzing a transcript for Call ID: {cid}, Session ID: {rsid}, Origin: {origin}, Call Type: {ct}.
358
 
359
- CORE REQUIREMENTS:
360
- 1. TIMESTAMPS: Each clip must contain ONLY the specified speaker's dialogue about a single topic. No overlapping dialogue from other speakers. YOU NEED TO BE VERY CAREFUL ABOUT THIS RULE. YOU HAVE THE TRANSCRIPT AND YOU CAN SEE WHO IS SPEAKING AT WHAT TIME SO BE VERY VERY CARAEFUL AND ONLY INCLUDE THE DIALOGUE OF THE SPEAKER YOU ARE MAKING THE CLIP FOR.
361
- 2. DURATION: Clips should be between 20-60 seconds long.
362
- 3. CONTENT: Select engaging, viral-worthy topics. Avoid mundane or irrelevant content
363
- 4. COVERAGE: Minimum 2 topics per speaker, aim for 3 if good content exists.
364
- 5. YOU CAN IGNORE THE HOST IF NO COMPELLING CONTENT IS FOUND.
365
-
366
- YOU SHOULD Prioritize accuracy in timestamp at every cost.""",
367
- },
368
- {"role": "user", "content": prompt},
369
- ],
370
- stream=True,
371
- temperature=0.5,
372
- )
373
 
374
  collected_messages = []
375
  # Iterate through the stream
@@ -458,15 +459,16 @@ If the start time is 10:13 and end time is 10:18, the url will be:
458
  {link_start}://roll.ai/colab/1234aq_12314/51234151?st=613&et=618&uid=82314
459
  In the URL, make sure that after RSID there is ? and then rest of the fields are added via &.
460
  You can include multiple links here that can related to the user answer. ALWAYS ANSWER FROM THE TRANSCRIPT.
 
461
 
462
  Example 1:
463
  User: Suggest me some clips that can go viral on Instagram.
464
  Response:
465
  1. [Clip 1 <div id='topic' style="display: inline"> 22s at 12:30 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{750}}&et={{772}}&uid={{uid}})
 
466
  2. [Clip 2 <div id='topic' style="display: inline"> 10s at 10:00 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{600}}&et={{610}}&uid={{uid}})
467
 
468
  Example 2:
469
- User: Give me the URL where each person has introduced themselves.
470
  Response (Please provide exact time where the person has started introducing themselves. Normally person start introducing themselves by saying Hi, Hello, I am, My name is, etc.):
471
  1. [Person Name1 <div id='topic' style="display: inline"> 43s at 14:45 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{885}}&et={{928}}&uid={{uid}})
472
  2. [Person Name2 <div id='topic' style="display: inline"> 58s at 16:20 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{980}}&et={{1038}}&uid={{uid}})
@@ -476,6 +478,7 @@ If the user provides a link to the agenda, use the correct_speaker_name_with_url
476
  If the user provides the correct call type, use the correct_call_type function to correct the call type. Call Type for street interviews is 'si'.
477
  """
478
  messages = [{"role": "system", "content": prompt}]
 
479
 
480
  for user_msg, assistant_msg in chat_history:
481
  if user_msg is not None: # Skip the initial message where user_msg is None
@@ -491,7 +494,7 @@ If the user provides the correct call type, use the correct_call_type function t
491
  messages=messages,
492
  tools=tools,
493
  stream=True,
494
- temperature=0.5,
495
  )
496
  collected_messages = []
497
  tool_calls_detected = False
@@ -787,7 +790,7 @@ def create_chat_interface():
787
  transcript_data = get_transcript_for_url(turl)
788
  transcript_processor = TranscriptProcessor(
789
  transcript_data=transcript_data,
790
- max_segment_duration=20 if ct != "si" else 10,
791
  call_type=ct,
792
  )
793
 
 
311
  temperature=0.5,
312
  )
313
  else:
314
+ system_prompt = f"""You are analyzing a transcript for Call ID: {cid}, Session ID: {rsid}, Origin: {origin}, and Call Type: {ct}.
315
+
316
+ CORE REQUIREMENTS:
317
+ 1. TIMESTAMPS: Each clip must contain ONLY the specified speaker's dialogue about a single topic. No overlapping dialogue from other speakers. YOU NEED TO BE VERY CAREFUL ABOUT THIS RULE. YOU HAVE THE TRANSCRIPT AND YOU CAN SEE WHO IS SPEAKING AT WHAT TIME, SO BE VERY, VERY CAREFUL AND ONLY INCLUDE THE DIALOGUE OF THE SPEAKER YOU ARE MAKING THE CLIP FOR.
318
+ 2. DURATION: Clips should be between 20-90 seconds long.
319
+ 3. CONTENT: Select engaging, viral-worthy topics. Avoid mundane or irrelevant content.
320
+ 4. COVERAGE: Minimum 2 topics per speaker, aim for 3 if good content exists.
321
+ 5. YOU CAN IGNORE THE HOST IF NO COMPELLING CONTENT IS FOUND.
322
+
323
+ YOU SHOULD prioritize accuracy in timestamps at all costs.
324
+ """
325
+
326
+ user_prompt = f"""Call Details:
327
  User ID: {uid}
328
  Call ID: {cid}
329
  Speakers: {", ".join(speaker_mapping.values())}
 
334
 
335
  1. SPEAKER FORMAT:
336
  **Speaker Name**
337
+ 1. [Topic title <div id='topic' style="display: inline"> 22s at 12:30 </div>]({{link_start}}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{750}}&et={{772}}&uid={{uid}})
338
+ 2. [Topic title <div id='topic' style="display: inline"> 43s at 14:45 </div>]({{link_start}}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{885}}&et={{928}}&uid={{uid}})
339
+ 3. [Topic title <div id='topic' style="display: inline"> 58s at 16:20 </div>]({{link_start}}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{980}}&et={{1038}}&uid={{uid}})
340
 
341
  2. TIMESTAMP RULES:
342
+ - Start time (st): Must begin exactly when speaker starts discussing the specific topic.
343
  - End time (et): Must end exactly when either:
344
  * The speaker completes their point, or
345
+ * Before the next speaker begins.
346
+ - NO OVERLAP: Selected duration must NEVER include dialogue from other speakers.
347
+ - Duration limits: Minimum 20 seconds, maximum 1 minute 30 seconds.
348
+ - Time format: "Xs at HH:MM" where X = seconds.
349
+ - URL parameters: Convert display times to seconds.
350
+ Example: "25s at 10:13" → st=613&et=638.
351
 
352
  3. FORMATTING RULES:
353
+ - Speaker names: Use markdown bold (**Name**).
354
+ - Topic titles: First word capitalized, rest lowercase.
355
+ - Each topic must be a clickable link with correct timestamp.
356
+ - URL format: {{link_start}}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{start_time_in_sec}}&et={{end_time_in_sec}}&uid={{uid}}).
357
 
358
  4. TOPIC SELECTION:
359
+ - Prioritize engaging, viral-worthy content.
360
+ - Minimum 2 topics per speaker, aim for 3 if available (SKIP THE HOST if no compelling content).
361
+ - Topics should be self-contained discussions within the timestamp.
362
+ - Skip speakers if fewer than 2 compelling topics found.
363
  """
 
 
 
 
 
 
364
 
365
+ completion = client.chat.completions.create(
366
+ model="gpt-4o-mini",
367
+ messages=[
368
+ {"role": "system", "content": system_prompt},
369
+ {"role": "user", "content": user_prompt},
370
+ ],
371
+ stream=True,
372
+ temperature=0.5,
373
+ )
 
 
 
 
 
374
 
375
  collected_messages = []
376
  # Iterate through the stream
 
459
  {link_start}://roll.ai/colab/1234aq_12314/51234151?st=613&et=618&uid=82314
460
  In the URL, make sure that after RSID there is ? and then rest of the fields are added via &.
461
  You can include multiple links here that can related to the user answer. ALWAYS ANSWER FROM THE TRANSCRIPT.
462
+ RULE: When selecting timestamps for the answer, always use the **starting time (XX:YY)** as the reference point for your response, with the duration (Z seconds) calculated from this starting time, not the ending time of the segment.
463
 
464
  Example 1:
465
  User: Suggest me some clips that can go viral on Instagram.
466
  Response:
467
  1. [Clip 1 <div id='topic' style="display: inline"> 22s at 12:30 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{750}}&et={{772}}&uid={{uid}})
468
+ User: Give me the URL where each person has introduced themselves.
469
  2. [Clip 2 <div id='topic' style="display: inline"> 10s at 10:00 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{600}}&et={{610}}&uid={{uid}})
470
 
471
  Example 2:
 
472
  Response (Please provide exact time where the person has started introducing themselves. Normally person start introducing themselves by saying Hi, Hello, I am, My name is, etc.):
473
  1. [Person Name1 <div id='topic' style="display: inline"> 43s at 14:45 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{885}}&et={{928}}&uid={{uid}})
474
  2. [Person Name2 <div id='topic' style="display: inline"> 58s at 16:20 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{980}}&et={{1038}}&uid={{uid}})
 
478
  If the user provides the correct call type, use the correct_call_type function to correct the call type. Call Type for street interviews is 'si'.
479
  """
480
  messages = [{"role": "system", "content": prompt}]
481
+ print(messages[0]["content"])
482
 
483
  for user_msg, assistant_msg in chat_history:
484
  if user_msg is not None: # Skip the initial message where user_msg is None
 
494
  messages=messages,
495
  tools=tools,
496
  stream=True,
497
+ temperature=0.3,
498
  )
499
  collected_messages = []
500
  tool_calls_detected = False
 
790
  transcript_data = get_transcript_for_url(turl)
791
  transcript_processor = TranscriptProcessor(
792
  transcript_data=transcript_data,
793
+ max_segment_duration=5 if ct != "si" else 10,
794
  call_type=ct,
795
  )
796