mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
ebf998acb6
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com> Co-authored-by: Lance Martin <lance@langchain.dev> Co-authored-by: Jacob Lee <jacoblee93@gmail.com>
84 lines
1.8 KiB
Plaintext
84 lines
1.8 KiB
Plaintext
{
|
|
"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",
|
|
"langchain serve add anthropic-functions\n",
|
|
"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",
|
|
"http://127.0.0.1:8000/docs#/default/invoke_anthropic-functions_invoke_post\n",
|
|
" \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",
|
|
"anthropic_function_model = RemoteRunnable('http://localhost:8000/anthropic-functions')\n",
|
|
"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
|
|
}
|