File size: 9,965 Bytes
31b6e27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
{
 "cells": [
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "import instructor\n",
    "from pydantic import BaseModel\n",
    "from openai import OpenAI\n",
    "\n",
    "import dotenv\n",
    "from tqdm.auto import trange\n",
    "\n",
    "import json"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T21:23:26.793952Z",
     "start_time": "2024-05-23T21:23:26.789582Z"
    }
   },
   "id": "1b2180343e5180dd",
   "execution_count": 36
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "True"
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dotenv.load_dotenv()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T20:49:24.686772Z",
     "start_time": "2024-05-23T20:49:24.683815Z"
    }
   },
   "id": "1296d472faf81f48",
   "execution_count": 20
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "def get_initial_messages(transcript: str):\n",
    "    return [\n",
    "        {\n",
    "            \"role\": \"system\",\n",
    "            \"content\": [\n",
    "                {\n",
    "                    \"type\": \"text\",\n",
    "                    \"text\": \"You are a trivia bot writing fun questions for a trivia game. You have been given a transcript of a video. You need to write two questions based on the transcript. Do not refer explicitly to the transcript - it should be a valid question at a trivia night, for fans of the show, which is Hot Ones, Season 19. The questions should be in a JSON format.\"\n",
    "                }\n",
    "            ]\n",
    "        },\n",
    "        {\n",
    "            \"role\": \"user\",\n",
    "            \"content\": [\n",
    "                {\n",
    "                    \"type\": \"text\",\n",
    "                    \"text\": f\"Transcript: {transcript}\"\n",
    "                }\n",
    "            ]\n",
    "        }\n",
    "    ]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T21:19:34.503329Z",
     "start_time": "2024-05-23T21:19:34.498Z"
    }
   },
   "id": "e511c7f86475ac01",
   "execution_count": 30
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "class TriviaQuestions(BaseModel):\n",
    "    question1: str\n",
    "    answer1: str\n",
    "    question2: str\n",
    "    answer2: str\n"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T21:19:34.945726Z",
     "start_time": "2024-05-23T21:19:34.944360Z"
    }
   },
   "id": "66b2c3c81748b42e",
   "execution_count": 31
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "\n",
    "# Patch the OpenAI client\n",
    "client = instructor.from_openai(OpenAI())"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T21:19:35.327482Z",
     "start_time": "2024-05-23T21:19:35.313726Z"
    }
   },
   "id": "e3f857ded1a29732",
   "execution_count": 32
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "  0%|          | 0/17 [00:00<?, ?it/s]",
      "application/vnd.jupyter.widget-view+json": {
       "version_major": 2,
       "version_minor": 0,
       "model_id": "497862b5404a4e3c9d9f7ae1a170b8eb"
      }
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "all_trivia = []\n",
    "for i in trange(17):\n",
    "    with open(f\"transcripts/{i}.vtt\") as f:\n",
    "        text = f.read()\n",
    "    msg = get_initial_messages(text)\n",
    "    \n",
    "    trivia = client.chat.completions.create(\n",
    "        model=\"gpt-4o\",\n",
    "        response_model=TriviaQuestions,\n",
    "        messages=msg,\n",
    "    )\n",
    "    \n",
    "    all_trivia.append(trivia)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T21:20:28.838601Z",
     "start_time": "2024-05-23T21:19:39.080663Z"
    }
   },
   "id": "d472211cac29e59c",
   "execution_count": 33
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "all_questions = sum([[t.question1, t.question2] for t in all_trivia], [])\n",
    "all_answers = sum([[t.answer1, t.answer2] for t in all_trivia], [])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T21:21:13.583657Z",
     "start_time": "2024-05-23T21:21:13.580310Z"
    }
   },
   "id": "fddeb7e20c845467",
   "execution_count": 34
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "[\"Which magician's documentary adventure series titled 'Beyond Belief' is coming soon to Disney Plus?\",\n 'In Hot Ones Season 19, which magician recounted learning to expel water like a stream from a performer in Liberia?',\n 'Who was the guest on the Hot Ones episode hosted by Sean Evans in which they joked about feeling their whiskers tingling?',\n 'In the Hot Ones episode with Puss in Boots, what common beverage was mentioned multiple times as being essential during the challenge?',\n 'Which charity is partnered with Hot Ones during their holiday fundraising efforts?',\n 'Who won the Hot Ones 2022 Lifetime Achievement Award?',\n \"Who did Emma Chamberlain claim she would marry, according to her 'F, Marry, Kill' choices involving milk types?\",\n \"What was Emma Chamberlain's major cooking success as mentioned on Hot Ones?\",\n 'Who hosted the Hot Ones season 19 Thanksgiving special with Israel Adesanya?',\n 'Which UFC fighter mentioned in the Hot Ones season 19 Thanksgiving special has defended his middleweight championship belt five times?',\n \"What challenges did the production face when shooting epic battle scenes in the film 'The Woman King' starring Viola Davis?\",\n \"Which television character portrayed by Viola Davis underwent significant transformation from the script to on-screen performance, as she discussed during the interview on 'Hot Ones'?\",\n 'In Hot Ones Season 19, which actress overcomes her spicy food fears while promoting the psychological drama \"TÁR\"?',\n 'Which challenging piece did Cate Blanchett preside over during a scene from the movie \"TÁR\" in Hot Ones Season 19?',\n \"What is the name of Kid Cudi's album and animated TV special mentioned on Hot Ones Season 19?\",\n 'Which fashion designer was responsible for the costume design in Kid Cudi\\'s animated TV special \"Intergalactic\"?',\n 'Which Emmy award-winning host appeared on Season 19 of Hot Ones and is known for The Late Late Show?',\n 'In which dark comedy drama series, set to release on Prime Video on November 11th, does James Corden star alongside Sally Hawkins?',\n 'Which actress, known for roles in Avatar, Star Trek, and Guardians of the Galaxy, appeared on Hot Ones in Season 19?',\n 'What upcoming movie directed by James Cameron was promoted by Zoe Saldana on Hot Ones, set for release on December 16th?',\n 'In Hot Ones Season 19, which actress and entrepreneur joined Sean Evans for an episode, discussing everything from her business ventures to her film roles?',\n \"In her Hot Ones appearance, which upcoming Netflix film did Kate Hudson promote, described as the 'long-weighted follow-up film'?\",\n 'What semi-autobiographical film directed by Steven Spielberg features Paul Dano as one of its main characters?',\n \"Which song by Nirvana influenced Paul Dano's portrayal of the Riddler?\",\n 'Who created the media company Lyrical Lemonade that has worked with artists like Eminem and Post Malone?',\n \"Who directed the music video for Eminem's song 'Godzilla' which featured Mike Tyson?\",\n 'What ingredient is mentioned in the transcript as a component of the spicy food being consumed?',\n 'What does one of the participants ask for during the spicy challenge in the transcript?',\n 'Which Hot Ones sauce featuring a sweet heat combination includes maple syrup, apple cider vinegar, and Fresno chilies?',\n 'What is the name of the Hot Ones sauce from Montreal, Canada, that features a blend of fruits like mango, papaya, and banana, combined with Scotch bonnet peppers?',\n 'Who was the guest on the episode of Hot Ones hosted by Sean Evans, where the guest discussed his struggles with faith and being human?',\n 'What comedy-drama series co-created by Rami Youssef was mentioned, which is now streaming on Netflix?',\n 'What is the name of the final sauce used in the Hot Ones challenge, often added as a tradition on the last wing?',\n 'Which hot sauce challenge involves eating a wing with extra sauce added at the end as a final tradition on the show Hot Ones?']"
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_questions"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T21:23:30.012900Z",
     "start_time": "2024-05-23T21:23:30.010901Z"
    }
   },
   "id": "6726839ddeb01f30",
   "execution_count": 37
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "with open(\"questions.json\", \"w\") as f:\n",
    "    json.dump(all_questions, f)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-05-23T21:23:30.594300Z",
     "start_time": "2024-05-23T21:23:30.589748Z"
    }
   },
   "id": "2adde26e15e3bb21",
   "execution_count": 38
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}