Spaces:
Sleeping
Sleeping
Commit
·
75feebc
1
Parent(s):
2cb3931
LE prompt with reasoning
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import json
|
2 |
import os
|
3 |
from dataclasses import dataclass
|
4 |
-
from typing import Dict, List
|
5 |
|
6 |
import gradio as gr
|
7 |
import requests
|
@@ -388,7 +388,7 @@ def get_transcript_for_url(url: str) -> dict:
|
|
388 |
|
389 |
def get_initial_analysis(
|
390 |
transcript_processor: TranscriptProcessor, cid, rsid, origin, ct, uid
|
391 |
-
) -> str:
|
392 |
"""Perform initial analysis of the transcript using OpenAI."""
|
393 |
try:
|
394 |
transcript = transcript_processor.get_transcript()
|
@@ -489,8 +489,65 @@ 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 |
|
493 |
-
user_prompt = f"""User ID: {uid}\n
|
494 |
Your task is to generate the social media clips following these strict rules:
|
495 |
|
496 |
1. TIMESTAMP SELECTION:
|
@@ -517,7 +574,6 @@ SPEAKER FORMAT:
|
|
517 |
**Speaker Name**
|
518 |
....
|
519 |
"""
|
520 |
-
print(user_prompt, speaker_mapping)
|
521 |
|
522 |
completion = client.chat.completions.create(
|
523 |
model="gpt-4o",
|
|
|
1 |
import json
|
2 |
import os
|
3 |
from dataclasses import dataclass
|
4 |
+
from typing import Dict, Generator, List
|
5 |
|
6 |
import gradio as gr
|
7 |
import requests
|
|
|
388 |
|
389 |
def get_initial_analysis(
|
390 |
transcript_processor: TranscriptProcessor, cid, rsid, origin, ct, uid
|
391 |
+
) -> Generator[str, None, None]:
|
392 |
"""Perform initial analysis of the transcript using OpenAI."""
|
393 |
try:
|
394 |
transcript = transcript_processor.get_transcript()
|
|
|
489 |
2. The speaker talks continuously for at least 20 seconds
|
490 |
3. The clip ends BEFORE any interruption or speaker change
|
491 |
"""
|
492 |
+
print(" , ".join(speaker_mapping.values()))
|
493 |
+
reasoning_prompt = f"""For each Speaker {" , ".join(speaker_mapping.values())}
|
494 |
+
in the transcript: {transcript}
|
495 |
+
|
496 |
+
Your job is to generate the thinking about the short social media clips for each speaker where they discuss. Think step by step and return a JSON at the end of the thinking.
|
497 |
+
Generate the thinking for atleast 2 clips for each speaker.
|
498 |
+
Return Format:
|
499 |
+
- Name of the Speaker
|
500 |
+
- Detailed Step by Step Thinking for each speaker from thier content and the topic they are talking about
|
501 |
+
After you have completed the thinking, give me a JSON of the thinking.
|
502 |
+
```json
|
503 |
+
[
|
504 |
+
{{
|
505 |
+
"Speaker 0": [
|
506 |
+
{{
|
507 |
+
"Topic Title": "...",
|
508 |
+
"Starting Sentence of that speaker": "...",
|
509 |
+
"Ending Sentence where the topic ends": "...."
|
510 |
+
}},
|
511 |
+
{{
|
512 |
+
"Topic Title": "...",
|
513 |
+
"Starting Sentence of that speaker": "....",
|
514 |
+
"Ending Sentence of that speaker where the topic ends": "....."
|
515 |
+
}}
|
516 |
+
]
|
517 |
+
}},
|
518 |
+
{{
|
519 |
+
"Speaker 1": [
|
520 |
+
{{
|
521 |
+
"Topic Title": "....",
|
522 |
+
"Starting Sentence of that speaker": ".....",
|
523 |
+
"Ending Sentence of that speaker": "....."
|
524 |
+
}},
|
525 |
+
{{
|
526 |
+
"Topic Title": "......",
|
527 |
+
"Starting Sentence of that speaker": "....",
|
528 |
+
"Ending Sentence of that speaker": "....."
|
529 |
+
}}
|
530 |
+
]
|
531 |
+
}},
|
532 |
+
....
|
533 |
+
]
|
534 |
+
```
|
535 |
+
"""
|
536 |
+
thinking_completion = client.chat.completions.create(
|
537 |
+
model="gpt-4o",
|
538 |
+
messages=[
|
539 |
+
{"role": "system", "content": reasoning_prompt},
|
540 |
+
],
|
541 |
+
stream=False,
|
542 |
+
temperature=0.4,
|
543 |
+
)
|
544 |
+
thinking = thinking_completion.choices[0].message.content
|
545 |
+
print("Thinking is:\n", thinking)
|
546 |
+
thinking_json = thinking[thinking.find("{") : thinking.rfind("}") + 1]
|
547 |
+
|
548 |
+
user_prompt = f"""User ID: {uid}
|
549 |
+
Intelligent Thinking Context: {thinking_json}
|
550 |
|
|
|
551 |
Your task is to generate the social media clips following these strict rules:
|
552 |
|
553 |
1. TIMESTAMP SELECTION:
|
|
|
574 |
**Speaker Name**
|
575 |
....
|
576 |
"""
|
|
|
577 |
|
578 |
completion = client.chat.completions.create(
|
579 |
model="gpt-4o",
|