-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathprompts_summarization.py
31 lines (27 loc) · 1.19 KB
/
prompts_summarization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from helpers import get_response_pydantic, extend_contents
from pydantic_models.summarization import StepSummarySchema
def get_step_summary_v4(contents, steps, task):
if len(steps) == 0:
return None
if len(steps) == 1:
steps = f"step `{steps[0]}`"
else:
steps = "steps ```\n" + '; '.join(steps) + "\n```"
messages = [
{
"role": "system",
"content": "You are a helpful assistant specializing in analyzing tutorial video content. Given a narration of a tutorial video for the task `{task}`, identify and extract all procedural information about the {steps}. Make sure to extract the information itself and avoid describing how it was presented.".format(task=task, steps=steps)
},
{
"role": "user",
"content": [{
"type": "text",
"text": f"Contents:\n"
}] + extend_contents(contents, include_ids=True),
}
]
response = get_response_pydantic(messages, StepSummarySchema)
response["frame_paths"] = []
for content in contents:
response["frame_paths"] = response["frame_paths"] + content["frame_paths"]
return response