Skip to content

Commit

Permalink
add requests to notebook (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwchase17 authored Oct 12, 2023
1 parent 06fec48 commit c44e3bf
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 14 deletions.
39 changes: 39 additions & 0 deletions examples/agent/client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,45 @@
"Demo of a client interacting with a remote agent. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can interact with this via API directly"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'output': {'output': 'Eugene thinks that cats like fish.'}}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"\n",
"inputs = {\"input\": {\"input\": \"what does eugene think of cats?\"}}\n",
"response = requests.post(\"http://localhost:8000/invoke\", json=inputs)\n",
"\n",
"response.json()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also interact with this via the RemoteRunnable interface (to use in other chains)"
]
},
{
"cell_type": "code",
"execution_count": 3,
Expand Down
48 changes: 38 additions & 10 deletions examples/chain/client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,46 @@
"Demo of client interacting with the simple chain server, which deploys a chain that tells jokes about a particular topic."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can interact with this via API directly"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": []
},
"outputs": [],
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'output': {'content': \"Why don't scientists trust atoms when playing sports? \\n\\nBecause they make up everything!\",\n",
" 'additional_kwargs': {},\n",
" 'type': 'ai',\n",
" 'example': False}}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"\n",
"inputs = {\"input\": {\"topic\": \"sports\"}}\n",
"response = requests.post(\"http://localhost:8000/invoke\", json=inputs)\n",
"\n",
"response.json()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"from langchain.prompts.chat import (\n",
" HumanMessagePromptTemplate,\n",
" SystemMessagePromptTemplate,\n",
")"
"You can also interact with this via the RemoteRunnable interface (to use in other chains)"
]
},
{
Expand Down Expand Up @@ -155,7 +183,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
39 changes: 39 additions & 0 deletions examples/conversational_retrieval_chain/client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,45 @@
"Demo of a client interacting with a remote conversational retrieval chain. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can interact with this via API directly"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'output': {'answer': 'Cats like fish.'}}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"\n",
"inputs = {\"input\": {\"question\": \"what do cats like?\", \"chat_history\": \"\"}}\n",
"response = requests.post(\"http://localhost:8000/invoke\", json=inputs)\n",
"\n",
"response.json()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also interact with this via the RemoteRunnable interface (to use in other chains)"
]
},
{
"cell_type": "code",
"execution_count": 6,
Expand Down
2 changes: 1 addition & 1 deletion examples/llm/client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
48 changes: 45 additions & 3 deletions examples/retrieval/client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,48 @@
"Demo of a client interacting with a remote retriever. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can interact with this via API directly"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'output': [{'page_content': 'dogs like sticks',\n",
" 'metadata': {},\n",
" 'type': 'Document'},\n",
" {'page_content': 'cats like fish', 'metadata': {}, 'type': 'Document'}]}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"\n",
"inputs = {\"input\": \"tree\"}\n",
"response = requests.post(\"http://localhost:8000/invoke\", json=inputs)\n",
"\n",
"response.json()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also interact with this via the RemoteRunnable interface (to use in other chains)"
]
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down Expand Up @@ -39,8 +81,8 @@
{
"data": {
"text/plain": [
"[Document(page_content='dogs like sticks', metadata={}),\n",
" Document(page_content='cats like fish', metadata={})]"
"[Document(page_content='dogs like sticks'),\n",
" Document(page_content='cats like fish')]"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -182,7 +224,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down

0 comments on commit c44e3bf

Please sign in to comment.