2023-10-26 01:47:42 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"id": "4ae4b789",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Document Loading\n",
|
|
|
|
"\n",
|
|
|
|
"Load a blog post on agents."
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"id": "5d6bd62e",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"from langchain.document_loaders import WebBaseLoader\n",
|
|
|
|
"loader = WebBaseLoader(\"https://lilianweng.github.io/posts/2023-06-23-agent/\")\n",
|
|
|
|
"text = loader.load()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"id": "8e21575d",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Run Template\n",
|
|
|
|
"\n",
|
|
|
|
"As shown in the README, add template and start server:\n",
|
|
|
|
"```\n",
|
2023-10-29 05:13:22 +00:00
|
|
|
"langchain serve add extraction-anthropic-functions\n",
|
2023-10-26 01:47:42 +00:00
|
|
|
"langchain start\n",
|
|
|
|
"```\n",
|
|
|
|
"\n",
|
|
|
|
"We can now look at the endpoints:\n",
|
|
|
|
"\n",
|
|
|
|
"http://127.0.0.1:8000/docs#\n",
|
|
|
|
"\n",
|
|
|
|
"And specifically at our loaded template:\n",
|
|
|
|
"\n",
|
2023-10-29 05:13:22 +00:00
|
|
|
"http://127.0.0.1:8000/docs#/default/invoke_extraction-anthropic-functions_invoke_post\n",
|
2023-10-26 01:47:42 +00:00
|
|
|
" \n",
|
|
|
|
"We can also use remote runnable to call it:"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 4,
|
|
|
|
"id": "92edba86",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"from langserve.client import RemoteRunnable\n",
|
2023-10-29 05:13:22 +00:00
|
|
|
"anthropic_function_model = RemoteRunnable('http://localhost:8000/extraction-anthropic-functions')\n",
|
2023-10-26 01:47:42 +00:00
|
|
|
"anthropic_function_model.invoke(text[0].page_content[0:1500])"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "langserve",
|
|
|
|
"language": "python",
|
|
|
|
"name": "langserve"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.9.16"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 5
|
|
|
|
}
|