Fixed up some import issues, README and a requirements.txt for users running the files

This commit is contained in:
Ivan
2023-11-19 08:58:02 +08:00
parent 90d8a8c424
commit 0928ce7a3a
3 changed files with 185 additions and 90 deletions
+121 -90
View File
@@ -32,7 +32,7 @@
},
{
"cell_type": "code",
"execution_count": 106,
"execution_count": 9,
"id": "fdf5e1d9-31ad-4e8a-a55e-e2e70fff598d",
"metadata": {},
"outputs": [
@@ -42,14 +42,15 @@
"{'age': 17, 'name': 'Harry Potter', 'house': <House.Gryffindor: 'gryffindor'>}"
]
},
"execution_count": 106,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from enum import Enum\n",
"\n",
"from pydantic import BaseModel,Field\n",
"from typing import List,Literal\n",
"import instructor\n",
"from openai import OpenAI\n",
"\n",
@@ -82,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": 107,
"execution_count": 10,
"id": "03db160c-81e9-4373-bfec-7a107224b6dd",
"metadata": {},
"outputs": [
@@ -92,7 +93,7 @@
"{'age': 17, 'name': 'Harry Potter', 'house': 'Gryffindor'}"
]
},
"execution_count": 107,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -128,7 +129,7 @@
},
{
"cell_type": "code",
"execution_count": 108,
"execution_count": 4,
"id": "0e7938b8-4666-4df4-bd80-f53e8baf7550",
"metadata": {},
"outputs": [
@@ -138,13 +139,13 @@
"{'age': 38,\n",
" 'name': 'Severus Snape',\n",
" 'house': 'Slytherin',\n",
" 'properties': [{'key': 'occupation', 'value': 'Potions Master'},\n",
" 'properties': [{'key': 'role', 'value': 'Professor of Potions'},\n",
" {'key': 'loyalty', 'value': 'Dumbledore'},\n",
" {'key': 'patronus', 'value': 'Doe'},\n",
" {'key': 'played_by', 'value': 'Alan Rickman'}]}"
]
},
"execution_count": 108,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -189,7 +190,7 @@
},
{
"cell_type": "code",
"execution_count": 109,
"execution_count": 5,
"id": "69a58d01-ab6f-41b6-bc0c-b0e55fdb6fe4",
"metadata": {},
"outputs": [
@@ -199,14 +200,20 @@
"{'age': 38,\n",
" 'name': 'Severus Snape',\n",
" 'house': 'Slytherin',\n",
" 'properties': [{'index': '1', 'key': 'Role', 'value': 'Potions Master'},\n",
" {'index': '2', 'key': 'Loyalty', 'value': 'Dumbledore'},\n",
" {'index': '3', 'key': 'Spying for', 'value': 'Order of the Phoenix'},\n",
" 'properties': [{'index': '1',\n",
" 'key': 'Occupation',\n",
" 'value': 'Potions Master, Defense Against the Dark Arts Professor, Headmaster'},\n",
" {'index': '2',\n",
" 'key': 'Loyalty',\n",
" 'value': 'Hogwarts, Order of the Phoenix, Albus Dumbledore, Lily Potter'},\n",
" {'index': '3',\n",
" 'key': 'Skills',\n",
" 'value': 'Potions, Occlumency, Legilimency, Spell creation'},\n",
" {'index': '4', 'key': 'Patronus', 'value': 'Doe'},\n",
" {'index': '5', 'key': 'Played by', 'value': 'Alan Rickman'}]}"
" {'index': '5', 'key': 'Actor', 'value': 'Alan Rickman'}]}"
]
},
"execution_count": 109,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -248,7 +255,7 @@
},
{
"cell_type": "code",
"execution_count": 110,
"execution_count": 6,
"id": "1f2a2b14-a956-4f96-90c9-e11ca04ab7d1",
"metadata": {},
"outputs": [
@@ -258,24 +265,34 @@
"{'users': [{'age': 38,\n",
" 'name': 'Severus Snape',\n",
" 'house': 'Slytherin',\n",
" 'properties': [{'index': '1', 'key': 'Position', 'value': 'Potions Master'},\n",
" {'index': '2', 'key': 'Loyalty', 'value': 'Dumbledore'},\n",
" {'index': '3', 'key': 'Special Ability', 'value': 'Occlumency'},\n",
" 'properties': [{'index': '1',\n",
" 'key': 'Occupation',\n",
" 'value': 'Potions Master, Defense Against the Dark Arts teacher, Headmaster'},\n",
" {'index': '2',\n",
" 'key': 'Loyalty',\n",
" 'value': 'Hogwarts School, Order of the Phoenix, Albus Dumbledore'},\n",
" {'index': '3',\n",
" 'key': 'Skills',\n",
" 'value': 'Potions, Occlumency, Legilimency'},\n",
" {'index': '4', 'key': 'Patronus', 'value': 'Doe'},\n",
" {'index': '5', 'key': 'Played by', 'value': 'Alan Rickman'}]},\n",
" {'age': 115,\n",
" 'name': 'Albus Dumbledore',\n",
" 'house': 'Gryffindor',\n",
" 'properties': [{'index': '1', 'key': 'Position', 'value': 'Headmaster'},\n",
" {'index': '2', 'key': 'Founder of', 'value': 'Order of the Phoenix'},\n",
" {'index': '3', 'key': 'Possession', 'value': 'Elder Wand'},\n",
" {'index': '4', 'key': 'Special Ability', 'value': 'Incredible Wizard'},\n",
" 'properties': [{'index': '1',\n",
" 'key': 'Occupation',\n",
" 'value': 'Headmaster, Founder of the Order of the Phoenix'},\n",
" {'index': '2',\n",
" 'key': 'Loyalty',\n",
" 'value': 'Hogwarts School, Order of the Phoenix'},\n",
" {'index': '3', 'key': 'Skills', 'value': 'Transfiguration, Alchemy'},\n",
" {'index': '4', 'key': 'Patronus', 'value': 'Phoenix'},\n",
" {'index': '5',\n",
" 'key': 'Played by',\n",
" 'value': 'Michael Gambon (primarily)'}]}]}"
" 'value': 'Richard Harris (films 1-2), Michael Gambon (films 3-8)'}]}]}"
]
},
"execution_count": 110,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -309,7 +326,7 @@
},
{
"cell_type": "code",
"execution_count": 111,
"execution_count": 7,
"id": "6de8768e-b36a-4a51-9cf9-940d178552f6",
"metadata": {},
"outputs": [
@@ -317,15 +334,17 @@
"data": {
"text/plain": [
"{'users': [{'id': 1, 'name': 'Harry Potter', 'friends': [2, 3, 4, 5, 6, 7]},\n",
" {'id': 2, 'name': 'Ron Weasley', 'friends': [1, 3, 5, 6]},\n",
" {'id': 2, 'name': 'Ron Weasley', 'friends': [1, 3, 5, 6, 7]},\n",
" {'id': 3, 'name': 'Hermione Granger', 'friends': [1, 2, 5, 6, 7]},\n",
" {'id': 4, 'name': 'Draco Malfoy', 'friends': [1, 5]},\n",
" {'id': 5, 'name': 'Neville Longbottom', 'friends': [1, 2, 3, 6]},\n",
" {'id': 6, 'name': 'Luna Lovegood', 'friends': [1, 2, 3, 5]},\n",
" {'id': 7, 'name': 'Ginny Weasley', 'friends': [1, 3]}]}"
" {'id': 4, 'name': 'Draco Malfoy', 'friends': [1, 7]},\n",
" {'id': 5, 'name': 'Neville Longbottom', 'friends': [1, 2, 3]},\n",
" {'id': 6, 'name': 'Luna Lovegood', 'friends': [1, 2, 3]},\n",
" {'id': 7, 'name': 'Ginny Weasley', 'friends': [1, 2, 3]},\n",
" {'id': 8, 'name': 'Fred Weasley', 'friends': [2, 7]},\n",
" {'id': 9, 'name': 'George Weasley', 'friends': [2, 7]}]}"
]
},
"execution_count": 111,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@@ -354,7 +373,7 @@
},
{
"cell_type": "code",
"execution_count": 112,
"execution_count": 8,
"id": "b31e10d7-ebd2-49b4-b2c4-20dd67ca135d",
"metadata": {},
"outputs": [
@@ -367,141 +386,153 @@
"<!-- Generated by graphviz version 9.0.0 (20230911.1827)\n",
" -->\n",
"<!-- Pages: 1 -->\n",
"<svg width=\"470pt\" height=\"332pt\"\n",
" viewBox=\"0.00 0.00 469.97 332.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 328)\">\n",
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-328 465.97,-328 465.97,4 -4,4\"/>\n",
"<svg width=\"704pt\" height=\"260pt\"\n",
" viewBox=\"0.00 0.00 704.49 260.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 256)\">\n",
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-256 700.49,-256 700.49,4 -4,4\"/>\n",
"<!-- 1 -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>1</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"267.78\" cy=\"-306\" rx=\"56.98\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"267.78\" y=\"-300.95\" font-family=\"Times,serif\" font-size=\"14.00\">Harry Potter</text>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"336.67\" cy=\"-234\" rx=\"56.98\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"336.67\" y=\"-228.95\" font-family=\"Times,serif\" font-size=\"14.00\">Harry Potter</text>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>2</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"213.78\" cy=\"-234\" rx=\"60.05\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"213.78\" y=\"-228.95\" font-family=\"Times,serif\" font-size=\"14.00\">Ron Weasley</text>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"292.67\" cy=\"-162\" rx=\"60.05\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"292.67\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">Ron Weasley</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;2 -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
"<title>1&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M254.7,-288.05C248.4,-279.89 240.71,-269.91 233.7,-260.82\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"236.53,-258.77 227.65,-252.99 230.99,-263.04 236.53,-258.77\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M326.02,-216.05C320.99,-208.06 314.87,-198.33 309.26,-189.4\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"312.31,-187.67 304.02,-181.07 306.38,-191.4 312.31,-187.67\"/>\n",
"</g>\n",
"<!-- 3 -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>3</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"317.78\" cy=\"-162\" rx=\"81.04\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"317.78\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">Hermione Granger</text>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"195.67\" cy=\"-90\" rx=\"81.04\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"195.67\" y=\"-84.95\" font-family=\"Times,serif\" font-size=\"14.00\">Hermione Granger</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;3 -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
"<title>1&#45;&gt;3</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M273.81,-287.87C282.29,-263.78 297.85,-219.6 308,-190.77\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"311.2,-192.21 311.22,-181.62 304.6,-189.89 311.2,-192.21\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M293.3,-221.97C269.73,-213.92 241.78,-200.72 223.67,-180 208.99,-163.22 202,-138.75 198.68,-119.72\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"202.15,-119.29 197.23,-109.91 195.23,-120.31 202.15,-119.29\"/>\n",
"</g>\n",
"<!-- 4 -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>4</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"78.78\" cy=\"-162\" rx=\"63.63\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"78.78\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">Draco Malfoy</text>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"472.67\" cy=\"-90\" rx=\"63.63\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"472.67\" y=\"-84.95\" font-family=\"Times,serif\" font-size=\"14.00\">Draco Malfoy</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;4 -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>1&#45;&gt;4</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M226.38,-293.25C201.03,-284.65 168.93,-271.13 144.78,-252 123.3,-234.99 105.29,-209.37 93.54,-189.97\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"96.66,-188.38 88.59,-181.51 90.62,-191.91 96.66,-188.38\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M355.7,-216.56C367.27,-206.34 382.16,-192.77 394.67,-180 414.93,-159.31 436.52,-134.43 451.84,-116.24\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"454.12,-118.97 457.85,-109.06 448.75,-114.48 454.12,-118.97\"/>\n",
"</g>\n",
"<!-- 5 -->\n",
"<g id=\"node5\" class=\"node\">\n",
"<title>5</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"93.78\" cy=\"-90\" rx=\"86.67\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"93.78\" y=\"-84.95\" font-family=\"Times,serif\" font-size=\"14.00\">Neville Longbottom</text>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"86.67\" cy=\"-18\" rx=\"86.67\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"86.67\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">Neville Longbottom</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;5 -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>1&#45;&gt;5</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M215.38,-298.46C151.13,-287.2 45.83,-257.3 5.78,-180 -1.58,-165.79 -2.1,-157.93 5.78,-144 13.68,-130.01 26.93,-119.3 40.78,-111.29\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"42.36,-114.42 49.56,-106.64 39.08,-108.23 42.36,-114.42\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M286.48,-225.09C225.68,-212.45 126.37,-181.17 85.67,-108 75.5,-89.72 76.36,-65.89 79.43,-47.49\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"82.85,-48.27 81.38,-37.78 75.98,-46.9 82.85,-48.27\"/>\n",
"</g>\n",
"<!-- 6 -->\n",
"<g id=\"node6\" class=\"node\">\n",
"<title>6</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"240.78\" cy=\"-18\" rx=\"69.78\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"240.78\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">Luna Lovegood</text>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"304.67\" cy=\"-18\" rx=\"69.78\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"304.67\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">Luna Lovegood</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;6 -->\n",
"<g id=\"edge5\" class=\"edge\">\n",
"<title>1&#45;&gt;6</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M308.2,-293.01C331.73,-284.48 360.8,-271.11 381.78,-252 443.9,-195.39 490.99,-138.64 439.78,-72 424.13,-51.64 363.39,-37.44 313.09,-28.9\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"313.81,-25.47 303.37,-27.31 312.68,-32.38 313.81,-25.47\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M347.03,-216.03C352.57,-205.96 358.82,-192.71 361.67,-180 365.16,-164.39 365.06,-159.64 361.67,-144 353.87,-108.11 334.83,-70.16 320.89,-45.62\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"324.09,-44.17 316.04,-37.28 318.04,-47.69 324.09,-44.17\"/>\n",
"</g>\n",
"<!-- 7 -->\n",
"<g id=\"node7\" class=\"node\">\n",
"<title>7</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"362.78\" cy=\"-90\" rx=\"67.73\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"362.78\" y=\"-84.95\" font-family=\"Times,serif\" font-size=\"14.00\">Ginny Weasley</text>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"466.67\" cy=\"-18\" rx=\"67.73\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"466.67\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">Ginny Weasley</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;7 -->\n",
"<g id=\"edge6\" class=\"edge\">\n",
"<title>1&#45;&gt;7</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M295.71,-289.98C329.55,-269.99 384.87,-231.15 407.78,-180 414.31,-165.4 413.29,-159.02 407.78,-144 403.99,-133.68 397.2,-124 390.03,-115.8\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"392.67,-113.5 383.25,-108.64 387.58,-118.31 392.67,-113.5\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M378.69,-221.61C428.73,-205.53 510,-170.89 545.67,-108 553.56,-94.08 553.2,-86.12 545.67,-72 538.36,-58.3 525.76,-47.51 512.74,-39.35\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"514.51,-36.33 504.1,-34.36 511.02,-42.39 514.51,-36.33\"/>\n",
"</g>\n",
"<!-- 2&#45;&gt;3 -->\n",
"<g id=\"edge7\" class=\"edge\">\n",
"<title>2&#45;&gt;3</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M237.38,-217.12C251.17,-207.83 268.82,-195.95 284.06,-185.69\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"285.59,-188.88 291.93,-180.4 281.68,-183.08 285.59,-188.88\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M270.66,-145.12C258.03,-136 241.95,-124.4 227.92,-114.28\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"229.99,-111.45 219.83,-108.44 225.89,-117.13 229.99,-111.45\"/>\n",
"</g>\n",
"<!-- 2&#45;&gt;5 -->\n",
"<g id=\"edge8\" class=\"edge\">\n",
"<title>2&#45;&gt;5</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M203.39,-215.78C191.85,-197.22 172.13,-167.23 151.78,-144 143.04,-134.02 132.57,-123.98 122.95,-115.36\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"125.38,-112.84 115.56,-108.88 120.77,-118.11 125.38,-112.84\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M233.05,-159.55C191.61,-155.28 138.18,-142.73 105.67,-108 90.71,-92.03 86.38,-67.3 85.55,-47.95\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"89.05,-47.93 85.44,-37.96 82.05,-48 89.05,-47.93\"/>\n",
"</g>\n",
"<!-- 2&#45;&gt;6 -->\n",
"<g id=\"edge9\" class=\"edge\">\n",
"<title>2&#45;&gt;6</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M215.94,-215.85C220.57,-179.14 231.48,-92.66 237.18,-47.53\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"240.63,-48.09 238.41,-37.73 233.69,-47.22 240.63,-48.09\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M294.14,-143.59C296.16,-119.61 299.84,-76.14 302.26,-47.42\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"305.74,-47.88 303.09,-37.62 298.76,-47.29 305.74,-47.88\"/>\n",
"</g>\n",
"<!-- 2&#45;&gt;7 -->\n",
"<g id=\"edge10\" class=\"edge\">\n",
"<title>2&#45;&gt;7</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M311.88,-144.78C333.2,-126.83 368.7,-97.12 399.67,-72 411.66,-62.27 424.99,-51.68 436.58,-42.55\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"438.55,-45.45 444.25,-36.51 434.22,-39.94 438.55,-45.45\"/>\n",
"</g>\n",
"<!-- 3&#45;&gt;5 -->\n",
"<g id=\"edge10\" class=\"edge\">\n",
"<g id=\"edge11\" class=\"edge\">\n",
"<title>3&#45;&gt;5</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M272.18,-146.75C237.25,-135.84 188.84,-120.71 151.26,-108.96\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"152.5,-105.68 141.91,-106.04 150.41,-112.37 152.5,-105.68\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M170.11,-72.59C155.73,-63.35 137.56,-51.68 121.85,-41.59\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"124.02,-38.83 113.71,-36.37 120.24,-44.72 124.02,-38.83\"/>\n",
"</g>\n",
"<!-- 3&#45;&gt;6 -->\n",
"<g id=\"edge11\" class=\"edge\">\n",
"<g id=\"edge12\" class=\"edge\">\n",
"<title>3&#45;&gt;6</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M307.07,-144.01C300.69,-133.7 292.54,-120.22 285.78,-108 274.52,-87.68 262.71,-64.21 254.01,-46.48\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"257.22,-45.08 249.69,-37.62 250.92,-48.14 257.22,-45.08\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M221.22,-72.59C235.81,-63.22 254.3,-51.34 270.17,-41.16\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"271.85,-44.23 278.37,-35.89 268.07,-38.34 271.85,-44.23\"/>\n",
"</g>\n",
"<!-- 3&#45;&gt;7 -->\n",
"<g id=\"edge12\" class=\"edge\">\n",
"<title>3&#45;&gt;7</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M328.9,-143.7C333.97,-135.81 340.08,-126.3 345.71,-117.55\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"348.5,-119.68 350.96,-109.38 342.61,-115.9 348.5,-119.68\"/>\n",
"</g>\n",
"<!-- 4&#45;&gt;5 -->\n",
"<g id=\"edge13\" class=\"edge\">\n",
"<title>4&#45;&gt;5</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M82.48,-143.7C84.06,-136.32 85.95,-127.52 87.72,-119.25\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"91.12,-120.1 89.79,-109.58 84.28,-118.63 91.12,-120.1\"/>\n",
"<title>3&#45;&gt;7</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M246.96,-75.75C292.94,-63.87 360.36,-46.46 408.37,-34.06\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"408.94,-37.53 417.75,-31.64 407.19,-30.75 408.94,-37.53\"/>\n",
"</g>\n",
"<!-- 5&#45;&gt;6 -->\n",
"<!-- 4&#45;&gt;7 -->\n",
"<g id=\"edge14\" class=\"edge\">\n",
"<title>5&#45;&gt;6</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M127.13,-73.12C148.19,-63.09 175.6,-50.04 198.22,-39.27\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"199.67,-42.45 207.2,-34.99 196.66,-36.13 199.67,-42.45\"/>\n",
"<title>4&#45;&gt;7</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M471.18,-71.7C470.56,-64.41 469.81,-55.73 469.11,-47.54\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"472.6,-47.28 468.26,-37.61 465.63,-47.87 472.6,-47.28\"/>\n",
"</g>\n",
"<!-- 8 -->\n",
"<g id=\"node8\" class=\"node\">\n",
"<title>8</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"473.67\" cy=\"-234\" rx=\"61.59\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"473.67\" y=\"-228.95\" font-family=\"Times,serif\" font-size=\"14.00\">Fred Weasley</text>\n",
"</g>\n",
"<!-- 9 -->\n",
"<g id=\"node9\" class=\"node\">\n",
"<title>9</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"624.67\" cy=\"-234\" rx=\"71.82\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"624.67\" y=\"-228.95\" font-family=\"Times,serif\" font-size=\"14.00\">George Weasley</text>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<graphviz.graphs.Digraph at 0x10c125fd0>"
"<graphviz.graphs.Digraph at 0x109081f90>"
]
},
"metadata": {},
@@ -542,9 +573,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "instructor-env",
"language": "python",
"name": "python3"
"name": "instructor-env"
},
"language_info": {
"codemirror_mode": {
+58
View File
@@ -0,0 +1,58 @@
# Introduction
This section includes a list of notebooks that walk you through some simple concepts in Instructor. We start small and then work our way up to more complex and tricky implementations using the library.
## Overview
Currently we have the following notebooks avaliable
1. `Introduction` - This is a quick walkthrough some of the benefits of Pydantic and how the Instructor Library integrates nicely with Pydantic with `instructor.patch()`
2. `Tips` - Quick demonstration of how to use enums, `Pydantic` models and structured prompting to get specific output formats
3.
## Installation
We utilise the Graphviz package in this tutorial series. If you don't have it on hand, you should download it. Mac users can do so by running `brew install graphviz` while Linux users can try `sudo apt install graphviz` ( modify to your system specific package manager).
If you're encountering an error like the following when trying to run graphviz after installing it, just restart the notebook and verify you've got graphviz installed by running `dot -v` in your shell.
```
Command '[PosixPath('dot'), '-Kdot', '-Tsvg']' died with <Signals.SIGKILL: 9>.
```
Here are the steps to start running the notebooks
1. Create a virtual environment
```
python3 -m venv .venv
source .venv .venv/bin/activate
```
2. Install the dependencies
```
pip3 install -r requirements.txt
```
3. Add the virtual environment to Jupyter notebook
```
python -m ipykernel install --user --name=instructor-env
```
4. Add OpenAI API Key into your shell by running the following command. This will be set for as long as the shell is open.
```
export OPENAI_API_KEY=<api key goes here>
```
5. Start Jupyter Notebook
```
jupyter notebook
```
+6
View File
@@ -0,0 +1,6 @@
ipykernel
jupyter
instructor
openai>=1.1.0
pydantic
graphviz