AhmadMustafa commited on
Commit
c1b170a
·
1 Parent(s): 780e5d4

remove: reasoning prompt

Browse files
Files changed (1) hide show
  1. app.py +60 -68
app.py CHANGED
@@ -189,8 +189,6 @@ class TranscriptProcessor:
189
  print("No agenda found in any description tags.")
190
  return
191
 
192
- print(self.speaker_mapping)
193
-
194
  prompt = (
195
  f"Given the original speaker mapping {self.speaker_mapping}, agenda:\n{agenda}, and the transcript: {self.formatted_transcript}\n\n"
196
  "Some speaker names in the mapping might have spelling errors or be incomplete."
@@ -489,71 +487,68 @@ CRITICAL: When analyzing timestamps, you must verify that in the duration specif
489
  2. The speaker talks continuously for at least 20 seconds
490
  3. The clip ends BEFORE any interruption or speaker change
491
  """
492
- start_end_sentence_prompt = f"""Given a transcript with speakers {" , ".join(speaker_mapping.values())}, analyze the content and identify segments that would make compelling social media clips. For each speaker, find complete topics that meet the following criteria:
493
-
494
- Key Requirements:
495
- 1. Speaker Isolation
496
- - Each clip must contain only ONE speaker
497
- - No interruptions from other speakers allowed within the clip
498
- - Once another speaker interrupts, the previous speaker's clip must end
499
-
500
- 2. Duration Guidelines
501
- - Minimum: 20 seconds of continuous speech
502
- - Maximum: 100 seconds
503
- - Must capture complete thoughts/topics
504
-
505
- 3. Content Selection
506
- - Focus on interesting or noteworthy content
507
- - Topics should be self-contained and coherent
508
- - Must include both the starting and ending sentences that bound the topic
509
- - You can do 2 or 3 topics per speaker if there is more content for that speaker.
510
-
511
- Expected Output Format:
512
- ```json
513
- {{
514
- "Speaker_Name": [
515
- {{
516
- "Topic_Title": "<descriptive title of the topic>",
517
- "Starting_Sentence": "<exact first sentence of the topic>",
518
- "Ending_Sentence": "<exact last sentence before any interruption or topic change>"
519
- }},
520
- // Additional topics for this speaker...
521
- ],
522
- // Additional speakers...
523
- }}
524
-
525
- Example:
526
- If a transcript contains:
527
- [10:13] Speaker1: "First sentence..."
528
- [10:20] Speaker1: "nth sentence..."
529
- [10:17] Speaker2: "Interruption..."
530
- [10:19] Speaker1: "nth+1 sentence..."
531
-
532
- The valid ending sentence for Speaker1 would only include the first n sentences, ending before Speaker2's interruption.
533
-
534
- Important:
535
- - Ensure each clip represents a single, uninterrupted segment from one speaker
536
- - Include only complete thoughts/statements
537
- - Verify that no other speakers appear between the selected start and end sentences
538
- """
539
-
540
- sentence_finding_completion = client.chat.completions.create(
541
- model="gpt-4o",
542
- messages=[
543
- {"role": "system", "content": start_end_sentence_prompt},
544
- ],
545
- stream=False,
546
- temperature=0.2,
547
- )
548
- sentence_finding = sentence_finding_completion.choices[0].message.content
549
- sentence_finding_json = sentence_finding[
550
- sentence_finding.find("{") : sentence_finding.rfind("}") + 1
551
- ]
552
-
553
- print(sentence_finding_json)
554
 
555
  user_prompt = f"""User ID: {uid}
556
- Short Listed Topics and Sentences: {sentence_finding_json}
557
 
558
  Your task is to find the starting time, ending time, and the duration for the each topic in the above Short Listed Topics. You need to return the answer in the following format.
559
 
@@ -566,8 +561,6 @@ SPEAKER FORMAT:
566
  **Speaker Name**
567
  ....
568
  """
569
- # print("User Prompt is:\n", user_prompt)
570
- # print("System Prompt is:\n", system_prompt)
571
  completion = client.chat.completions.create(
572
  model="gpt-4o",
573
  messages=[
@@ -1052,7 +1045,6 @@ def create_chat_interface():
1052
 
1053
  # Handle initial loading with streaming
1054
  def on_app_load(request: gr.Request):
1055
- # print("App loaded")
1056
  cid = request.query_params.get("cid", None)
1057
  rsid = request.query_params.get("rsid", None)
1058
  origin = request.query_params.get("origin", None)
 
189
  print("No agenda found in any description tags.")
190
  return
191
 
 
 
192
  prompt = (
193
  f"Given the original speaker mapping {self.speaker_mapping}, agenda:\n{agenda}, and the transcript: {self.formatted_transcript}\n\n"
194
  "Some speaker names in the mapping might have spelling errors or be incomplete."
 
487
  2. The speaker talks continuously for at least 20 seconds
488
  3. The clip ends BEFORE any interruption or speaker change
489
  """
490
+ # start_end_sentence_prompt = f"""Given a transcript with speakers {" , ".join(speaker_mapping.values())}, analyze the content and identify segments that would make compelling social media clips. For each speaker, find complete topics that meet the following criteria:
491
+
492
+ # Key Requirements:
493
+ # 1. Speaker Isolation
494
+ # - Each clip must contain only ONE speaker
495
+ # - No interruptions from other speakers allowed within the clip
496
+ # - Once another speaker interrupts, the previous speaker's clip must end
497
+
498
+ # 2. Duration Guidelines
499
+ # - Minimum: 20 seconds of continuous speech
500
+ # - Maximum: 100 seconds
501
+ # - Must capture complete thoughts/topics
502
+
503
+ # 3. Content Selection
504
+ # - Focus on interesting or noteworthy content
505
+ # - Topics should be self-contained and coherent
506
+ # - Must include both the starting and ending sentences that bound the topic
507
+ # - You can do 2 or 3 topics per speaker if there is more content for that speaker.
508
+
509
+ # Expected Output Format:
510
+ # ```json
511
+ # {{
512
+ # "Speaker_Name": [
513
+ # {{
514
+ # "Topic_Title": "<descriptive title of the topic>",
515
+ # "Starting_Sentence": "<exact first sentence of the topic>",
516
+ # "Ending_Sentence": "<exact last sentence before any interruption or topic change>"
517
+ # }},
518
+ # // Additional topics for this speaker...
519
+ # ],
520
+ # // Additional speakers...
521
+ # }}
522
+
523
+ # Example:
524
+ # If a transcript contains:
525
+ # [10:13] Speaker1: "First sentence..."
526
+ # [10:20] Speaker1: "nth sentence..."
527
+ # [10:17] Speaker2: "Interruption..."
528
+ # [10:19] Speaker1: "nth+1 sentence..."
529
+
530
+ # The valid ending sentence for Speaker1 would only include the first n sentences, ending before Speaker2's interruption.
531
+
532
+ # Important:
533
+ # - Ensure each clip represents a single, uninterrupted segment from one speaker
534
+ # - Include only complete thoughts/statements
535
+ # - Verify that no other speakers appear between the selected start and end sentences
536
+ # """
537
+
538
+ # sentence_finding_completion = client.chat.completions.create(
539
+ # model="gpt-4o",
540
+ # messages=[
541
+ # {"role": "system", "content": start_end_sentence_prompt},
542
+ # ],
543
+ # stream=False,
544
+ # temperature=0.2,
545
+ # )
546
+ # sentence_finding = sentence_finding_completion.choices[0].message.content
547
+ # sentence_finding_json = sentence_finding[
548
+ # sentence_finding.find("{") : sentence_finding.rfind("}") + 1
549
+ # ]
 
 
550
 
551
  user_prompt = f"""User ID: {uid}
 
552
 
553
  Your task is to find the starting time, ending time, and the duration for the each topic in the above Short Listed Topics. You need to return the answer in the following format.
554
 
 
561
  **Speaker Name**
562
  ....
563
  """
 
 
564
  completion = client.chat.completions.create(
565
  model="gpt-4o",
566
  messages=[
 
1045
 
1046
  # Handle initial loading with streaming
1047
  def on_app_load(request: gr.Request):
 
1048
  cid = request.query_params.get("cid", None)
1049
  rsid = request.query_params.get("rsid", None)
1050
  origin = request.query_params.get("origin", None)