|
77 | 77 | "llama_index.core.set_global_handler(\"arize_phoenix\")"
|
78 | 78 | ]
|
79 | 79 | },
|
| 80 | + { |
| 81 | + "cell_type": "code", |
| 82 | + "execution_count": null, |
| 83 | + "id": "abc3f6b1", |
| 84 | + "metadata": {}, |
| 85 | + "outputs": [], |
| 86 | + "source": [ |
| 87 | + "import os\n", |
| 88 | + "\n", |
| 89 | + "os.environ[\"OPENAI_API_KEY\"] = \"sk-...\"" |
| 90 | + ] |
| 91 | + }, |
80 | 92 | {
|
81 | 93 | "cell_type": "code",
|
82 | 94 | "execution_count": null,
|
|
180 | 192 | "name": "stdout",
|
181 | 193 | "output_type": "stream",
|
182 | 194 | "text": [
|
183 |
| - "\u001b[1;3;38;2;155;135;227m> Running module 43554ab5-002f-4705-b5f1-f3fb4fd9bd44 with input: \n", |
| 195 | + "\u001b[1;3;38;2;155;135;227m> Running module 8dc57d24-9691-4d8d-87d7-151865a7cd1b with input: \n", |
184 | 196 | "movie_name: The Departed\n",
|
185 | 197 | "\n",
|
186 |
| - "\u001b[0m\u001b[1;3;38;2;155;135;227m> Running module 4b086131-f82b-4cb9-b929-427a60aca9c8 with input: \n", |
| 198 | + "\u001b[0m\u001b[1;3;38;2;155;135;227m> Running module 7ed9e26c-a704-4b0b-9cfd-991266e754c0 with input: \n", |
187 | 199 | "messages: Please generate related movies to The Departed\n",
|
188 | 200 | "\n",
|
189 | 201 | "\u001b[0m"
|
|
204 | 216 | "name": "stdout",
|
205 | 217 | "output_type": "stream",
|
206 | 218 | "text": [
|
207 |
| - "assistant: 1. Infernal Affairs (2002) - This is the original Hong Kong film that inspired The Departed. It follows a similar storyline of undercover cops infiltrating a criminal organization.\n", |
208 |
| - "\n", |
209 |
| - "2. Internal Affairs (1990) - This American crime thriller film shares a similar premise to The Departed, focusing on the corrupt practices within the police force.\n", |
210 |
| - "\n", |
211 |
| - "3. The Town (2010) - Directed by Ben Affleck, this crime drama revolves around a group of bank robbers in Boston and the FBI agent determined to bring them down.\n", |
212 |
| - "\n", |
213 |
| - "4. American Gangster (2007) - Based on a true story, this crime film explores the rise and fall of a drug lord in Harlem, New York, and the detective who is determined to bring him to justice.\n", |
214 |
| - "\n", |
215 |
| - "5. Donnie Brasco (1997) - Starring Johnny Depp and Al Pacino, this crime drama tells the story of an undercover FBI agent who infiltrates the mob and forms a close bond with a mafia hitman.\n", |
216 |
| - "\n", |
217 |
| - "6. The Departed (2006) - Although already mentioned, it is worth noting that The Departed itself is a highly acclaimed crime thriller directed by Martin Scorsese, exploring the intertwining lives of undercover cops and mobsters in Boston.\n", |
218 |
| - "\n", |
219 |
| - "7. Training Day (2001) - Denzel Washington won an Academy Award for his role in this crime thriller, where he plays a corrupt narcotics detective who takes a rookie cop under his wing for a day of training.\n", |
220 |
| - "\n", |
221 |
| - "8. Heat (1995) - Directed by Michael Mann, this crime film features an intense cat-and-mouse game between a skilled detective and a professional thief, both equally obsessed with their work.\n", |
| 219 | + "assistant: 1. Infernal Affairs (2002) - The original Hong Kong film that inspired The Departed\n", |
| 220 | + "2. The Town (2010) - A crime thriller directed by and starring Ben Affleck\n", |
| 221 | + "3. Mystic River (2003) - A crime drama directed by Clint Eastwood\n", |
| 222 | + "4. Goodfellas (1990) - A classic mobster film directed by Martin Scorsese\n", |
| 223 | + "5. The Irishman (2019) - Another crime drama directed by Martin Scorsese, starring Robert De Niro and Al Pacino\n", |
| 224 | + "6. The Departed (2006) - The Departed is a 2006 American crime film directed by Martin Scorsese and written by William Monahan. It is a remake of the 2002 Hong Kong film Infernal Affairs. The film stars Leonardo DiCaprio, Matt Damon, Jack Nicholson, and Mark Wahlberg, with Martin Sheen, Ray Winstone, Vera Farmiga, and Alec Baldwin in supporting roles.\n" |
| 225 | + ] |
| 226 | + } |
| 227 | + ], |
| 228 | + "source": [ |
| 229 | + "print(str(output))" |
| 230 | + ] |
| 231 | + }, |
| 232 | + { |
| 233 | + "cell_type": "markdown", |
| 234 | + "id": "9e84db05", |
| 235 | + "metadata": {}, |
| 236 | + "source": [ |
| 237 | + "### View Intermediate Inputs/Outputs\n", |
| 238 | + "\n", |
| 239 | + "For debugging and other purposes, we can also view the inputs and outputs at each step." |
| 240 | + ] |
| 241 | + }, |
| 242 | + { |
| 243 | + "cell_type": "code", |
| 244 | + "execution_count": null, |
| 245 | + "id": "6083e322", |
| 246 | + "metadata": {}, |
| 247 | + "outputs": [ |
| 248 | + { |
| 249 | + "name": "stdout", |
| 250 | + "output_type": "stream", |
| 251 | + "text": [ |
| 252 | + "\u001b[1;3;38;2;155;135;227m> Running module 8dc57d24-9691-4d8d-87d7-151865a7cd1b with input: \n", |
| 253 | + "movie_name: The Departed\n", |
222 | 254 | "\n",
|
223 |
| - "9. The Godfather (1972) - Francis Ford Coppola's iconic crime saga follows the Corleone family's rise to power in the world of organized crime, with themes of loyalty, betrayal, and family ties.\n", |
| 255 | + "\u001b[0m\u001b[1;3;38;2;155;135;227m> Running module 7ed9e26c-a704-4b0b-9cfd-991266e754c0 with input: \n", |
| 256 | + "messages: Please generate related movies to The Departed\n", |
224 | 257 | "\n",
|
225 |
| - "10. Casino (1995) - Directed by Martin Scorsese, this film delves into the dark underbelly of Las Vegas casinos, exploring the corrupt and violent world of mob-controlled gambling.\n" |
| 258 | + "\u001b[0m" |
226 | 259 | ]
|
227 | 260 | }
|
228 | 261 | ],
|
229 | 262 | "source": [
|
230 |
| - "print(str(output))" |
| 263 | + "output, intermediates = p.run_with_intermediates(movie_name=\"The Departed\")" |
| 264 | + ] |
| 265 | + }, |
| 266 | + { |
| 267 | + "cell_type": "code", |
| 268 | + "execution_count": null, |
| 269 | + "id": "1c0d5874", |
| 270 | + "metadata": {}, |
| 271 | + "outputs": [ |
| 272 | + { |
| 273 | + "data": { |
| 274 | + "text/plain": [ |
| 275 | + "ComponentIntermediates(inputs={'movie_name': 'The Departed'}, outputs={'prompt': 'Please generate related movies to The Departed'})" |
| 276 | + ] |
| 277 | + }, |
| 278 | + "execution_count": null, |
| 279 | + "metadata": {}, |
| 280 | + "output_type": "execute_result" |
| 281 | + } |
| 282 | + ], |
| 283 | + "source": [ |
| 284 | + "intermediates[\"8dc57d24-9691-4d8d-87d7-151865a7cd1b\"]" |
| 285 | + ] |
| 286 | + }, |
| 287 | + { |
| 288 | + "cell_type": "code", |
| 289 | + "execution_count": null, |
| 290 | + "id": "02cb9574", |
| 291 | + "metadata": {}, |
| 292 | + "outputs": [ |
| 293 | + { |
| 294 | + "data": { |
| 295 | + "text/plain": [ |
| 296 | + "ComponentIntermediates(inputs={'messages': 'Please generate related movies to The Departed'}, outputs={'output': ChatResponse(message=ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, content='1. Infernal Affairs (2002) - The original Hong Kong film that inspired The Departed\\n2. The Town (2010) - A crime thriller directed by Ben Affleck\\n3. Mystic River (2003) - A crime drama directed by Clint Eastwood\\n4. Goodfellas (1990) - A classic crime film directed by Martin Scorsese\\n5. The Irishman (2019) - Another crime film directed by Martin Scorsese, starring Robert De Niro and Al Pacino\\n6. The Godfather (1972) - A classic crime film directed by Francis Ford Coppola\\n7. Heat (1995) - A crime thriller directed by Michael Mann, starring Al Pacino and Robert De Niro\\n8. The Departed (2006) - A crime thriller directed by Martin Scorsese, starring Leonardo DiCaprio and Matt Damon.', additional_kwargs={}), raw={'id': 'chatcmpl-9EKf2nZ4latFJvHy0gzOUZbaB8xwY', 'choices': [Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='1. Infernal Affairs (2002) - The original Hong Kong film that inspired The Departed\\n2. The Town (2010) - A crime thriller directed by Ben Affleck\\n3. Mystic River (2003) - A crime drama directed by Clint Eastwood\\n4. Goodfellas (1990) - A classic crime film directed by Martin Scorsese\\n5. The Irishman (2019) - Another crime film directed by Martin Scorsese, starring Robert De Niro and Al Pacino\\n6. The Godfather (1972) - A classic crime film directed by Francis Ford Coppola\\n7. Heat (1995) - A crime thriller directed by Michael Mann, starring Al Pacino and Robert De Niro\\n8. The Departed (2006) - A crime thriller directed by Martin Scorsese, starring Leonardo DiCaprio and Matt Damon.', role='assistant', function_call=None, tool_calls=None))], 'created': 1713203040, 'model': 'gpt-3.5-turbo-0125', 'object': 'chat.completion', 'system_fingerprint': 'fp_c2295e73ad', 'usage': CompletionUsage(completion_tokens=184, prompt_tokens=15, total_tokens=199)}, delta=None, logprobs=None, additional_kwargs={})})" |
| 297 | + ] |
| 298 | + }, |
| 299 | + "execution_count": null, |
| 300 | + "metadata": {}, |
| 301 | + "output_type": "execute_result" |
| 302 | + } |
| 303 | + ], |
| 304 | + "source": [ |
| 305 | + "intermediates[\"7ed9e26c-a704-4b0b-9cfd-991266e754c0\"]" |
231 | 306 | ]
|
232 | 307 | },
|
233 | 308 | {
|
|
1154 | 1229 | ],
|
1155 | 1230 | "metadata": {
|
1156 | 1231 | "kernelspec": {
|
1157 |
| - "display_name": "llama_index_v2", |
| 1232 | + "display_name": "venv", |
1158 | 1233 | "language": "python",
|
1159 |
| - "name": "llama_index_v2" |
| 1234 | + "name": "python3" |
1160 | 1235 | },
|
1161 | 1236 | "language_info": {
|
1162 | 1237 | "codemirror_mode": {
|
|
0 commit comments