diff --git a/docs/source/apis.ipynb b/docs/source/apis.ipynb index 79990c9..9fa8218 100644 --- a/docs/source/apis.ipynb +++ b/docs/source/apis.ipynb @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "id": "0b4597b2-2a43-4491-8830-bf9f79428074", "metadata": { "nbsphinx": "hidden", @@ -23,16 +23,7 @@ "remove-cell" ] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" - ] - } - ], + "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", @@ -44,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 2, "id": "c719e4fc-3ccf-4633-a787-b2fe0d1eac65", "metadata": { "tags": [] @@ -57,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 3, "id": "f1313c02-d415-4ce6-bff0-3df537cc06c2", "metadata": { "tags": [] @@ -65,7 +56,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-4o-mini\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", ")" @@ -89,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 4, "id": "f61c94db-c05d-43ba-9ffc-b58552c715c3", "metadata": { "tags": [] @@ -146,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 5, "id": "ff9ad27f-7a81-4123-8d0b-1e14802df67e", "metadata": { "tags": [] @@ -166,7 +157,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 6, "id": "760baa5f-9368-4b5a-abc0-6ac65c34b7a7", "metadata": { "tags": [] @@ -178,7 +169,7 @@ "{'player': {'action': 'stop'}}" ] }, - "execution_count": 18, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -189,7 +180,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 7, "id": "462303c0-e83a-4e39-86cd-cab6875b40ef", "metadata": { "tags": [] @@ -201,7 +192,7 @@ "{'player': {'action': 'play'}}" ] }, - "execution_count": 19, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -212,7 +203,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 8, "id": "02c7f1e5-1c8d-4e9f-82e6-c37a41d6de14", "metadata": { "tags": [] @@ -221,10 +212,10 @@ { "data": { "text/plain": [ - "{'player': {'album': ['lion king soundtrack'], 'action': 'play'}}" + "{'player': {'album': ['the lion king soundtrack'], 'action': 'play'}}" ] }, - "execution_count": 20, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -235,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 9, "id": "7a6d918c-53fe-426b-b37e-eec2abb8a704", "metadata": { "tags": [] @@ -246,12 +237,12 @@ "text/plain": [ "{'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", + " 'raw': '{\"player\": {\"artist\": [\"paul simon\", \"led zeppelin\", \"the doors\"], \"action\": \"play\"}}',\n", " 'errors': [],\n", " 'validated_data': {}}" ] }, - "execution_count": 21, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -262,7 +253,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 10, "id": "b18acf0a-d99e-48de-ace5-fb01bded5a41", "metadata": { "tags": [] @@ -274,7 +265,7 @@ "{'player': {'action': 'previous'}}" ] }, - "execution_count": 22, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -295,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 11, "id": "c50b080b-7179-4bbe-b234-83ce59e2d215", "metadata": { "tags": [] @@ -342,7 +333,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 12, "id": "404e4f1a-d316-41f2-ab94-040e22001fc4", "metadata": { "tags": [] @@ -354,7 +345,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 13, "id": "73c31ace-32dd-4a33-ae39-475db6934f6d", "metadata": { "tags": [] @@ -368,7 +359,7 @@ " 'price_range': {'price_max': '100'}}}" ] }, - "execution_count": 25, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -379,7 +370,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 14, "id": "78e3b3af-bfa8-4503-854a-b83a7f8f49e6", "metadata": { "tags": [] @@ -390,10 +381,10 @@ "text/plain": [ "{'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": 26, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -420,7 +411,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 15, "id": "2b0bcf09-a3ae-4a8a-9ce3-f86834ce6ca2", "metadata": { "tags": [] @@ -583,7 +574,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 16, "id": "7b389d20-ae6b-4764-9209-3cd3c2f0a715", "metadata": { "tags": [] @@ -603,7 +594,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 17, "id": "b203ac4a-4f9f-45c6-a509-39b9a6cfd98f", "metadata": { "tags": [] @@ -615,7 +606,7 @@ "{}" ] }, - "execution_count": 29, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -630,7 +621,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 18, "id": "398377bf-5d30-4b4c-b637-e9af969d16a4", "metadata": { "tags": [] @@ -639,10 +630,15 @@ { "data": { "text/plain": [ - "{}" + "{'search_for_companies': {'geography_name': 'india',\n", + " 'attribute_filter': [{'attribute': 'market cap',\n", + " 'op': '>',\n", + " 'value': '1000000'},\n", + " {'attribute': 'employees', 'op': 'in', 'value': ['20', '50']}],\n", + " 'attribute_selection': ['revenue', 'eps']}}" ] }, - "execution_count": 30, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -657,7 +653,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 19, "id": "2a620246-4c85-4256-8f58-0acbcc9455a3", "metadata": { "tags": [] @@ -671,7 +667,7 @@ " 'value': ['red', 'blue']}]}}" ] }, - "execution_count": 31, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -683,7 +679,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 20, "id": "4745517e-507e-4d1a-97e0-d143fa34cea2", "metadata": { "tags": [] @@ -698,7 +694,7 @@ " 'attribute': 'number of employees'}}}" ] }, - "execution_count": 32, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -710,7 +706,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 21, "id": "b206407f-57e0-4212-8e75-970cb49b52e5", "metadata": { "tags": [] @@ -719,10 +715,15 @@ { "data": { "text/plain": [ - "{}" + "{'search_for_companies': {'geography_name': 'india',\n", + " 'attribute_filter': [{'attribute': 'market cap',\n", + " 'op': '>',\n", + " 'value': '1 million'},\n", + " {'attribute': 'buildings', 'op': 'in', 'value': ['red', 'blue']}],\n", + " 'attribute_selection': ['revenue', 'eps']}}" ] }, - "execution_count": 33, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -737,15 +738,111 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "a1025f99-eb0a-4d96-923e-35f36e4ac6b2", "metadata": { "tags": [] }, - "outputs": [], + "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" + ] + } + ], "source": [ "print(chain.get_prompts()[0].format_prompt(\"[user_input]\").to_string())" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cff14a3d-046e-45b8-acce-a59b5f2986cb", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/docs/source/document_extraction.ipynb b/docs/source/document_extraction.ipynb index 3a3cbb8..b329248 100644 --- a/docs/source/document_extraction.ipynb +++ b/docs/source/document_extraction.ipynb @@ -80,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 2, "id": "d93b3de7-9b81-456e-acff-4b0df9755c14", "metadata": { "nbsphinx": "hidden", @@ -110,7 +110,7 @@ "\n", "Instantiate an LLM. \n", "\n", - "Try experimenting with the cheaper davinci models or with gpt-4o-mini before trying the more expensive davinci-003 or gpt 4.\n", + "Try experimenting with the cheaper davinci models or with gpt-4o before trying the more expensive davinci-003 or gpt 4.\n", "\n", "In some cases, providing a better prompt (with more examples) can help make up for using a smaller model." ] @@ -132,15 +132,14 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 8, "id": "fab20ada-6443-4799-b6e8-faf16a2fb585", "metadata": { "tags": [] }, "outputs": [], "source": [ - "# Using gpt-4o-mini which is pretty cheap, but has worse quality\n", - "llm = ChatOpenAI(temperature=0)" + "llm = ChatOpenAI(temperature=0, model='gpt-4o')" ] }, { @@ -153,7 +152,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 9, "id": "981938c5-f438-49a0-b511-329d31073a56", "metadata": { "tags": [] @@ -203,7 +202,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 10, "id": "ff57507d-d789-4ae3-8763-0465e8b27686", "metadata": { "tags": [] @@ -231,7 +230,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 11, "id": "b5bd49b1-0b51-40ff-b34b-3ad7f90423b6", "metadata": { "tags": [] @@ -275,7 +274,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 12, "id": "396a16b7-bc45-4035-9848-f995cddbba2f", "metadata": { "tags": [] @@ -297,7 +296,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 13, "id": "22d3229a-aa6f-4586-a527-6f7835800740", "metadata": { "tags": [] @@ -317,7 +316,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 14, "id": "814e4151-f7d7-412d-beab-58ed190b7dd3", "metadata": { "tags": [] @@ -329,7 +328,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 15, "id": "e663f031-7a61-4a27-b925-1c9a6f365bcc", "metadata": { "tags": [] @@ -339,63 +338,75 @@ "name": "stdout", "output_type": "stream", "text": [ - "Latest Episode: Jul 11](/tv/vikings_valhalla)\n", + "Latest Episode: Jul 17](/tv/presumed_innocent)\n", "\n", - "Watch the trailer for Land of Women\n", + "Watch the trailer for Sausage Party: Foodtopia\n", "\n", - "[89%\n", + "[52%\n", "\n", - " 35%\n", + " 52%\n", "\n", - " Land of Women\n", + " Sausage Party: Foodtopia\n", "\n", - " Latest Episode: Jul 10](/tv/land_of_women)\n", + " Latest Episode: Jul 11](/tv/sausage_party_foodtopia)\n", "\n", - "[100%\n", + "Watch the trailer for Exploding Kittens\n", "\n", - " 68%\n", + "[69%\n", "\n", - " The Mole\n", + " 80%\n", "\n", - " Latest Episode: Jul 12](/tv/the_mole_2022)\n", + " Exploding Kittens\n", "\n", - "Watch the trailer for Bridgerton\n", + " Latest Episode: Jul 12](/tv/exploding_kittens)\n", "\n", - "[84%\n", + "Watch the trailer for Kite Man: Hell Yeah!\n", "\n", - " 73%\n", + "[86%\n", "\n", - " Bridgerton\n", + " 100%\n", "\n", - " Latest Episode: Jun 13](/tv/bridgerton)\n", + " Kite Man: Hell Yeah!\n", "\n", - "Watch the trailer for Your Honor\n", + " Latest Episode: Jul 18](/tv/kite_man_hell_yeah)\n", "\n", - "[50%\n", + "Watch the trailer for Vikings: Valhalla\n", "\n", - " 68%\n", + "[96%\n", "\n", - " Your Honor](/tv/your_honor_2020)\n", + " 60%\n", "\n", - "Watch the trailer for Mayor of Kingstown\n", + " Vikings: Valhalla\n", "\n", - "[51%\n", + " Latest Episode: Jul 11](/tv/vikings_valhalla)\n", "\n", - " 89%\n", + "Watch the trailer for Marvel's Hit-Monkey\n", "\n", - " Mayor of Kingstown\n", + "[82%\n", "\n", - " Latest Episode: Jul 07](/tv/mayor_of_kingstown)\n", + " 93%\n", "\n", - "Watch the trailer for The Serpent Queen\n", + " Marvel's Hit-Monkey\n", "\n", - "[100%\n", + " Latest Episode: Jul 15](/tv/marvels_hit_monkey)\n", "\n", - " 84%\n", + "Watch the trailer for Snowpiercer\n", "\n", - " The Serpent Queen\n", + "[75%\n", + "\n", + " 69%\n", + "\n", + " Snowpiercer](/tv/snowpiercer)\n", + "\n", + "Watch the trailer for Shōgun\n", + "\n", + "[99%\n", "\n", - " Latest Episode: Jul 12](/tv/the_serpent_queen)\n", + " 92%\n", + "\n", + " Shōgun\n", + "\n", + " Latest Episode: Apr 23](/tv/shogun_2024)\n", "\n", "Watch the trailer for True Detective\n", "\n", @@ -405,73 +416,83 @@ "\n", " True Detective](/tv/true_detective)\n", "\n", - "[67%\n", + "Watch the trailer for Land of Women\n", + "\n", + "[89%\n", + "\n", + " 36%\n", "\n", - " Mirzapur\n", + " Land of Women\n", "\n", - " Latest Episode: Jul 05](/tv/mirzapur)\n", + " Latest Episode: Jul 17](/tv/land_of_women)\n", "\n", - "Watch the trailer for Hotel Cocaine\n", + "Watch the trailer for Emperor of Ocean Park\n", "\n", - "[70%\n", + "[50%\n", "\n", - " Hotel Cocaine\n", + " 75%\n", "\n", - " Latest Episode: Jul 07](/tv/hotel_cocaine)\n", + " Emperor of Ocean Park\n", + "\n", + " Latest Episode: Jul 14](/tv/emperor_of_ocean_park)\n", "\n", "[86%\n", "\n", - " 69%\n", + " 71%\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", + "[75%\n", + "\n", + " Desperate Lies\n", "\n", - "[72%\n", + " Latest Episode: Jul 05](/tv/desperate_lies)\n", "\n", - " 58%\n", + "Watch the trailer for Simone Biles: Rising\n", "\n", - " Eric\n", + "[100%\n", "\n", - " Latest Episode: May 30](/tv/eric)\n", + " Simone Biles: Rising\n", "\n", - "Watch the trailer for Game of Thrones\n", + " Latest Episode: Jul 17](/tv/simone_biles_rising)\n", "\n", - "[89%\n", + "Watch the trailer for Fool Me Once\n", "\n", - " 85%\n", + "[69%\n", "\n", - " Game of Thrones](/tv/game_of_thrones)\n", + " 45%\n", "\n", - "Watch the trailer for Shōgun\n", + " Fool Me Once](/tv/fool_me_once)\n", "\n", - "[99%\n", + "Watch the trailer for Dear Child\n", "\n", - " 91%\n", + "[100%\n", "\n", - " Shōgun\n", + " 84%\n", "\n", - " Latest Episode: Apr 23](/tv/shogun_2024)\n", + " Dear Child](/tv/dear_child)\n", "\n", - "Watch the trailer for Geek Girl\n", + "Watch the trailer for Dark Matter\n", "\n", - "[100%\n", + "[82%\n", "\n", - " 75%\n", + " 82%\n", "\n", - " Geek Girl\n", + " Dark Matter\n", "\n", - " Latest Episode: May 30](/tv/geek_girl)\n", + " Latest Episode: Jun 26](/tv/dark_matter_2024)\n", "\n", - "Watch the trailer for Dear Child\n", + "Watch the trailer for The Serpent Queen\n", "\n", "[100%\n", "\n", - " 84%\n", + " 92%\n", "\n", - " Dear Child](/tv/dear_child)\n", + " The Serpent Queen\n", + "\n", + " Latest Episode: Jul 19](/tv/the_serpent_queen)\n", "\n", " Load more\n", "\n", @@ -531,7 +552,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 16, "id": "ec72cb5b-1fcb-4381-85e8-f060ea1f0077", "metadata": { "tags": [] @@ -543,7 +564,7 @@ "4" ] }, - "execution_count": 22, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -562,7 +583,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 17, "id": "1d17ebaa-8222-48df-82d9-42173a60f5f7", "metadata": { "tags": [] @@ -574,29 +595,21 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 18, "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: 6342\n", - "Prompt Tokens: 5390\n", - "Completion Tokens: 952\n", + "Total Tokens: 6344\n", + "Prompt Tokens: 5448\n", + "Completion Tokens: 896\n", "Successful Requests: 4\n", - "Total Cost (USD): $0.009989000000000001\n" + "Total Cost (USD): $0.0\n" ] } ], @@ -614,7 +627,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 19, "id": "d00f86ed-48c3-46c3-8d37-49de50817d93", "metadata": { "tags": [] @@ -630,7 +643,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 20, "id": "89e35b77-aac4-4a32-9515-9ebe9bfef046", "metadata": { "tags": [] @@ -639,10 +652,10 @@ { "data": { "text/plain": [ - "50" + "47" ] }, - "execution_count": 26, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -661,7 +674,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 21, "id": "75f3e35e-d6a9-4c0d-a5c3-a509eaf7d6ec", "metadata": { "tags": [] @@ -698,182 +711,190 @@ " \n", " \n", " 0\n", - " Sunny\n", - " 1\n", + " Twisters\n", " \n", " \n", - " /tv/sunny/s01\n", + " July 2024\n", + " /m/twisters\n", " \n", " \n", " 1\n", - " Vikings: Valhalla\n", - " 3\n", + " Longlegs\n", " \n", " \n", - " /tv/vikings_valhalla/s03\n", + " July 2024\n", + " /m/longlegs\n", " \n", " \n", " 2\n", - " Sunny\n", - " 1\n", + " National Anthem\n", " \n", " \n", - " /tv/sunny/s01\n", + " July 2024\n", + " /m/national_anthem\n", " \n", " \n", " 3\n", - " Vikings: Valhalla\n", - " 3\n", + " Cobra Kai\n", + " 6\n", " \n", - " \n", - " /tv/vikings_valhalla/s03\n", + " July 2024\n", + " /tv/cobra_kai/s06\n", " \n", " \n", " 4\n", - " Sausage Party: Foodtopia\n", - " 1\n", + " Cobra Kai\n", + " 6\n", " \n", " \n", - " /tv/sausage_party_foodtopia/s01\n", + " /tv/cobra_kai/s06\n", " \n", " \n", " 5\n", - " The Serpent Queen\n", - " 2\n", + " Kite Man: Hell Yeah!\n", + " 1\n", " \n", " \n", - " /tv/the_serpent_queen/s02\n", + " /tv/kite_man_hell_yeah/s01\n", " \n", " \n", " 6\n", - " Me\n", + " Simone Biles: Rising\n", " 1\n", " \n", " \n", - " /tv/me/s01\n", + " /tv/simone_biles_rising/s01\n", " \n", " \n", " 7\n", - " The Bachelorette\n", - " 21\n", + " Lady in the Lake\n", + " 1\n", " \n", " \n", - " /tv/the_bachelorette/s21\n", + " /tv/lady_in_the_lake/s01\n", " \n", " \n", " 8\n", - " Mastermind: To Think Like a Killer\n", - " 1\n", + " Marvel's Hit-Monkey\n", + " 2\n", " \n", " \n", - " /tv/mastermind_to_think_like_a_killer/s01\n", + " /tv/marvels_hit_monkey/s02\n", " \n", " \n", " 9\n", - " Melissa Etheridge: I'm Not Broken\n", + " Those About to Die\n", " 1\n", " \n", " \n", - " /tv/melissa_etheridge_im_not_broken/s01\n", + " /tv/those_about_to_die/s01\n", " \n", " \n", " 10\n", - " All American: Homecoming\n", - " 3\n", + " Emperor of Ocean Park\n", + " 1\n", " \n", " \n", - " /tv/all_american_homecoming/s03\n", + " /tv/emperor_of_ocean_park/s01\n", " \n", " \n", " 11\n", - " Supacell\n", + " Mafia Spies\n", " 1\n", " \n", " \n", - " /tv/supacell/s01\n", + " /tv/mafia_spies/s01\n", " \n", " \n", " 12\n", - " Star Wars: The Acolyte\n", - " 1\n", + " The Ark\n", + " 2\n", " \n", " \n", - " /tv/star_wars_the_acolyte/s01\n", + " /tv/the_ark/s02\n", " \n", " \n", " 13\n", - " The Bear\n", - " 3\n", + " Unprisoned\n", + " 2\n", " \n", " \n", - " /tv/the_bear/s03\n", + " /tv/unprisoned/s02\n", " \n", " \n", " 14\n", - " The Boys\n", - " 4\n", + " Star Wars: The Acolyte\n", + " 1\n", " \n", " \n", - " /tv/the_boys_2019/s04\n", + " /tv/star_wars_the_acolyte/s01\n", " \n", " \n", " 15\n", - " Presumed Innocent\n", - " 1\n", + " The Boys\n", + " 4\n", " \n", " \n", - " /tv/presumed_innocent/s01\n", + " /tv/the_boys_2019/s04\n", " \n", " \n", " 16\n", - " My Lady Jane\n", + " Supacell\n", " 1\n", " \n", " \n", - " /tv/my_lady_jane/s01\n", + " /tv/supacell/s01\n", " \n", " \n", " 17\n", - " House of the Dragon\n", - " 2\n", + " The Bear\n", + " 3\n", " \n", " \n", - " /tv/house_of_the_dragon/s02\n", + " /tv/the_bear/s03\n", " \n", " \n", " 18\n", - " The Mole\n", - " 2\n", + " Presumed Innocent\n", + " 1\n", " \n", " \n", - " /tv/the_mole_2022/s02\n", + " /tv/presumed_innocent/s01\n", " \n", " \n", " 19\n", - " Dark Matter\n", + " Sunny\n", " 1\n", " \n", " \n", - " /tv/dark_matter_2024/s01\n", + " /tv/sunny/s01\n", " \n", " \n", " 20\n", + " Cobra Kai\n", + " 6\n", + " \n", + " Jul 18\n", + " https://editorial.rottentomatoes.com/article/c...\n", + " \n", + " \n", + " 21\n", " Star Wars: The Acolyte\n", " \n", " \n", - " Jul 09\n", + " Jul 16\n", " /tv/star_wars_the_acolyte\n", " \n", " \n", - " 21\n", + " 22\n", " The Boys\n", " \n", - " 2019\n", - " Jul 11\n", + " \n", + " Jul 18\n", " /tv/the_boys_2019\n", " \n", " \n", - " 22\n", + " 23\n", " Supacell\n", " \n", " \n", @@ -881,332 +902,294 @@ " /tv/supacell\n", " \n", " \n", - " 23\n", - " The Bear\n", - " \n", - " \n", - " Jun 26\n", - " /tv/the_bear\n", - " \n", - " \n", " 24\n", " Sunny\n", " \n", " \n", - " Jul 10\n", + " Jul 17\n", " /tv/sunny\n", " \n", " \n", " 25\n", - " House of the Dragon\n", + " Those About to Die\n", " \n", " \n", - " Jul 07\n", - " /tv/house_of_the_dragon\n", + " Jul 19\n", + " /tv/those_about_to_die\n", " \n", " \n", " 26\n", - " My Lady Jane\n", + " Cobra Kai\n", " \n", " \n", - " Jun 27\n", - " /tv/my_lady_jane\n", + " Jul 18\n", + " /tv/cobra_kai\n", " \n", " \n", " 27\n", - " Presumed Innocent\n", + " The Bear\n", " \n", " \n", - " Jul 10\n", - " /tv/presumed_innocent\n", + " Jun 26\n", + " /tv/the_bear\n", " \n", " \n", " 28\n", - " Sausage Party: Foodtopia\n", + " House of the Dragon\n", " \n", " \n", - " Jul 11\n", - " /tv/sausage_party_foodtopia\n", + " Jul 14\n", + " /tv/house_of_the_dragon\n", " \n", " \n", " 29\n", - " Dark Matter\n", + " Lady in the Lake\n", " \n", - " 2024\n", - " Jun 26\n", - " /tv/dark_matter_2024\n", + " \n", + " Jul 19\n", + " /tv/lady_in_the_lake\n", " \n", " \n", " 30\n", - " Evil\n", + " My Lady Jane\n", " \n", " \n", - " Jul 11\n", - " /tv/evil\n", + " Jun 27\n", + " /tv/my_lady_jane\n", " \n", " \n", " 31\n", - " Interview With the Vampire\n", + " Presumed Innocent\n", " \n", " \n", - " Jun 30\n", - " /tv/interview_with_the_vampire\n", + " Jul 17\n", + " /tv/presumed_innocent\n", " \n", " \n", " 32\n", - " Vikings: Valhalla\n", + " Sausage Party: Foodtopia\n", " \n", " \n", " Jul 11\n", - " /tv/vikings_valhalla\n", + " /tv/sausage_party_foodtopia\n", " \n", " \n", " 33\n", - " Land of Women\n", + " Presumed Innocent\n", " \n", " \n", - " Jul 10\n", - " /tv/land_of_women\n", + " Jul 17\n", + " /tv/presumed_innocent\n", " \n", " \n", " 34\n", - " Vikings Valhalla\n", + " Sausage Party: Foodtopia\n", " \n", " \n", " Jul 11\n", - " /tv/vikings_valhalla\n", + " /tv/sausage_party_foodtopia\n", " \n", " \n", " 35\n", - " Land of Women\n", + " Exploding Kittens\n", " \n", " \n", - " Jul 10\n", - " /tv/land_of_women\n", + " Jul 12\n", + " /tv/exploding_kittens\n", " \n", " \n", " 36\n", - " The Mole\n", + " Kite Man: Hell Yeah!\n", " \n", " \n", - " Jul 12\n", - " /tv/the_mole_2022\n", + " Jul 18\n", + " /tv/kite_man_hell_yeah\n", " \n", " \n", " 37\n", - " Bridgerton\n", + " Vikings: Valhalla\n", " \n", " \n", - " Jun 13\n", - " /tv/bridgerton\n", + " Jul 11\n", + " /tv/vikings_valhalla\n", " \n", " \n", " 38\n", - " Your Honor\n", + " Marvel's Hit-Monkey\n", " \n", " \n", - " Jul 07\n", - " /tv/your_honor_2020\n", + " Jul 15\n", + " /tv/marvels_hit_monkey\n", " \n", " \n", " 39\n", - " Mayor of Kingstown\n", + " Shōgun\n", " \n", " \n", - " Jul 07\n", - " /tv/mayor_of_kingstown\n", + " Apr 23\n", + " /tv/shogun_2024\n", " \n", " \n", " 40\n", - " The Serpent Queen\n", + " Land of Women\n", " \n", " \n", - " Jul 12\n", - " /tv/the_serpent_queen\n", + " Jul 17\n", + " /tv/land_of_women\n", " \n", " \n", " 41\n", - " True Detective\n", + " Emperor of Ocean Park\n", " \n", " \n", - " Jul 05\n", - " /tv/true_detective\n", + " Jul 14\n", + " /tv/emperor_of_ocean_park\n", " \n", " \n", " 42\n", - " Mirzapur\n", + " A Good Girl's Guide to Murder\n", " \n", " \n", - " Jul 05\n", - " /tv/mirzapur\n", + " Jul 01\n", + " /tv/a_good_girls_guide_to_murder\n", " \n", " \n", " 43\n", - " Hotel Cocaine\n", + " Desperate Lies\n", " \n", " \n", - " Jul 07\n", - " /tv/hotel_cocaine\n", + " Jul 05\n", + " /tv/desperate_lies\n", " \n", " \n", " 44\n", - " A Good Girl's Guide to Murder\n", + " Simone Biles: Rising\n", " \n", " \n", - " Jul 01\n", - " /tv/a_good_girls_guide_to_murder\n", + " Jul 17\n", + " /tv/simone_biles_rising\n", " \n", " \n", " 45\n", - " Eric\n", + " Dark Matter\n", " \n", " \n", - " May 30\n", - " /tv/eric\n", + " Jun 26\n", + " /tv/dark_matter_2024\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", + " The Serpent Queen\n", " \n", " \n", - " May 30\n", - " /tv/dear_child\n", + " Jul 19\n", + " /tv/the_serpent_queen\n", " \n", " \n", "\n", "" ], "text/plain": [ - " 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", + " name season year latest_episode \\\n", + "0 Twisters July 2024 \n", + "1 Longlegs July 2024 \n", + "2 National Anthem July 2024 \n", + "3 Cobra Kai 6 July 2024 \n", + "4 Cobra Kai 6 \n", + "5 Kite Man: Hell Yeah! 1 \n", + "6 Simone Biles: Rising 1 \n", + "7 Lady in the Lake 1 \n", + "8 Marvel's Hit-Monkey 2 \n", + "9 Those About to Die 1 \n", + "10 Emperor of Ocean Park 1 \n", + "11 Mafia Spies 1 \n", + "12 The Ark 2 \n", + "13 Unprisoned 2 \n", + "14 Star Wars: The Acolyte 1 \n", + "15 The Boys 4 \n", + "16 Supacell 1 \n", + "17 The Bear 3 \n", + "18 Presumed Innocent 1 \n", + "19 Sunny 1 \n", + "20 Cobra Kai 6 Jul 18 \n", + "21 Star Wars: The Acolyte Jul 16 \n", + "22 The Boys Jul 18 \n", + "23 Supacell Jun 27 \n", + "24 Sunny Jul 17 \n", + "25 Those About to Die Jul 19 \n", + "26 Cobra Kai Jul 18 \n", + "27 The Bear Jun 26 \n", + "28 House of the Dragon Jul 14 \n", + "29 Lady in the Lake Jul 19 \n", + "30 My Lady Jane Jun 27 \n", + "31 Presumed Innocent Jul 17 \n", + "32 Sausage Party: Foodtopia Jul 11 \n", + "33 Presumed Innocent Jul 17 \n", + "34 Sausage Party: Foodtopia Jul 11 \n", + "35 Exploding Kittens Jul 12 \n", + "36 Kite Man: Hell Yeah! Jul 18 \n", + "37 Vikings: Valhalla Jul 11 \n", + "38 Marvel's Hit-Monkey Jul 15 \n", + "39 Shōgun Apr 23 \n", + "40 Land of Women Jul 17 \n", + "41 Emperor of Ocean Park Jul 14 \n", + "42 A Good Girl's Guide to Murder Jul 01 \n", + "43 Desperate Lies Jul 05 \n", + "44 Simone Biles: Rising Jul 17 \n", + "45 Dark Matter Jun 26 \n", + "46 The Serpent Queen Jul 19 \n", "\n", - " 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 " + " link \n", + "0 /m/twisters \n", + "1 /m/longlegs \n", + "2 /m/national_anthem \n", + "3 /tv/cobra_kai/s06 \n", + "4 /tv/cobra_kai/s06 \n", + "5 /tv/kite_man_hell_yeah/s01 \n", + "6 /tv/simone_biles_rising/s01 \n", + "7 /tv/lady_in_the_lake/s01 \n", + "8 /tv/marvels_hit_monkey/s02 \n", + "9 /tv/those_about_to_die/s01 \n", + "10 /tv/emperor_of_ocean_park/s01 \n", + "11 /tv/mafia_spies/s01 \n", + "12 /tv/the_ark/s02 \n", + "13 /tv/unprisoned/s02 \n", + "14 /tv/star_wars_the_acolyte/s01 \n", + "15 /tv/the_boys_2019/s04 \n", + "16 /tv/supacell/s01 \n", + "17 /tv/the_bear/s03 \n", + "18 /tv/presumed_innocent/s01 \n", + "19 /tv/sunny/s01 \n", + "20 https://editorial.rottentomatoes.com/article/c... \n", + "21 /tv/star_wars_the_acolyte \n", + "22 /tv/the_boys_2019 \n", + "23 /tv/supacell \n", + "24 /tv/sunny \n", + "25 /tv/those_about_to_die \n", + "26 /tv/cobra_kai \n", + "27 /tv/the_bear \n", + "28 /tv/house_of_the_dragon \n", + "29 /tv/lady_in_the_lake \n", + "30 /tv/my_lady_jane \n", + "31 /tv/presumed_innocent \n", + "32 /tv/sausage_party_foodtopia \n", + "33 /tv/presumed_innocent \n", + "34 /tv/sausage_party_foodtopia \n", + "35 /tv/exploding_kittens \n", + "36 /tv/kite_man_hell_yeah \n", + "37 /tv/vikings_valhalla \n", + "38 /tv/marvels_hit_monkey \n", + "39 /tv/shogun_2024 \n", + "40 /tv/land_of_women \n", + "41 /tv/emperor_of_ocean_park \n", + "42 /tv/a_good_girls_guide_to_murder \n", + "43 /tv/desperate_lies \n", + "44 /tv/simone_biles_rising \n", + "45 /tv/dark_matter_2024 \n", + "46 /tv/the_serpent_queen " ] }, - "execution_count": 27, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -1232,7 +1215,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/guidelines.ipynb b/docs/source/guidelines.ipynb index 21c2702..d079327 100644 --- a/docs/source/guidelines.ipynb +++ b/docs/source/guidelines.ipynb @@ -9,6 +9,11 @@ "\n", "`Kor` is a wrapper around LLMs to help with information extraction.\n", "\n", + "*Kor* is best used with LLMs that do **NOT** natively support function calling.\n", + "\n", + "If you're working with a chat model that **does** support native function calling, please read through\n", + "this guide first (https://python.langchain.com/v0.2/docs/how_to/tool_calling/).\n", + "\n", "The quality of the results depends on a lot of factors. \n", "\n", "Here are a few things to experiment with to improve quality:\n", @@ -16,7 +21,7 @@ "* Add more examples. Diverse examples can help, including examples where nothing should be extracted.\n", "* Improve the descriptions of the attributes.\n", "* If working with multi-paragraph text, specify an `input_formatter` of `\"triple_quotes\"` when creating the chain.\n", - "* Try a better model (e.g., text-davinci-003, gpt-4).\n", + "* Try a better model.\n", "* Break the schema into a few smaller schemas, run separate extractions, and merge the results.\n", "* If possible to flatten the schema, and use a CSV encoding instead of a JSON encoding.\n", "* Add verification/correction steps (ask an LLM to correct or verify the results of the extraction).\n", @@ -44,7 +49,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.1" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/nested_objects.ipynb b/docs/source/nested_objects.ipynb index c106981..cf58c56 100644 --- a/docs/source/nested_objects.ipynb +++ b/docs/source/nested_objects.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 1, "id": "0b4597b2-2a43-4491-8830-bf9f79428074", "metadata": { "nbsphinx": "hidden", @@ -22,16 +22,7 @@ "remove-cell" ] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" - ] - } - ], + "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", @@ -43,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 2, "id": "718c66a7-6186-4ed8-87e9-5ed28e3f209e", "metadata": { "tags": [] @@ -57,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 3, "id": "9bc98f35-ea5f-4b74-a32e-a300a22c0c89", "metadata": { "tags": [] @@ -65,7 +56,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-4o-mini\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", ")" @@ -83,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 4, "id": "f75990e6-5973-4618-9f15-f3b60a14bfa5", "metadata": { "tags": [] @@ -147,7 +138,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 5, "id": "54a199a5-24b4-442c-8907-1449e437a880", "metadata": { "tags": [] @@ -161,7 +152,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 6, "id": "193e257b-df01-45ec-af77-076d2070533b", "metadata": { "tags": [] @@ -178,7 +169,7 @@ " 'to_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'}}]}" ] }, - "execution_count": 29, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -191,7 +182,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 8, "id": "c8295f36-f986-4db2-97bc-ef2e6cdbcc87", "metadata": { "tags": [] @@ -201,23 +192,18 @@ "data": { "text/plain": [ "{'information': [{'person_name': 'Alice Doe',\n", - " 'from_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'},\n", - " 'to_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'}},\n", + " 'from_address': {'city': 'New York', 'country': 'USA'},\n", + " 'to_address': {'city': 'Boston', 'country': 'USA'}},\n", " {'person_name': 'Bob Smith',\n", - " 'from_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'},\n", - " 'to_address': {'city': 'Boston', 'state': 'MA', 'country': 'USA'}},\n", + " 'from_address': {'city': 'New York', 'country': 'USA'},\n", + " 'to_address': {'city': 'Boston', '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', 'state': 'MA', 'country': 'USA'},\n", - " 'to_address': {'city': 'New York', 'state': 'NY', 'country': 'USA'}}]}" + " 'to_address': {'city': 'Boston', 'country': 'USA'}},\n", + " {'person_name': 'Joana', 'to_address': {'city': 'Boston', 'country': 'USA'}},\n", + " {'person_name': 'Paul', 'to_address': {'city': 'Boston', 'country': 'USA'}}]}" ] }, - "execution_count": 30, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -247,7 +233,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 9, "id": "e528f20c-46d3-40b6-b1ba-11024002deb8", "metadata": { "tags": [] @@ -300,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 10, "id": "23b81b06-118a-4ebe-9e20-5df1bf269ce3", "metadata": { "tags": [] @@ -312,7 +298,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 11, "id": "29219fae-41cb-4235-92fa-07b16ded2296", "metadata": { "tags": [] @@ -325,13 +311,14 @@ " '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', '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'}]}]}" + " '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', 'country': 'USA'}],\n", + " 'to_address': [{'city': 'LA', 'state': 'CA', 'country': 'USA'}]}]}" ] }, - "execution_count": 33, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -359,7 +346,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/objects.ipynb b/docs/source/objects.ipynb index d264af7..78b6aec 100644 --- a/docs/source/objects.ipynb +++ b/docs/source/objects.ipynb @@ -54,7 +54,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-4o-mini\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", ")" @@ -194,14 +194,6 @@ "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": [ @@ -333,7 +325,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "id": "5c694d79-e72c-4712-b891-111bc0279032", "metadata": { "tags": [] @@ -347,7 +339,7 @@ " 'age': '20'}]}" ] }, - "execution_count": 12, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -370,7 +362,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "id": "a2944e8c-4630-4b29-b505-b2ca6fceba01", "metadata": { "tags": [] @@ -428,7 +420,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/prompt.ipynb b/docs/source/prompt.ipynb index 68ba5cf..65350f5 100644 --- a/docs/source/prompt.ipynb +++ b/docs/source/prompt.ipynb @@ -56,7 +56,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-4o-mini\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", ")\n", "\n", @@ -279,7 +279,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/schema_serialization.ipynb b/docs/source/schema_serialization.ipynb index a22a9e3..8ba0eb5 100644 --- a/docs/source/schema_serialization.ipynb +++ b/docs/source/schema_serialization.ipynb @@ -188,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 5, "id": "6088c98a", "metadata": { "tags": [] @@ -211,7 +211,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 6, "id": "718c66a7-6186-4ed8-87e9-5ed28e3f209e", "metadata": { "tags": [] @@ -224,7 +224,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 7, "id": "9bc98f35-ea5f-4b74-a32e-a300a22c0c89", "metadata": { "tags": [] @@ -232,7 +232,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-4o-mini\",\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", @@ -241,7 +241,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 8, "id": "54a199a5-24b4-442c-8907-1449e437a880", "metadata": { "tags": [] @@ -253,27 +253,19 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 9, "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": 13, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -284,7 +276,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 10, "id": "c8295f36-f986-4db2-97bc-ef2e6cdbcc87", "metadata": { "tags": [] @@ -325,7 +317,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/tutorial.ipynb b/docs/source/tutorial.ipynb index df6e28d..7000ef2 100644 --- a/docs/source/tutorial.ipynb +++ b/docs/source/tutorial.ipynb @@ -136,7 +136,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-4o-mini\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", " max_tokens=2000,\n", ")" @@ -174,14 +174,6 @@ "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": [ @@ -394,7 +386,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/type_descriptors.ipynb b/docs/source/type_descriptors.ipynb index b005ab2..2eec45a 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.9.6" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/untyped_objects.ipynb b/docs/source/untyped_objects.ipynb index 2e78339..a0c447f 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-4o-mini\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", ")" ] @@ -107,14 +107,6 @@ "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": [ @@ -197,7 +189,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.4" } }, "nbformat": 4, diff --git a/docs/source/validation.ipynb b/docs/source/validation.ipynb index 9049eb1..99da1e3 100644 --- a/docs/source/validation.ipynb +++ b/docs/source/validation.ipynb @@ -63,7 +63,7 @@ "outputs": [], "source": [ "llm = ChatOpenAI(\n", - " model_name=\"gpt-4o-mini\",\n", + " model_name=\"gpt-4o\",\n", " temperature=0,\n", ")" ] @@ -240,7 +240,7 @@ { "data": { "text/plain": [ - "MusicRequest(song=['yellow submarine'], album=None, artist=['the beatles'], action=None)" + "MusicRequest(song=['yellow submarine'], album=None, artist=['the beatles'], action=)" ] }, "execution_count": 9, @@ -263,7 +263,7 @@ { "data": { "text/plain": [ - "MusicRequest(song=['goliath'], album=None, artist=['smith&thell'], action=None)" + "MusicRequest(song=['goliath'], album=None, artist=['smith&thell'], action=)" ] }, "execution_count": 10, @@ -286,7 +286,7 @@ { "data": { "text/plain": [ - "MusicRequest(song=None, album=['the lion king soundtrack'], artist=None, action=None)" + "MusicRequest(song=None, album=['the lion king soundtrack'], artist=None, action=)" ] }, "execution_count": 11, @@ -309,7 +309,7 @@ { "data": { "text/plain": [ - "MusicRequest(song=None, album=None, artist=['paul simon', 'led zeppelin', 'the doors'], action=None)" + "MusicRequest(song=None, album=None, artist=['paul simon', 'led zeppelin', 'the doors'], action=)" ] }, "execution_count": 12, @@ -466,19 +466,12 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "id": "d594eb6e-02a0-4774-9dca-421db192372d", "metadata": { "tags": [] }, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Error in LangChainTracer.on_chain_end callback: No constructor defined\n" - ] - }, { "data": { "text/plain": [ @@ -487,11 +480,11 @@ " 'errors': [1 validation error for Player\n", " song\n", " Field required [type=missing, input_value={'action': 'stop'}, input_type=dict]\n", - " For further information visit https://errors.pydantic.dev/2.3/v/missing],\n", + " For further information visit https://errors.pydantic.dev/2.8/v/missing],\n", " 'validated_data': None}" ] }, - "execution_count": 19, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -502,7 +495,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 19, "id": "672f9908-c6b7-47cf-8c82-03b0e5b8fa84", "metadata": { "tags": [] @@ -514,7 +507,7 @@ "Player(song=['yellow submarine'], album=None, artist=['the beatles'], action=None)" ] }, - "execution_count": 21, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -549,7 +542,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 20, "id": "cd9dffbe-82bf-4d1f-9b0a-3ec2c58b63d6", "metadata": { "tags": [] @@ -563,7 +556,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 21, "id": "f859b6e1-c2d8-48e0-af17-2ffb286bffe9", "metadata": { "tags": [] @@ -583,7 +576,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 22, "id": "af6c6339-81db-482b-9507-31f41d2fa489", "metadata": { "tags": [] @@ -624,7 +617,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 23, "id": "837a08c2-8de0-448a-9984-0cf19a73d4a3", "metadata": { "tags": [] @@ -636,7 +629,7 @@ "[Person(name='john', age=13), Person(name='maria', age=24)]" ] }, - "execution_count": 25, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -659,7 +652,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 24, "id": "ee92ae5e-52e9-4405-9718-be71d25ce412", "metadata": { "tags": [] @@ -688,7 +681,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 25, "id": "7464aab0-45fb-4e22-bed4-b695c7f60629", "metadata": { "tags": [] @@ -703,7 +696,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 26, "id": "8becd13d-bd23-4d37-8fd3-7548a7fe51c1", "metadata": { "tags": [] @@ -719,7 +712,7 @@ " 'validated_data': Root(people=[Person(name='tom', age=23), Person(name='Jessica', age=75)])}" ] }, - "execution_count": 28, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -732,7 +725,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 27, "id": "7ea06fe0-104b-487a-ab78-cd23de66ec88", "metadata": { "tags": [] @@ -772,7 +765,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 28, "id": "38245cd6-e188-40c9-a940-184da8755983", "metadata": { "tags": [] @@ -813,7 +806,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 29, "id": "236a9510-6f69-4d63-8854-62e2c57380a6", "metadata": { "tags": [] @@ -830,7 +823,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 30, "id": "843e992a-32c5-4382-95ab-33eb3cd7810b", "metadata": { "tags": [] @@ -878,7 +871,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 32, "id": "e34b6194-9a2b-43a1-95c6-2c9930d036ed", "metadata": { "tags": [] @@ -887,17 +880,17 @@ { "data": { "text/plain": [ - "Root(people=[Person(name='Neo', age=None, pets=[Pet(name='Tom', species='dog', age=None, age_unit=None), Pet(name='Weeby', species='cat', age=23, age_unit='days')]), Person(name='Julia', age=None, pets=[Pet(name='Wind', species='horse', age=None, age_unit=None)])])" + "Root(people=[Person(name='Neo', age=None, pets=[Pet(name='Tom', species='dog', age=0, age_unit='days'), Pet(name='Weeby', species='cat', age=23, age_unit='days')]), Person(name='Julia', age=None, pets=[Pet(name='Wind', species='horse', age=0, age_unit='days')])])" ] }, - "execution_count": 45, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "chain.invoke(\n", - " text=\"Neo had a dog by the name of Tom and a cat by the name of Weeby. Weeby was 23 days old. Julia owned a horse. The horses name was Wind\"\n", + " \"Neo had a dog by the name of Tom and a cat by the name of Weeby. Weeby was 23 days old. Julia owned a horse. The horses name was Wind\"\n", ")[\"validated_data\"]" ] } @@ -918,7 +911,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.11.4" } }, "nbformat": 4,