2023-10-26 01:47:42 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"id": "16f2c32e",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Document Loading\n",
|
|
|
|
"\n",
|
|
|
|
"Load a blog post on agents."
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"id": "c9fadce0",
|
|
|
|
"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": "4086be03",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Run Template\n",
|
|
|
|
"\n",
|
2023-10-27 05:23:03 +00:00
|
|
|
"In `server.py`, set -\n",
|
2023-10-26 01:47:42 +00:00
|
|
|
"```\n",
|
2023-10-27 05:23:03 +00:00
|
|
|
"add_routes(app, chain_ext, path=\"/extraction_openai_functions\")\n",
|
|
|
|
"```"
|
2023-10-26 01:47:42 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 2,
|
|
|
|
"id": "ed507784",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"from langserve.client import RemoteRunnable\n",
|
2023-10-27 05:23:03 +00:00
|
|
|
"oai_function = RemoteRunnable('http://0.0.0.0:8001/extraction_openai_functions')"
|
2023-10-26 01:47:42 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"id": "68046695",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2023-10-27 05:23:03 +00:00
|
|
|
"The function wille extract paper titles and authors from an input."
|
2023-10-26 01:47:42 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-10-27 05:23:03 +00:00
|
|
|
"execution_count": 8,
|
2023-10-26 01:47:42 +00:00
|
|
|
"id": "6dace748",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2023-10-27 05:23:03 +00:00
|
|
|
"[{'title': 'Chain of Thought', 'author': 'Wei et al. 2022'},\n",
|
|
|
|
" {'title': 'Tree of Thoughts', 'author': 'Yao et al. 2023'},\n",
|
|
|
|
" {'title': 'LLM+P', 'author': 'Liu et al. 2023'}]"
|
2023-10-26 01:47:42 +00:00
|
|
|
]
|
|
|
|
},
|
2023-10-27 05:23:03 +00:00
|
|
|
"execution_count": 8,
|
2023-10-26 01:47:42 +00:00
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
2023-10-27 05:23:03 +00:00
|
|
|
"oai_function.invoke({\"input\":text[0].page_content[0:4000]})"
|
2023-10-26 01:47:42 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"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
|
|
|
|
}
|