Spaces:
Running
Running
from typing import Dict | |
def get_street_interview_prompt( | |
transcript: str, uid: str, rsid: str, link_start: str | |
) -> str: | |
"""Generate prompt for street interview analysis.""" | |
return f"""This is a transcript for a street interview. Call Details are as follows: | |
User ID UID: {uid} | |
RSID: {rsid} | |
Transcript: {transcript} | |
Your task is to analyze this street interview transcript and identify the final/best timestamps for each topic or question discussed. Here are the key rules: | |
The user might repeat the answer to the question sometimes, you need to pick the very last answer intelligently | |
1. For any topic/answer that appears multiple times in the transcript (even partially): | |
- The LAST occurrence is always considered the best version. If the same thing is said multiple times, the last time is the best, all previous times are considered as additional takes. | |
- This includes cases where parts of an answer are scattered throughout the transcript | |
- Even slight variations of the same answer should be tracked | |
- List timestamps for ALL takes, with the final take highlighted as the best answer | |
2. Introduction handling: | |
- Question 1 is ALWAYS the speaker's introduction/self-introduction | |
- If someone introduces themselves multiple times, use the last introduction as best answer | |
- Include all variations of how they state their name/background | |
- List ALL introduction timestamps chronologically | |
3. Question sequence: | |
- After the introduction, list questions in the order they were first asked | |
- If a question or introduction is revisited later at any point, please use the later timestamp | |
- Track partial answers to the same question across the transcript | |
You need to make sure that any words that are repeated, you need to pick the last of them. | |
Return format: | |
**Question Title** | |
Total takes: [X] (Include ONLY if content appears more than once) | |
- [Take 1. <div id='topic' style="display: inline"> 15s at 12:30 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{750}}&et={{765}}&uid={{uid}}) | |
- [Take 2. <div id='topic' style="display: inline"> 30s at 14:45 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{885}}&et={{915}}&uid={{uid}}) | |
... | |
- [Take X (Best) <div id='topic' style="display: inline"> 1m 10s at 16:20 </div>]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{980}}&et={{1050}}&uid={{uid}})""" | |
def get_street_interview_system_prompt( | |
cid: str, rsid: str, origin: str, ct: str | |
) -> str: | |
"""Generate system prompt for street interview analysis.""" | |
return f"""You are analyzing a transcript for Call ID: {cid}, Session ID: {rsid}, Origin: {origin}, Call Type: {ct}. | |
CORE REQUIREMENT: | |
- TIMESTAMPS: A speaker can repeat the answer to a question multiple times. You need to pick the last answer very carefully and choose that as best take. Make sure that that same answer is not repeated again after the best answer. | |
YOU SHOULD Prioritize accuracy in timestamp at every cost. Read the Transcript carefully and decide where an answer starts and ends. You will have speaker labels so you need to be very sharp.""" | |
def get_live_event_system_prompt( | |
cid: str, | |
rsid: str, | |
origin: str, | |
ct: str, | |
speaker_mapping: Dict[str, str], | |
transcript: str, | |
) -> str: | |
"""Generate system prompt for RollAI call analysis.""" | |
return f"""You are a helpful assistant developed by Roll.AI(Leading AI tool for Remote production) who is analyzing the transcript for a RollAI Call. Following are the details: | |
- Call ID: {cid} | |
- Session ID: {rsid} | |
- Origin: {origin} | |
- Call Type: {ct} | |
- Speakers: {", ".join(speaker_mapping.values())} | |
- Diarized Transcript: {transcript} | |
You are tasked with creating social media clips from the transcript, You need to shortlist the atleast two short clips for EACH SPEAKER. There are some requirments: | |
CORE REQUIREMENTS: | |
1. SPEAKER Overlap in the CLIP: When specifying the duration for the script, make sure that in that duration: | |
- There is only continuous dialogue from that speaker. | |
- As soon as another speaker starts talking or the topic ends, the clip MUST end. | |
2. DURATION RULES: | |
- Each clip must be between 20 seconds to 120 seconds. | |
3. SPEAKER COVERAGE: | |
- Minimum 2 topics per speaker, aim for 3 if good content exists | |
CRITICAL: When analyzing timestamps, you must verify that in the duration specified: | |
1. No other speaker talks during the selected timeframe | |
2. The speaker talks continuously for at least 20 seconds | |
3. The clip ends BEFORE any interruption or speaker change""" | |
def get_live_event_user_prompt(uid: str, link_start: str) -> str: | |
"""Generate user prompt for RollAI call analysis.""" | |
return f"""User ID: {uid} | |
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. | |
Please make sure that in the duration of 1 speaker, there is no segment of any other speaker. The shortlisted duration must be of a single speaker | |
Return Format requirements: | |
SPEAKER FORMAT: | |
**Speaker Name** | |
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}}) | |
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}}) | |
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}}) | |
**Speaker Name** | |
....""" | |
def get_chat_system_prompt( | |
cid: str, | |
rsid: str, | |
origin: str, | |
ct: str, | |
speaker_mapping: Dict[str, str], | |
transcript: str, | |
link_start: str, | |
) -> str: | |
"""Generate system prompt for chat analysis.""" | |
return f"""You are a helpful assistant analyzing transcripts and generating timestamps and URL. The user will ask you questions regarding the social media clips from the transcript. | |
Call ID is {cid}, | |
Session ID is {rsid}, | |
origin is {origin}, | |
Call Type is {ct}. | |
Speakers: {", ".join(speaker_mapping.values())} | |
Transcript: {transcript} | |
IMPORTANT: If the user suggests clips along with timestamps, the clips are correct but the timings can differ slightly from the actual transcript because the user was in the audience and does not have exact timestamps. You need to find the correct timestamp in the transcript and verify it instead of relying on the user's timestamps. | |
If a user asks timestamps for a specific topic or things, find the start time and end time of that specific topic and return answer in the format: | |
Answers and URLs should be formated as follows: | |
[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}}) | |
For Example: | |
If the start time is 10:13 and end time is 10:18, the url will be: | |
{link_start}://roll.ai/colab/1234aq_12314/51234151?st=613&et=618&uid=82314 | |
In the URL, make sure that after RSID there is ? and then rest of the fields are added via &. | |
You can include multiple links here that can related to the user answer. ALWAYS ANSWER FROM THE TRANSCRIPT. | |
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. | |
Example 1: | |
User: Suggest me some clips that can go viral on Instagram. | |
Response: | |
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}}) | |
User: Give me the URL where each person has introduced themselves. | |
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}}) | |
Example 2: | |
Provide the exact timestamp where the person begins their introduction, typically starting with phrases like "Hi," "Hello," "I am," or "My name is," and include the full introduction, covering everything they say about themselves, including their name, role, background, current responsibilities, organization, and any additional details they provide about their work or personal interests. | |
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}}) | |
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}}) | |
.... | |
If the user provides a link to the agenda, use the correct_speaker_name_with_url function to correct the speaker names based on the agenda. | |
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'. | |
IMPORTANT TIMESTAMP VERIFICATION INSTRUCTIONS: | |
When a user provides clips with timestamps, the starting timestamp may be slightly inaccurate since they were noted by someone in the audience without access to exact timing data. You MUST verify and correct these timestamps by searching the actual transcript. | |
For example, user says 15:25 "speaker 1 talks about mark zuckerberg" but the actual transcript shows that sentence starts at 15:30. You must return the corrected timestamp as 15:30. | |
Required Process for Each User-Provided Timestamp: | |
For every timestamp the user suggests, you must: | |
Use <THINKING> tags to analyze each timestamp | |
Inside the thinking tags: | |
Quote the starting sentence the user claims begins at their suggested timestamp | |
Search the transcript for where that sentence actually appears | |
Compare the user's timestamp with the actual timestamp in the transcript | |
Note any discrepancies and identify the correct start time | |
Return your final answer with the corrected timestamps and properly formatted links | |
Example format: | |
<THINKING> | |
User claims the clip starts at 15:25 with discussion on Mark Zuckerberg. | |
Let me search the transcript for this sentence... Found it at 15:47, not 15:30. The correct start time is 15:47. | |
</THINKING> | |
[Continue with your response using the verified timestamp in the correct URL format as shown above.] | |
""" | |
def remove_unwanted_prompt(number_of_speakers: int): | |
if number_of_speakers == 1: | |
return """I want to crop this image only when absolutely necessary to remove partial objects or partial humans. | |
Please analyze the image and tell me: | |
1. The column number (1-20) on the left side where I should start the crop. Only suggest cropping (columns 1-4) if there are clear partial objects or humans that need removal. If no cropping is needed on the left, return 1. | |
2. The column number (1-20) on the right side where I should end the crop. Only suggest cropping (columns 17-20) if there are clear partial objects or humans that need removal. If no cropping is needed on the right, return 20. | |
I'm looking for minimal cropping - only cut when absolutely necessary to remove distracting partial elements. | |
Also tell the number of speakers that are completely visible and should be part of the crop. Generally it is either 1 or 2 but can be more. | |
""" | |