From d30d75a397f20098714ba1a233bfd79890e26499 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Fri, 12 Jul 2024 15:21:39 -0400 Subject: [PATCH] verify everything runs --- docs/source/apis.ipynb | 199 ++----- docs/source/document_extraction.ipynb | 727 ++++++++++++++++--------- docs/source/nested_objects.ipynb | 80 +-- docs/source/objects.ipynb | 29 +- docs/source/prompt.ipynb | 8 +- docs/source/schema_serialization.ipynb | 57 +- docs/source/tutorial.ipynb | 12 +- docs/source/type_descriptors.ipynb | 2 +- docs/source/untyped_objects.ipynb | 14 +- 9 files changed, 657 insertions(+), 471 deletions(-) diff --git a/docs/source/apis.ipynb b/docs/source/apis.ipynb index c00d0ba..4b125ac 100644 --- a/docs/source/apis.ipynb +++ b/docs/source/apis.ipynb @@ -48,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 23, "id": "f1313c02-d415-4ce6-bff0-3df537cc06c2", "metadata": { "tags": [] @@ -56,7 +56,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-3.5-turbo\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", ")" @@ -80,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 24, "id": "f61c94db-c05d-43ba-9ffc-b58552c715c3", "metadata": { "tags": [] @@ -137,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 25, "id": "ff9ad27f-7a81-4123-8d0b-1e14802df67e", "metadata": { "tags": [] @@ -157,7 +157,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 26, "id": "760baa5f-9368-4b5a-abc0-6ac65c34b7a7", "metadata": { "tags": [] @@ -169,18 +169,18 @@ "{'player': {'action': 'stop'}}" ] }, - "execution_count": 6, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "chain.run(\"stop the music now\")[\"data\"]" + "chain.run(\"stop the music now\")['data']" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 27, "id": "462303c0-e83a-4e39-86cd-cab6875b40ef", "metadata": { "tags": [] @@ -192,7 +192,7 @@ "{'player': {'action': 'play'}}" ] }, - "execution_count": 7, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -203,7 +203,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 28, "id": "02c7f1e5-1c8d-4e9f-82e6-c37a41d6de14", "metadata": { "tags": [] @@ -212,10 +212,10 @@ { "data": { "text/plain": [ - "{'player': {'album': ['the lion king soundtrack']}}" + "{'player': {'album': ['the lion king soundtrack'], 'action': 'play'}}" ] }, - "execution_count": 8, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -226,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 29, "id": "7a6d918c-53fe-426b-b37e-eec2abb8a704", "metadata": { "tags": [] @@ -235,13 +235,14 @@ { "data": { "text/plain": [ - "{'data': {'player': {'artist': ['paul simon', 'led zeppelin', 'the doors']}},\n", - " 'raw': '{\"player\": {\"artist\": [\"paul simon\", \"led zeppelin\", \"the doors\"]}}',\n", + "{'data': {'player': {'artist': ['paul simon', 'led zeppelin', 'the doors'],\n", + " 'action': 'play'}},\n", + " 'raw': '{\"player\": {\"artist\": [\"paul simon\", \"led zeppelin\", \"the doors\"], \"action\": \"play\"}}',\n", " 'errors': [],\n", " 'validated_data': {}}" ] }, - "execution_count": 9, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -252,7 +253,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 30, "id": "b18acf0a-d99e-48de-ace5-fb01bded5a41", "metadata": { "tags": [] @@ -264,7 +265,7 @@ "{'player': {'action': 'previous'}}" ] }, - "execution_count": 10, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -285,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 31, "id": "c50b080b-7179-4bbe-b234-83ce59e2d215", "metadata": { "tags": [] @@ -332,7 +333,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 32, "id": "404e4f1a-d316-41f2-ab94-040e22001fc4", "metadata": { "tags": [] @@ -344,7 +345,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 33, "id": "73c31ace-32dd-4a33-ae39-475db6934f6d", "metadata": { "tags": [] @@ -355,10 +356,10 @@ "text/plain": [ "{'action': {'sport': 'baseball',\n", " 'location': 'LA area',\n", - " 'price_range': {'price_max': '100', 'currency': '$'}}}" + " 'price_range': {'price_max': '100'}}}" ] }, - "execution_count": 13, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -369,7 +370,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 34, "id": "78e3b3af-bfa8-4503-854a-b83a7f8f49e6", "metadata": { "tags": [] @@ -378,12 +379,12 @@ { "data": { "text/plain": [ - "{'action': {'sport': 'celtics',\n", + "{'action': {'sport': 'basketball',\n", " 'location': 'boston',\n", - " 'price_range': {'price_min': '20', 'price_max': '40', 'currency': '$'}}}" + " 'price_range': {'price_max': '40', 'price_min': '20', 'currency': '$'}}}" ] }, - "execution_count": 14, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -410,7 +411,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 35, "id": "2b0bcf09-a3ae-4a8a-9ce3-f86834ce6ca2", "metadata": { "tags": [] @@ -573,7 +574,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 36, "id": "7b389d20-ae6b-4764-9209-3cd3c2f0a715", "metadata": { "tags": [] @@ -593,7 +594,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 37, "id": "b203ac4a-4f9f-45c6-a509-39b9a6cfd98f", "metadata": { "tags": [] @@ -605,7 +606,7 @@ "{}" ] }, - "execution_count": 17, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -620,7 +621,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 38, "id": "398377bf-5d30-4b4c-b637-e9af969d16a4", "metadata": { "tags": [] @@ -629,14 +630,15 @@ { "data": { "text/plain": [ - "{'search_for_companies': {'attribute_filter': [{'attribute': 'market cap',\n", + "{'search_for_companies': {'geography_name': 'india',\n", + " 'attribute_filter': [{'attribute': 'market cap',\n", " 'op': '>',\n", - " 'value': '1 million'},\n", + " 'value': '1000000'},\n", " {'attribute': 'employees', 'op': 'in', 'value': ['20', '50']}],\n", " 'attribute_selection': ['revenue', 'eps']}}" ] }, - "execution_count": 18, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -651,7 +653,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 39, "id": "2a620246-4c85-4256-8f58-0acbcc9455a3", "metadata": { "tags": [] @@ -660,12 +662,12 @@ { "data": { "text/plain": [ - "{'search_for_companies': {'attribute_filter': [{'attribute': 'building_color',\n", + "{'search_for_companies': {'attribute_filter': [{'attribute': 'building color',\n", " 'op': 'in',\n", " 'value': ['red', 'blue']}]}}" ] }, - "execution_count": 19, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -677,7 +679,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 40, "id": "4745517e-507e-4d1a-97e0-d143fa34cea2", "metadata": { "tags": [] @@ -687,12 +689,12 @@ "data": { "text/plain": [ "{'search_for_companies': {'geography_name': 'germany',\n", + " 'attribute_selection': ['revenue'],\n", " 'sort_block': {'direction': 'descending',\n", - " 'attribute': 'number of employees'},\n", - " 'attribute_selection': ['revenue']}}" + " 'attribute': 'number of employees'}}}" ] }, - "execution_count": 20, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -704,27 +706,12 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "id": "b206407f-57e0-4212-8e75-970cb49b52e5", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'search_for_companies': {'attribute_filter': [{'attribute': 'market cap',\n", - " 'op': '>',\n", - " 'value': '1000000'},\n", - " {'attribute': 'building color', 'op': 'in', 'value': ['red', 'blue']}],\n", - " 'attribute_selection': ['revenue', 'eps']}}" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "text = (\n", " \"revenue, eps of indian companies that have market cap of over 1 million, \"\n", @@ -735,100 +722,12 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "id": "a1025f99-eb0a-4d96-923e-35f36e4ac6b2", "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Your goal is to extract structured information from the user's input that matches the form described below. When extracting information please make sure it matches the type information exactly. Do not add any attributes that do not appear in the schema shown below.\n", - "\n", - "```TypeScript\n", - "\n", - "search_for_companies: { // Search for companies matching the following criteria.\n", - " company_name: Array // what is the name of the company you want to find\n", - " geography_name: string // where is the company based?\n", - " foundation_date: string // Foundation date of the company\n", - " industry_name: Array // what is the name of the company's industry\n", - " geography_sales: Array // where is the company doing sales? Please use a single country name.\n", - " attribute_filter: Array<{ // Filter by a value of an attribute using a binary expression. Specify the attribute's name, an operator (>, <, =, !=, >=, <=, in, not in) and a value.\n", - " }>\n", - " attribute_selection: Array // Asking to see the value of one or more attributes\n", - " sort_block: { // Use to request to sort the results by a particular attribute. Can specify the direction\n", - " direction: string // The direction of the sort\n", - " attribute: string // The sort attribute\n", - " }\n", - "}\n", - "```\n", - "\n", - "\n", - "Please output the extracted information in JSON format. Do not output anything except for the extracted information. Do not add any clarifying information. Do not add any fields that are not in the schema. If the text contains attributes that do not appear in the schema, please ignore them. All output must be in JSON format and follow the schema specified above. Wrap the JSON in tags.\n", - "\n", - "\n", - "\n", - "Input: Apple inc\n", - "Output: {\"search_for_companies\": {\"company_name\": [\"Apple inc\"]}}\n", - "Input: largest 10 banks in the world\n", - "Output: {}\n", - "Input: microsoft and apple\n", - "Output: {\"search_for_companies\": {\"company_name\": [\"microsoft,apple\"]}}\n", - "Input: chinese companies\n", - "Output: {\"search_for_companies\": {\"geography_name\": \"china\"}}\n", - "Input: companies based in france\n", - "Output: {\"search_for_companies\": {\"geography_name\": \"france\"}}\n", - "Input: LaMaple was based in france, italy\n", - "Output: {\"search_for_companies\": {\"geography_name\": [\"france\", \"italy\"]}}\n", - "Input: italy\n", - "Output: {}\n", - "Input: companies founded in 2023\n", - "Output: {\"search_for_companies\": {\"foundation_date\": \"2023\"}}\n", - "Input: companies in the steel manufacturing industry\n", - "Output: {\"search_for_companies\": {\"industry_name\": [\"steel manufacturing\"]}}\n", - "Input: large banks\n", - "Output: {\"search_for_companies\": {\"industry_name\": [\"banking\"]}}\n", - "Input: military companies\n", - "Output: {\"search_for_companies\": {\"industry_name\": [\"defense\"]}}\n", - "Input: chinese companies\n", - "Output: {}\n", - "Input: companies that cell cigars\n", - "Output: {\"search_for_companies\": {\"industry_name\": [\"cigars\"]}}\n", - "Input: companies with sales in france\n", - "Output: {\"search_for_companies\": {\"geography_sales\": [\"france\"]}}\n", - "Input: companies that sell their products in germany\n", - "Output: {\"search_for_companies\": {\"geography_sales\": [\"germany\"]}}\n", - "Input: france, italy\n", - "Output: {}\n", - "Input: Companies with revenue > 100\n", - "Output: {\"search_for_companies\": {\"attribute_filter\": [{\"attribute\": \"revenue\", \"op\": \">\", \"value\": \"100\"}]}}\n", - "Input: number of employees between 50 and 1000\n", - "Output: {\"search_for_companies\": {\"attribute_filter\": [{\"attribute\": \"employees\", \"op\": \"in\", \"value\": [\"50\", \"1000\"]}]}}\n", - "Input: blue or green color\n", - "Output: {\"search_for_companies\": {\"attribute_filter\": [{\"attribute\": \"color\", \"op\": \"in\", \"value\": [\"blue\", \"green\"]}]}}\n", - "Input: companies that do not sell in california\n", - "Output: {\"search_for_companies\": {\"attribute_filter\": [{\"attribute\": \"geography-sales\", \"op\": \"not in\", \"value\": \"california\"}]}}\n", - "Input: What is the revenue of tech companies?\n", - "Output: {\"search_for_companies\": {\"attribute_selection\": [\"revenue\"]}}\n", - "Input: market cap of apple?\n", - "Output: {\"search_for_companies\": {\"attribute_selection\": [\"market cap\"]}}\n", - "Input: number of employees of largest company\n", - "Output: {\"search_for_companies\": {\"attribute_selection\": [\"number of employees\"]}}\n", - "Input: what are the revenue and market cap of apple\n", - "Output: {\"search_for_companies\": {\"attribute_selection\": [\"revenue\", \"market cap\"]}}\n", - "Input: share price and number of shares of indian companies\n", - "Output: {\"search_for_companies\": {\"attribute_selection\": [\"share price\", \"number of shares\"]}}\n", - "Input: Largest by market-cap tech companies\n", - "Output: {\"search_for_companies\": {\"sort_block\": {\"direction\": \"descending\", \"attribute\": \"market-cap\"}}}\n", - "Input: sort by companies with smallest revenue \n", - "Output: {\"search_for_companies\": {\"sort_block\": {\"direction\": \"ascending\", \"attribute\": \"revenue\"}}}\n", - "Input: [user_input]\n", - "Output:\n" - ] - } - ], + "outputs": [], "source": [ "print(chain.prompt.format_prompt(\"[user_input]\").to_string())" ] @@ -850,7 +749,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/docs/source/document_extraction.ipynb b/docs/source/document_extraction.ipynb index 261c8c9..6eb2738 100644 --- a/docs/source/document_extraction.ipynb +++ b/docs/source/document_extraction.ipynb @@ -80,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 12, "id": "d93b3de7-9b81-456e-acff-4b0df9755c14", "metadata": { "nbsphinx": "hidden", @@ -93,7 +93,7 @@ "import requests\n", "\n", "import pandas as pd\n", - "from pydantic import BaseModel, Field, validator\n", + "from pydantic import BaseModel, Field, field_validator\n", "from kor import extract_from_documents, from_pydantic, create_extraction_chain\n", "from kor.documents.html import MarkdownifyHTMLProcessor\n", "from langchain_core.documents import Document\n", @@ -132,7 +132,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 13, "id": "fab20ada-6443-4799-b6e8-faf16a2fb585", "metadata": { "tags": [] @@ -153,13 +153,15 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 15, "id": "981938c5-f438-49a0-b511-329d31073a56", "metadata": { "tags": [] }, "outputs": [], "source": [ + "\n", + "\n", "class ShowOrMovie(BaseModel):\n", " name: str = Field(\n", " description=\"The name of the movie or tv show\",\n", @@ -179,7 +181,7 @@ " # you could try extracting it by using the raw HTML (rather than markdown)\n", " # or you could try doing something similar on imdb\n", "\n", - " @validator(\"name\")\n", + " @field_validator(\"name\")\n", " def name_must_not_be_empty(cls, v):\n", " if not v:\n", " raise ValueError(\"Name must not be empty\")\n", @@ -201,7 +203,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 16, "id": "ff57507d-d789-4ae3-8763-0465e8b27686", "metadata": { "tags": [] @@ -229,7 +231,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 17, "id": "b5bd49b1-0b51-40ff-b34b-3ad7f90423b6", "metadata": { "tags": [] @@ -273,7 +275,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 18, "id": "396a16b7-bc45-4035-9848-f995cddbba2f", "metadata": { "tags": [] @@ -295,7 +297,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 19, "id": "22d3229a-aa6f-4586-a527-6f7835800740", "metadata": { "tags": [] @@ -315,7 +317,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 20, "id": "814e4151-f7d7-412d-beab-58ed190b7dd3", "metadata": { "tags": [] @@ -327,7 +329,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 21, "id": "e663f031-7a61-4a27-b925-1c9a6f365bcc", "metadata": { "tags": [] @@ -337,25 +339,139 @@ "name": "stdout", "output_type": "stream", "text": [ - "Watch the trailer for You\n", + "Latest Episode: Jul 11](/tv/vikings_valhalla)\n", + "\n", + "Watch the trailer for Land of Women\n", + "\n", + "[89%\n", + "\n", + " 35%\n", + "\n", + " Land of Women\n", + "\n", + " Latest Episode: Jul 10](/tv/land_of_women)\n", + "\n", + "[100%\n", + "\n", + " 68%\n", + "\n", + " The Mole\n", + "\n", + " Latest Episode: Jul 12](/tv/the_mole_2022)\n", + "\n", + "Watch the trailer for Bridgerton\n", + "\n", + "[84%\n", + "\n", + " 73%\n", + "\n", + " Bridgerton\n", + "\n", + " Latest Episode: Jun 13](/tv/bridgerton)\n", + "\n", + "Watch the trailer for Your Honor\n", + "\n", + "[50%\n", + "\n", + " 68%\n", + "\n", + " Your Honor](/tv/your_honor_2020)\n", + "\n", + "Watch the trailer for Mayor of Kingstown\n", + "\n", + "[51%\n", + "\n", + " 89%\n", + "\n", + " Mayor of Kingstown\n", + "\n", + " Latest Episode: Jul 07](/tv/mayor_of_kingstown)\n", + "\n", + "Watch the trailer for The Serpent Queen\n", + "\n", + "[100%\n", + "\n", + " 84%\n", + "\n", + " The Serpent Queen\n", + "\n", + " Latest Episode: Jul 12](/tv/the_serpent_queen)\n", + "\n", + "Watch the trailer for True Detective\n", + "\n", + "[79%\n", "\n", - "[You\n", + " 57%\n", "\n", - " Latest Episode: Mar 09](/tv/you)\n", + " True Detective](/tv/true_detective)\n", "\n", - "Watch the trailer for She-Hulk: Attorney at Law\n", + "[67%\n", "\n", - "[She-Hulk: Attorney at Law](/tv/she_hulk_attorney_at_law)\n", + " Mirzapur\n", "\n", - "[Breaking Bad](/tv/breaking_bad)\n", + " Latest Episode: Jul 05](/tv/mirzapur)\n", "\n", - "Watch the trailer for The Lord of the Rings: The Rings of Power\n", + "Watch the trailer for Hotel Cocaine\n", "\n", - "[The Lord of the Rings: The Rings of Power](/tv/the_lord_of_the_rings_the_rings_of_power)\n", + "[70%\n", "\n", - "No results\n", + " Hotel Cocaine\n", "\n", - " Reset Filters\n", + " Latest Episode: Jul 07](/tv/hotel_cocaine)\n", + "\n", + "[86%\n", + "\n", + " 69%\n", + "\n", + " A Good Girl's Guide to Murder\n", + "\n", + " Latest Episode: Jul 01](/tv/a_good_girls_guide_to_murder)\n", + "\n", + "Watch the trailer for Eric\n", + "\n", + "[72%\n", + "\n", + " 58%\n", + "\n", + " Eric\n", + "\n", + " Latest Episode: May 30](/tv/eric)\n", + "\n", + "Watch the trailer for Game of Thrones\n", + "\n", + "[89%\n", + "\n", + " 85%\n", + "\n", + " Game of Thrones](/tv/game_of_thrones)\n", + "\n", + "Watch the trailer for Shōgun\n", + "\n", + "[99%\n", + "\n", + " 91%\n", + "\n", + " Shōgun\n", + "\n", + " Latest Episode: Apr 23](/tv/shogun_2024)\n", + "\n", + "Watch the trailer for Geek Girl\n", + "\n", + "[100%\n", + "\n", + " 75%\n", + "\n", + " Geek Girl\n", + "\n", + " Latest Episode: May 30](/tv/geek_girl)\n", + "\n", + "Watch the trailer for Dear Child\n", + "\n", + "[100%\n", + "\n", + " 84%\n", + "\n", + " Dear Child](/tv/dear_child)\n", "\n", " Load more\n", "\n", @@ -375,39 +491,34 @@ "* [Advertise With Us](https://together.nbcuni.com/advertise/?utm_source=rotten_tomatoes&utm_medium=referral&utm_campaign=property_ad_pages&utm_content=footer)\n", "* [Careers](//www.fandango.com/careers)\n", "\n", - "Join The Newsletter\n", + " Join the Newsletter\n", "\n", "Get the freshest reviews, news, and more delivered right to your inbox!\n", "\n", + " Join The Newsletter\n", + "\n", "Join The Newsletter\n", - "[Join The Newsletter](https://optout.services.fandango.com/rottentomatoes)\n", "\n", "Follow Us\n", "\n", - "* \n", - "* \n", - "* \n", - "* \n", - "* \n", - "\n", "Copyright © Fandango. All rights reserved.\n", "\n", - "Join Newsletter\n", - "[Join Newsletter](https://optout.services.fandango.com/rottentomatoes)\n", - "* [Privacy Policy](//www.fandango.com/policies/privacy-policy)\n", - "* [Terms and Policies](//www.fandango.com/policies/terms-and-policies)\n", - "* [Cookie Settings](javascript:void(0))\n", - "* [California Notice](//www.fandango.com/californianotice)\n", - "* [Ad Choices](//www.fandango.com/policies/cookies-and-tracking#cookie_management)\n", + "Join The Newsletter\n", + "Join The Newsletter\n", + "* [Privacy Policy](https://www.nbcuniversal.com/fandango-privacy-policy)\n", + "* [Terms and Policies](/policies/terms-and-policies)\n", + "* \n", + "* [California Notice](https://www.nbcuniversal.com/privacy/california-consumer-privacy-act)\n", + "* [Ad Choices](https://www.nbcuniversal.com/privacy/cookies#accordionheader2)\n", "* \n", "* [Accessibility](/faq#accessibility)\n", "\n", "* V3.1\n", - "* [Privacy Policy](//www.fandango.com/policies/privacy-policy)\n", - "* [Terms and Policies](//www.fandango.com/policies/terms-and-policies)\n", - "* [Cookie Settings](javascript:void(0))\n", - "* [California Notice](//www.fandango.com/californianotice)\n", - "* [Ad Choices](//www.fandango.com/policies/cookies-and-tracking#cookie_management)\n", + "* [Privacy Policy](https://www.nbcuniversal.com/fandango-privacy-policy)\n", + "* [Terms and Policies](/policies/terms-and-policies)\n", + "* \n", + "* [California Notice](https://www.nbcuniversal.com/privacy/california-consumer-privacy-act)\n", + "* [Ad Choices](https://www.nbcuniversal.com/privacy/cookies#accordionheader2)\n", "* [Accessibility](/faq#accessibility)\n", "\n", "Copyright © Fandango. All rights reserved.\n" @@ -420,7 +531,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 22, "id": "ec72cb5b-1fcb-4381-85e8-f060ea1f0077", "metadata": { "tags": [] @@ -432,7 +543,7 @@ "4" ] }, - "execution_count": 11, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -451,7 +562,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 23, "id": "1d17ebaa-8222-48df-82d9-42173a60f5f7", "metadata": { "tags": [] @@ -463,21 +574,29 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 24, "id": "bdb85b12-25b9-477c-bf7e-5407812f4807", "metadata": { "tags": [] }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/eugene/.pyenv/versions/3.9.6/envs/kor/lib/python3.9/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `Chain.arun` was deprecated in langchain 0.1.0 and will be removed in 0.2.0. Use ainvoke instead.\n", + " warn_deprecated(\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "Total Tokens: 5854\n", - "Prompt Tokens: 5128\n", - "Completion Tokens: 726\n", + "Total Tokens: 6342\n", + "Prompt Tokens: 5390\n", + "Completion Tokens: 952\n", "Successful Requests: 4\n", - "Total Cost (USD): $0.011708000000000001\n" + "Total Cost (USD): $0.009989000000000001\n" ] } ], @@ -495,7 +614,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 25, "id": "d00f86ed-48c3-46c3-8d37-49de50817d93", "metadata": { "tags": [] @@ -511,7 +630,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 26, "id": "89e35b77-aac4-4a32-9515-9ebe9bfef046", "metadata": { "tags": [] @@ -520,10 +639,10 @@ { "data": { "text/plain": [ - "40" + "50" ] }, - "execution_count": 15, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -542,7 +661,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 27, "id": "75f3e35e-d6a9-4c0d-a5c3-a509eaf7d6ec", "metadata": { "tags": [] @@ -579,415 +698,515 @@ " \n", " \n", " 0\n", - " Beef\n", + " Sunny\n", " 1\n", " \n", " \n", - " /tv/beef/s01\n", + " /tv/sunny/s01\n", " \n", " \n", " 1\n", - " Dave\n", + " Vikings: Valhalla\n", " 3\n", " \n", " \n", - " /tv/dave/s03\n", + " /tv/vikings_valhalla/s03\n", " \n", " \n", " 2\n", - " Schmigadoon!\n", - " 2\n", + " Sunny\n", + " 1\n", " \n", " \n", - " /tv/schmigadoon/s02\n", + " /tv/sunny/s01\n", " \n", " \n", " 3\n", - " Pretty Baby: Brooke Shields\n", - " 1\n", + " Vikings: Valhalla\n", + " 3\n", " \n", " \n", - " /tv/pretty_baby_brooke_shields/s01\n", + " /tv/vikings_valhalla/s03\n", " \n", " \n", " 4\n", - " Tiny Beautiful Things\n", + " Sausage Party: Foodtopia\n", " 1\n", " \n", " \n", - " /tv/tiny_beautiful_things/s01\n", + " /tv/sausage_party_foodtopia/s01\n", " \n", " \n", " 5\n", - " Grease: Rise of the Pink Ladies\n", - " 1\n", + " The Serpent Queen\n", + " 2\n", " \n", " \n", - " /tv/grease_rise_of_the_pink_ladies/s01\n", + " /tv/the_serpent_queen/s02\n", " \n", " \n", " 6\n", - " Jury Duty\n", + " Me\n", " 1\n", " \n", " \n", - " /tv/jury_duty/s01\n", + " /tv/me/s01\n", " \n", " \n", " 7\n", - " The Crossover\n", - " 1\n", + " The Bachelorette\n", + " 21\n", " \n", " \n", - " /tv/the_crossover/s01\n", + " /tv/the_bachelorette/s21\n", " \n", " \n", " 8\n", - " Transatlantic\n", + " Mastermind: To Think Like a Killer\n", " 1\n", " \n", " \n", - " /tv/transatlantic/s01\n", + " /tv/mastermind_to_think_like_a_killer/s01\n", " \n", " \n", " 9\n", - " Race to Survive: Alaska\n", + " Melissa Etheridge: I'm Not Broken\n", " 1\n", " \n", " \n", - " /tv/race_to_survive_alaska/s01\n", + " /tv/melissa_etheridge_im_not_broken/s01\n", " \n", " \n", " 10\n", - " Beef\n", + " All American: Homecoming\n", + " 3\n", " \n", " \n", - " Apr 06\n", - " /tv/beef\n", + " /tv/all_american_homecoming/s03\n", " \n", " \n", " 11\n", - " The Night Agent\n", + " Supacell\n", + " 1\n", " \n", " \n", - " Mar 23\n", - " /tv/the_night_agent\n", + " /tv/supacell/s01\n", " \n", " \n", " 12\n", - " Unstable\n", + " Star Wars: The Acolyte\n", + " 1\n", " \n", " \n", - " Mar 30\n", - " /tv/unstable\n", + " /tv/star_wars_the_acolyte/s01\n", " \n", " \n", " 13\n", - " The Mandalorian\n", + " The Bear\n", + " 3\n", " \n", " \n", - " Apr 05\n", - " /tv/the_mandalorian\n", + " /tv/the_bear/s03\n", " \n", " \n", " 14\n", - " The Big Door Prize\n", + " The Boys\n", + " 4\n", " \n", " \n", - " Apr 05\n", - " /tv/the_big_door_prize\n", + " /tv/the_boys_2019/s04\n", " \n", " \n", " 15\n", - " Class of '07\n", + " Presumed Innocent\n", + " 1\n", " \n", " \n", - " Mar 17\n", - " /tv/class_of_07\n", + " /tv/presumed_innocent/s01\n", " \n", " \n", " 16\n", - " Rabbit Hole\n", + " My Lady Jane\n", + " 1\n", " \n", " \n", - " Apr 02\n", - " /tv/rabbit_hole\n", + " /tv/my_lady_jane/s01\n", " \n", " \n", " 17\n", - " The Power\n", + " House of the Dragon\n", + " 2\n", " \n", " \n", - " Apr 07\n", - " /tv/the_power\n", + " /tv/house_of_the_dragon/s02\n", " \n", " \n", " 18\n", - " The Last of Us\n", + " The Mole\n", + " 2\n", " \n", " \n", - " Mar 12\n", - " /tv/the_last_of_us\n", + " /tv/the_mole_2022/s02\n", " \n", " \n", " 19\n", - " Yellowjackets\n", + " Dark Matter\n", + " 1\n", " \n", " \n", - " Mar 31\n", - " /tv/yellowjackets\n", + " /tv/dark_matter_2024/s01\n", " \n", " \n", " 20\n", - " Succession\n", + " Star Wars: The Acolyte\n", " \n", " \n", - " Apr 02\n", - " /tv/succession\n", + " Jul 09\n", + " /tv/star_wars_the_acolyte\n", " \n", " \n", " 21\n", - " Lucky Hank\n", + " The Boys\n", " \n", - " \n", - " Apr 02\n", - " /tv/lucky_hank\n", + " 2019\n", + " Jul 11\n", + " /tv/the_boys_2019\n", " \n", " \n", " 22\n", - " Sex/Life\n", + " Supacell\n", " \n", " \n", - " Mar 02\n", - " /tv/sex_life\n", + " Jun 27\n", + " /tv/supacell\n", " \n", " \n", " 23\n", - " Ted Lasso\n", + " The Bear\n", " \n", " \n", - " Apr 05\n", - " /tv/ted_lasso\n", + " Jun 26\n", + " /tv/the_bear\n", " \n", " \n", " 24\n", - " Wellmania\n", + " Sunny\n", " \n", " \n", - " Mar 29\n", - " /tv/wellmania\n", + " Jul 10\n", + " /tv/sunny\n", " \n", " \n", " 25\n", - " Daisy Jones & the Six\n", + " House of the Dragon\n", " \n", " \n", - " Mar 24\n", - " /tv/daisy_jones_and_the_six\n", + " Jul 07\n", + " /tv/house_of_the_dragon\n", " \n", " \n", " 26\n", - " Shadow and Bone\n", + " My Lady Jane\n", " \n", " \n", - " Mar 16\n", - " /tv/shadow_and_bone\n", + " Jun 27\n", + " /tv/my_lady_jane\n", " \n", " \n", " 27\n", - " The Order\n", - " \n", + " Presumed Innocent\n", " \n", " \n", - " /tv/the_order\n", + " Jul 10\n", + " /tv/presumed_innocent\n", " \n", " \n", " 28\n", - " Shrinking\n", + " Sausage Party: Foodtopia\n", " \n", " \n", - " Mar 24\n", - " /tv/shrinking\n", + " Jul 11\n", + " /tv/sausage_party_foodtopia\n", " \n", " \n", " 29\n", - " Swarm\n", - " \n", + " Dark Matter\n", " \n", - " Mar 17\n", - " /tv/swarm\n", + " 2024\n", + " Jun 26\n", + " /tv/dark_matter_2024\n", " \n", " \n", " 30\n", - " The Last Kingdom\n", + " Evil\n", " \n", " \n", - " \n", - " /tv/the_last_kingdom\n", + " Jul 11\n", + " /tv/evil\n", " \n", " \n", " 31\n", - " Rain Dogs\n", + " Interview With the Vampire\n", " \n", " \n", - " Apr 03\n", - " /tv/rain_dogs\n", + " Jun 30\n", + " /tv/interview_with_the_vampire\n", " \n", " \n", " 32\n", - " Extrapolations\n", + " Vikings: Valhalla\n", " \n", " \n", - " Apr 07\n", - " /tv/extrapolations\n", + " Jul 11\n", + " /tv/vikings_valhalla\n", " \n", " \n", " 33\n", - " War Sailor\n", + " Land of Women\n", " \n", " \n", - " Apr 02\n", - " /tv/war_sailor\n", + " Jul 10\n", + " /tv/land_of_women\n", " \n", " \n", " 34\n", - " You\n", + " Vikings Valhalla\n", " \n", " \n", - " Mar 09\n", - " /tv/you\n", + " Jul 11\n", + " /tv/vikings_valhalla\n", " \n", " \n", " 35\n", - " She-Hulk: Attorney at Law\n", - " \n", + " Land of Women\n", " \n", " \n", - " /tv/she_hulk_attorney_at_law\n", + " Jul 10\n", + " /tv/land_of_women\n", " \n", " \n", " 36\n", - " You\n", + " The Mole\n", " \n", " \n", - " Mar 09\n", - " /tv/you\n", + " Jul 12\n", + " /tv/the_mole_2022\n", " \n", " \n", " 37\n", - " She-Hulk: Attorney at Law\n", + " Bridgerton\n", " \n", " \n", - " None\n", - " /tv/she_hulk_attorney_at_law\n", + " Jun 13\n", + " /tv/bridgerton\n", " \n", " \n", " 38\n", - " Breaking Bad\n", + " Your Honor\n", " \n", " \n", - " None\n", - " /tv/breaking_bad\n", + " Jul 07\n", + " /tv/your_honor_2020\n", " \n", " \n", " 39\n", - " The Lord of the Rings: The Rings of Power\n", + " Mayor of Kingstown\n", + " \n", + " \n", + " Jul 07\n", + " /tv/mayor_of_kingstown\n", + " \n", + " \n", + " 40\n", + " The Serpent Queen\n", + " \n", + " \n", + " Jul 12\n", + " /tv/the_serpent_queen\n", + " \n", + " \n", + " 41\n", + " True Detective\n", + " \n", + " \n", + " Jul 05\n", + " /tv/true_detective\n", + " \n", + " \n", + " 42\n", + " Mirzapur\n", + " \n", + " \n", + " Jul 05\n", + " /tv/mirzapur\n", + " \n", + " \n", + " 43\n", + " Hotel Cocaine\n", + " \n", + " \n", + " Jul 07\n", + " /tv/hotel_cocaine\n", + " \n", + " \n", + " 44\n", + " A Good Girl's Guide to Murder\n", + " \n", + " \n", + " Jul 01\n", + " /tv/a_good_girls_guide_to_murder\n", + " \n", + " \n", + " 45\n", + " Eric\n", + " \n", + " \n", + " May 30\n", + " /tv/eric\n", + " \n", + " \n", + " 46\n", + " Game of Thrones\n", + " \n", + " \n", + " May 30\n", + " /tv/game_of_thrones\n", + " \n", + " \n", + " 47\n", + " Shōgun\n", + " \n", + " \n", + " Apr 23\n", + " /tv/shogun_2024\n", + " \n", + " \n", + " 48\n", + " Geek Girl\n", + " \n", + " \n", + " May 30\n", + " /tv/geek_girl\n", + " \n", + " \n", + " 49\n", + " Dear Child\n", " \n", " \n", - " None\n", - " /tv/the_lord_of_the_rings_the_rings_of_power\n", + " May 30\n", + " /tv/dear_child\n", " \n", " \n", "\n", "" ], "text/plain": [ - " name season year latest_episode \\\n", - "0 Beef 1 \n", - "1 Dave 3 \n", - "2 Schmigadoon! 2 \n", - "3 Pretty Baby: Brooke Shields 1 \n", - "4 Tiny Beautiful Things 1 \n", - "5 Grease: Rise of the Pink Ladies 1 \n", - "6 Jury Duty 1 \n", - "7 The Crossover 1 \n", - "8 Transatlantic 1 \n", - "9 Race to Survive: Alaska 1 \n", - "10 Beef Apr 06 \n", - "11 The Night Agent Mar 23 \n", - "12 Unstable Mar 30 \n", - "13 The Mandalorian Apr 05 \n", - "14 The Big Door Prize Apr 05 \n", - "15 Class of '07 Mar 17 \n", - "16 Rabbit Hole Apr 02 \n", - "17 The Power Apr 07 \n", - "18 The Last of Us Mar 12 \n", - "19 Yellowjackets Mar 31 \n", - "20 Succession Apr 02 \n", - "21 Lucky Hank Apr 02 \n", - "22 Sex/Life Mar 02 \n", - "23 Ted Lasso Apr 05 \n", - "24 Wellmania Mar 29 \n", - "25 Daisy Jones & the Six Mar 24 \n", - "26 Shadow and Bone Mar 16 \n", - "27 The Order \n", - "28 Shrinking Mar 24 \n", - "29 Swarm Mar 17 \n", - "30 The Last Kingdom \n", - "31 Rain Dogs Apr 03 \n", - "32 Extrapolations Apr 07 \n", - "33 War Sailor Apr 02 \n", - "34 You Mar 09 \n", - "35 She-Hulk: Attorney at Law \n", - "36 You Mar 09 \n", - "37 She-Hulk: Attorney at Law None \n", - "38 Breaking Bad None \n", - "39 The Lord of the Rings: The Rings of Power None \n", + " name season year latest_episode \\\n", + "0 Sunny 1 \n", + "1 Vikings: Valhalla 3 \n", + "2 Sunny 1 \n", + "3 Vikings: Valhalla 3 \n", + "4 Sausage Party: Foodtopia 1 \n", + "5 The Serpent Queen 2 \n", + "6 Me 1 \n", + "7 The Bachelorette 21 \n", + "8 Mastermind: To Think Like a Killer 1 \n", + "9 Melissa Etheridge: I'm Not Broken 1 \n", + "10 All American: Homecoming 3 \n", + "11 Supacell 1 \n", + "12 Star Wars: The Acolyte 1 \n", + "13 The Bear 3 \n", + "14 The Boys 4 \n", + "15 Presumed Innocent 1 \n", + "16 My Lady Jane 1 \n", + "17 House of the Dragon 2 \n", + "18 The Mole 2 \n", + "19 Dark Matter 1 \n", + "20 Star Wars: The Acolyte Jul 09 \n", + "21 The Boys 2019 Jul 11 \n", + "22 Supacell Jun 27 \n", + "23 The Bear Jun 26 \n", + "24 Sunny Jul 10 \n", + "25 House of the Dragon Jul 07 \n", + "26 My Lady Jane Jun 27 \n", + "27 Presumed Innocent Jul 10 \n", + "28 Sausage Party: Foodtopia Jul 11 \n", + "29 Dark Matter 2024 Jun 26 \n", + "30 Evil Jul 11 \n", + "31 Interview With the Vampire Jun 30 \n", + "32 Vikings: Valhalla Jul 11 \n", + "33 Land of Women Jul 10 \n", + "34 Vikings Valhalla Jul 11 \n", + "35 Land of Women Jul 10 \n", + "36 The Mole Jul 12 \n", + "37 Bridgerton Jun 13 \n", + "38 Your Honor Jul 07 \n", + "39 Mayor of Kingstown Jul 07 \n", + "40 The Serpent Queen Jul 12 \n", + "41 True Detective Jul 05 \n", + "42 Mirzapur Jul 05 \n", + "43 Hotel Cocaine Jul 07 \n", + "44 A Good Girl's Guide to Murder Jul 01 \n", + "45 Eric May 30 \n", + "46 Game of Thrones May 30 \n", + "47 Shōgun Apr 23 \n", + "48 Geek Girl May 30 \n", + "49 Dear Child May 30 \n", "\n", - " link \n", - "0 /tv/beef/s01 \n", - "1 /tv/dave/s03 \n", - "2 /tv/schmigadoon/s02 \n", - "3 /tv/pretty_baby_brooke_shields/s01 \n", - "4 /tv/tiny_beautiful_things/s01 \n", - "5 /tv/grease_rise_of_the_pink_ladies/s01 \n", - "6 /tv/jury_duty/s01 \n", - "7 /tv/the_crossover/s01 \n", - "8 /tv/transatlantic/s01 \n", - "9 /tv/race_to_survive_alaska/s01 \n", - "10 /tv/beef \n", - "11 /tv/the_night_agent \n", - "12 /tv/unstable \n", - "13 /tv/the_mandalorian \n", - "14 /tv/the_big_door_prize \n", - "15 /tv/class_of_07 \n", - "16 /tv/rabbit_hole \n", - "17 /tv/the_power \n", - "18 /tv/the_last_of_us \n", - "19 /tv/yellowjackets \n", - "20 /tv/succession \n", - "21 /tv/lucky_hank \n", - "22 /tv/sex_life \n", - "23 /tv/ted_lasso \n", - "24 /tv/wellmania \n", - "25 /tv/daisy_jones_and_the_six \n", - "26 /tv/shadow_and_bone \n", - "27 /tv/the_order \n", - "28 /tv/shrinking \n", - "29 /tv/swarm \n", - "30 /tv/the_last_kingdom \n", - "31 /tv/rain_dogs \n", - "32 /tv/extrapolations \n", - "33 /tv/war_sailor \n", - "34 /tv/you \n", - "35 /tv/she_hulk_attorney_at_law \n", - "36 /tv/you \n", - "37 /tv/she_hulk_attorney_at_law \n", - "38 /tv/breaking_bad \n", - "39 /tv/the_lord_of_the_rings_the_rings_of_power " + " link \n", + "0 /tv/sunny/s01 \n", + "1 /tv/vikings_valhalla/s03 \n", + "2 /tv/sunny/s01 \n", + "3 /tv/vikings_valhalla/s03 \n", + "4 /tv/sausage_party_foodtopia/s01 \n", + "5 /tv/the_serpent_queen/s02 \n", + "6 /tv/me/s01 \n", + "7 /tv/the_bachelorette/s21 \n", + "8 /tv/mastermind_to_think_like_a_killer/s01 \n", + "9 /tv/melissa_etheridge_im_not_broken/s01 \n", + "10 /tv/all_american_homecoming/s03 \n", + "11 /tv/supacell/s01 \n", + "12 /tv/star_wars_the_acolyte/s01 \n", + "13 /tv/the_bear/s03 \n", + "14 /tv/the_boys_2019/s04 \n", + "15 /tv/presumed_innocent/s01 \n", + "16 /tv/my_lady_jane/s01 \n", + "17 /tv/house_of_the_dragon/s02 \n", + "18 /tv/the_mole_2022/s02 \n", + "19 /tv/dark_matter_2024/s01 \n", + "20 /tv/star_wars_the_acolyte \n", + "21 /tv/the_boys_2019 \n", + "22 /tv/supacell \n", + "23 /tv/the_bear \n", + "24 /tv/sunny \n", + "25 /tv/house_of_the_dragon \n", + "26 /tv/my_lady_jane \n", + "27 /tv/presumed_innocent \n", + "28 /tv/sausage_party_foodtopia \n", + "29 /tv/dark_matter_2024 \n", + "30 /tv/evil \n", + "31 /tv/interview_with_the_vampire \n", + "32 /tv/vikings_valhalla \n", + "33 /tv/land_of_women \n", + "34 /tv/vikings_valhalla \n", + "35 /tv/land_of_women \n", + "36 /tv/the_mole_2022 \n", + "37 /tv/bridgerton \n", + "38 /tv/your_honor_2020 \n", + "39 /tv/mayor_of_kingstown \n", + "40 /tv/the_serpent_queen \n", + "41 /tv/true_detective \n", + "42 /tv/mirzapur \n", + "43 /tv/hotel_cocaine \n", + "44 /tv/a_good_girls_guide_to_murder \n", + "45 /tv/eric \n", + "46 /tv/game_of_thrones \n", + "47 /tv/shogun_2024 \n", + "48 /tv/geek_girl \n", + "49 /tv/dear_child " ] }, - "execution_count": 16, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -1013,7 +1232,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/docs/source/nested_objects.ipynb b/docs/source/nested_objects.ipynb index dc93bff..56cf8ec 100644 --- a/docs/source/nested_objects.ipynb +++ b/docs/source/nested_objects.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 24, "id": "0b4597b2-2a43-4491-8830-bf9f79428074", "metadata": { "nbsphinx": "hidden", @@ -22,7 +22,16 @@ "remove-cell" ] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" + ] + } + ], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", @@ -34,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 25, "id": "718c66a7-6186-4ed8-87e9-5ed28e3f209e", "metadata": { "tags": [] @@ -48,7 +57,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 26, "id": "9bc98f35-ea5f-4b74-a32e-a300a22c0c89", "metadata": { "tags": [] @@ -56,7 +65,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-3.5-turbo\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", ")" @@ -74,7 +83,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 27, "id": "f75990e6-5973-4618-9f15-f3b60a14bfa5", "metadata": { "tags": [] @@ -138,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 28, "id": "54a199a5-24b4-442c-8907-1449e437a880", "metadata": { "tags": [] @@ -152,7 +161,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 29, "id": "193e257b-df01-45ec-af77-076d2070533b", "metadata": { "tags": [] @@ -162,14 +171,14 @@ "data": { "text/plain": [ "{'information': [{'person_name': 'Alice Doe',\n", - " 'from_address': {'city': 'New York'},\n", - " 'to_address': {'city': 'Boston', 'state': 'MA'}},\n", + " 'from_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'},\n", + " 'to_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'}},\n", " {'person_name': 'Bob Smith',\n", - " 'from_address': {'city': 'Boston', 'state': 'MA'},\n", - " 'to_address': {'city': 'New York'}}]}" + " 'from_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'},\n", + " 'to_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'}}]}" ] }, - "execution_count": 6, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -182,7 +191,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 30, "id": "c8295f36-f986-4db2-97bc-ef2e6cdbcc87", "metadata": { "tags": [] @@ -192,20 +201,23 @@ "data": { "text/plain": [ "{'information': [{'person_name': 'Alice Doe',\n", - " 'from_address': {'city': 'New York'},\n", - " 'to_address': {'city': 'Boston'}},\n", + " 'from_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'},\n", + " 'to_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'}},\n", " {'person_name': 'Bob Smith',\n", - " 'from_address': {'city': 'New York'},\n", - " 'to_address': {'city': 'Boston'}},\n", - " {'person_name': 'Andrew', 'to_address': {'city': 'Boston'}},\n", - " {'person_name': 'Joana', 'to_address': {'city': 'Boston'}},\n", - " {'person_name': 'Paul', 'to_address': {'city': 'Boston'}},\n", + " 'from_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'},\n", + " 'to_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'}},\n", + " {'person_name': 'Andrew',\n", + " 'to_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'}},\n", + " {'person_name': 'Joana',\n", + " 'to_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'}},\n", + " {'person_name': 'Paul',\n", + " 'to_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'}},\n", " {'person_name': 'Betty',\n", - " 'from_address': {'city': 'Boston'},\n", - " 'to_address': {'city': 'New York'}}]}" + " 'from_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'},\n", + " 'to_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'}}]}" ] }, - "execution_count": 7, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -235,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 31, "id": "e528f20c-46d3-40b6-b1ba-11024002deb8", "metadata": { "tags": [] @@ -288,7 +300,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 32, "id": "23b81b06-118a-4ebe-9e20-5df1bf269ce3", "metadata": { "tags": [] @@ -300,7 +312,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 33, "id": "29219fae-41cb-4235-92fa-07b16ded2296", "metadata": { "tags": [] @@ -310,14 +322,16 @@ "data": { "text/plain": [ "{'information': [{'person_name': 'Alice Doe',\n", - " 'from_address': [{'city': 'New York'}],\n", - " 'to_address': [{'city': 'Boston'}]},\n", + " 'from_address': [{'city': 'New York', 'state': 'NY', 'country': 'USA'}],\n", + " 'to_address': [{'city': 'Boston', 'state': 'MA', 'country': 'USA'}]},\n", " {'person_name': 'Bob Smith',\n", - " 'from_address': [{'city': 'New York'}],\n", - " 'to_address': [{'city': 'Boston'}, {'city': 'LA'}]}]}" + " 'from_address': [{'city': 'New York', 'state': 'NY', 'country': 'USA'},\n", + " {'city': 'Boston', 'state': 'MA', 'country': 'USA'}],\n", + " 'to_address': [{'city': 'Boston', 'state': 'MA', 'country': 'USA'},\n", + " {'city': 'LA', 'state': 'CA', 'country': 'USA'}]}]}" ] }, - "execution_count": 10, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -345,7 +359,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/docs/source/objects.ipynb b/docs/source/objects.ipynb index 580840d..6a290de 100644 --- a/docs/source/objects.ipynb +++ b/docs/source/objects.ipynb @@ -54,7 +54,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-3.5-turbo\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", ")" @@ -194,6 +194,14 @@ "tags": [] }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/eugene/.pyenv/versions/3.9.6/envs/kor/lib/python3.9/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n", + " warn_deprecated(\n" + ] + }, { "data": { "text/plain": [ @@ -221,7 +229,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'personal_info': [{'first_name': 'Bob', 'last_name': 'Alice', 'age': ''}]}\n" + "{'personal_info': [{'first_name': 'Bob', 'last_name': 'Alice', 'age': ''}, {'first_name': 'Moana', 'last_name': 'Sunrise', 'age': '10'}]}\n" ] } ], @@ -254,7 +262,7 @@ { "data": { "text/plain": [ - "{'personal_info': [{'first_name': '', 'last_name': '', 'age': ''}]}" + "{'personal_info': []}" ] }, "execution_count": 8, @@ -325,7 +333,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 12, "id": "5c694d79-e72c-4712-b891-111bc0279032", "metadata": { "tags": [] @@ -334,11 +342,12 @@ { "data": { "text/plain": [ - "{'personal_info': [{'first_name': 'Bob', 'last_name': 'Alice', 'age': ''},\n", - " {'first_name': 'Moana', 'last_name': 'Sunrise', 'age': '10'}]}" + "{'personal_info': [{'first_name': 'Moana',\n", + " 'last_name': 'Sunrise',\n", + " 'age': '20'}]}" ] }, - "execution_count": 10, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -347,7 +356,7 @@ "chain = create_extraction_chain(llm, schema)\n", "chain.run(\n", " \"My name is Bob Alice and my phone number is (123)-444-9999. I found my true love one\"\n", - " \" on a blue sunday. Her number was (333)1232832. Her name was Moana Sunrise and she was 10 years old.\"\n", + " \" on a blue sunday. Her number was (333)1232832. Her name was Moana Sunrise and she was 20 years old.\"\n", ")[\"data\"]" ] }, @@ -361,7 +370,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 13, "id": "a2944e8c-4630-4b29-b505-b2ca6fceba01", "metadata": { "tags": [] @@ -419,7 +428,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/docs/source/prompt.ipynb b/docs/source/prompt.ipynb index fa27ed4..9041afb 100644 --- a/docs/source/prompt.ipynb +++ b/docs/source/prompt.ipynb @@ -56,7 +56,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-3.5-turbo\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", ")\n", "\n", @@ -195,7 +195,9 @@ "cell_type": "code", "execution_count": 7, "id": "86611975-41c8-41d4-9347-7e3f4ae5247f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "class CatType(TypeDescriptor):\n", @@ -277,7 +279,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/docs/source/schema_serialization.ipynb b/docs/source/schema_serialization.ipynb index 6a04dd1..dfc7acb 100644 --- a/docs/source/schema_serialization.ipynb +++ b/docs/source/schema_serialization.ipynb @@ -9,7 +9,7 @@ "\n", "A Kor schema can be serialized and deserialzed to JSON. This lets you store the schema outside of the code.\n", "\n", - "**ATTENTION** This only works with pydantic v1 at the moment." + "**ATTENTION** This only works with **pydantic 1** at the moment." ] }, { @@ -66,7 +66,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{\"id\": \"personal_info\", \"description\": \"Personal information about a given person.\", \"many\": true, \"attributes\": [{\"id\": \"first_name\", \"description\": \"The first name of the person\", \"many\": false, \"examples\": [[\"John Smith went to the store\", \"John\"]], \"$type\": \"Text\"}, {\"id\": \"last_name\", \"description\": \"The last name of the person\", \"many\": false, \"examples\": [[\"John Smith went to the store\", \"Smith\"]], \"$type\": \"Text\"}, {\"id\": \"age\", \"description\": \"The age of the person in years.\", \"many\": false, \"examples\": [[\"23 years old\", \"23\"], [\"I turned three on sunday\", \"3\"]], \"$type\": \"Number\"}], \"examples\": [[\"John Smith was 23 years old. He was very tall. He knew Jane Doe. She was 5 years old.\", [{\"first_name\": \"John\", \"last_name\": \"Smith\", \"age\": 23}, {\"first_name\": \"Jane\", \"last_name\": \"Doe\", \"age\": 5}]]]}\n" + "{\"id\":\"personal_info\",\"description\":\"Personal information about a given person.\",\"many\":true,\"attributes\":[{\"id\":\"first_name\",\"description\":\"The first name of the person\",\"many\":false,\"examples\":[[\"John Smith went to the store\",\"John\"]]},{\"id\":\"last_name\",\"description\":\"The last name of the person\",\"many\":false,\"examples\":[[\"John Smith went to the store\",\"Smith\"]]},{\"id\":\"age\",\"description\":\"The age of the person in years.\",\"many\":false,\"examples\":[[\"23 years old\",23],[\"I turned three on sunday\",3]]}],\"examples\":[[\"John Smith was 23 years old. He was very tall. He knew Jane Doe. She was 5 years old.\",[{\"first_name\":\"John\",\"last_name\":\"Smith\",\"age\":23},{\"first_name\":\"Jane\",\"last_name\":\"Doe\",\"age\":5}]]]}\n" ] } ], @@ -178,21 +178,40 @@ "To deserialize a schema from JSON simply call the `parse_raw()` method." ] }, + { + "cell_type": "markdown", + "id": "9e48f3c7-ca54-44cf-b7e3-cd8367dd5825", + "metadata": {}, + "source": [ + "Deserialization only works with pydantic 1" + ] + }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 19, "id": "6088c98a", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "De-serialization only works with pydantic 1!\n" + ] + } + ], "source": [ - "schema = Object.parse_raw(json)" + "try:\n", + " schema = Object.parse_raw(json)\n", + "except NotImplementedError:\n", + " print('De-serialization only works with pydantic 1!')" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "id": "718c66a7-6186-4ed8-87e9-5ed28e3f209e", "metadata": { "tags": [] @@ -205,7 +224,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 11, "id": "9bc98f35-ea5f-4b74-a32e-a300a22c0c89", "metadata": { "tags": [] @@ -213,7 +232,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-3.5-turbo\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", " model_kwargs={\"frequency_penalty\": 0, \"presence_penalty\": 0, \"top_p\": 1.0},\n", @@ -222,7 +241,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 12, "id": "54a199a5-24b4-442c-8907-1449e437a880", "metadata": { "tags": [] @@ -234,19 +253,27 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 13, "id": "193e257b-df01-45ec-af77-076d2070533b", "metadata": { "tags": [] }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/eugene/.pyenv/versions/3.9.6/envs/kor/lib/python3.9/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n", + " warn_deprecated(\n" + ] + }, { "data": { "text/plain": [ "{'personal_info': [{'first_name': 'Eugene', 'last_name': '', 'age': '18'}]}" ] }, - "execution_count": 9, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -257,7 +284,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 15, "id": "c8295f36-f986-4db2-97bc-ef2e6cdbcc87", "metadata": { "tags": [] @@ -267,7 +294,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'personal_info': [{'first_name': 'Bob', 'last_name': 'Alice', 'age': ''}]}\n" + "{'personal_info': [{'first_name': 'Bob', 'last_name': 'Alice', 'age': ''}, {'first_name': 'Moana', 'last_name': 'Sunrise', 'age': '20'}]}\n" ] } ], @@ -276,7 +303,7 @@ "print(\n", " chain.run(\n", " \"My name is Bob Alice and my phone number is (123)-444-9999. I found my true love one\"\n", - " \" on a blue sunday. Her number was (333)1232832. Her name was Moana Sunrise and she was 10 years old.\"\n", + " \" on a blue sunday. Her number was (333)1232832. Her name was Moana Sunrise and she was 20 years old.\"\n", " )[\"data\"]\n", ")" ] @@ -298,7 +325,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/docs/source/tutorial.ipynb b/docs/source/tutorial.ipynb index fa5ff27..86611d8 100644 --- a/docs/source/tutorial.ipynb +++ b/docs/source/tutorial.ipynb @@ -136,7 +136,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-3.5-turbo\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", ")" @@ -174,6 +174,14 @@ "tags": [] }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/eugene/.pyenv/versions/3.9.6/envs/kor/lib/python3.9/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n", + " warn_deprecated(\n" + ] + }, { "data": { "text/plain": [ @@ -386,7 +394,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/docs/source/type_descriptors.ipynb b/docs/source/type_descriptors.ipynb index 9c8dbd4..b005ab2 100644 --- a/docs/source/type_descriptors.ipynb +++ b/docs/source/type_descriptors.ipynb @@ -338,7 +338,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/docs/source/untyped_objects.ipynb b/docs/source/untyped_objects.ipynb index c036798..e8f8cb1 100644 --- a/docs/source/untyped_objects.ipynb +++ b/docs/source/untyped_objects.ipynb @@ -54,7 +54,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-3.5-turbo\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", ")" ] @@ -107,6 +107,14 @@ "tags": [] }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/eugene/.pyenv/versions/3.9.6/envs/kor/lib/python3.9/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n", + " warn_deprecated(\n" + ] + }, { "data": { "text/plain": [ @@ -116,7 +124,7 @@ " {'person_name': 'Bob Smith',\n", " 'from_address': {'city': 'New York'},\n", " 'to_address': {'city': 'Boston'}},\n", - " {'person_name': 'Andrew', 'to_address': {'city': 'Boston'}, 'age': 12},\n", + " {'person_name': 'Andrew', 'to_address': {'city': 'Boston'}},\n", " {'person_name': 'Joana', 'to_address': {'city': 'Boston'}},\n", " {'person_name': 'Paul', 'to_address': {'city': 'Boston'}},\n", " {'person_name': 'Betty',\n", @@ -189,7 +197,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.9.6" } }, "nbformat": 4,