Update notebooks to use bind_tools (#394)

This commit is contained in:
William FH
2024-05-04 01:30:52 -07:00
committed by GitHub
parent 21b8cbfd33
commit e0770d68b3
29 changed files with 1466 additions and 949 deletions
+24 -20
View File
@@ -214,7 +214,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "df39af17",
"id": "6b7dc713",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-19T11:25:40.358604Z",
@@ -227,8 +227,9 @@
"from IPython.display import display, HTML\n",
"import base64\n",
"\n",
"\n",
"def display_image(image_bytes: bytes, width=300):\n",
" decoded_img_bytes = base64.b64encode(image_bytes).decode('utf-8')\n",
" decoded_img_bytes = base64.b64encode(image_bytes).decode(\"utf-8\")\n",
" html = f'<img src=\"data:image/png;base64,{decoded_img_bytes}\" style=\"width: {width}px;\" />'\n",
" display(HTML(html))"
]
@@ -271,7 +272,7 @@
}
],
"source": [
"#%%capture --no-stderr\n",
"%%capture --no-stderr\n",
"%pip install pygraphviz"
]
},
@@ -374,10 +375,9 @@
}
],
"source": [
"# %%capture --no-stderr\n",
"%pip install pyppeteer\n",
"# %%capture --no-stderr\n",
"%pip install nest_asyncio"
"%%capture --no-stderr\n",
"%pip install --quiet pyppeteer\n",
"%pip install --quiet nest_asyncio"
]
},
{
@@ -418,17 +418,19 @@
"import nest_asyncio\n",
"from langchain_core.runnables.graph import CurveStyle, NodeColors, MermaidDrawMethod\n",
"\n",
"nest_asyncio.apply() # Required for Jupyter Notebook to run async functions\n",
"nest_asyncio.apply() # Required for Jupyter Notebook to run async functions\n",
"\n",
"display_image(app.get_graph().draw_mermaid_png(\n",
" curve_style=CurveStyle.LINEAR,\n",
" node_colors=NodeColors(start=\"#ffdfba\", end=\"#baffc9\", other=\"#fad7de\"),\n",
" wrap_label_n_words=9,\n",
" output_file_path=None,\n",
" draw_method=MermaidDrawMethod.PYPPETEER,\n",
" background_color=\"white\",\n",
" padding=10\n",
"))"
"display_image(\n",
" app.get_graph().draw_mermaid_png(\n",
" curve_style=CurveStyle.LINEAR,\n",
" node_colors=NodeColors(start=\"#ffdfba\", end=\"#baffc9\", other=\"#fad7de\"),\n",
" wrap_label_n_words=9,\n",
" output_file_path=None,\n",
" draw_method=MermaidDrawMethod.PYPPETEER,\n",
" background_color=\"white\",\n",
" padding=10,\n",
" )\n",
")"
]
},
{
@@ -469,9 +471,11 @@
}
],
"source": [
"display_image(app.get_graph().draw_mermaid_png(\n",
" draw_method=MermaidDrawMethod.API,\n",
"))"
"display_image(\n",
" app.get_graph().draw_mermaid_png(\n",
" draw_method=MermaidDrawMethod.API,\n",
" )\n",
")"
]
}
],