Skip to content

Commit c44e3bf

Browse files
authored
add requests to notebook (langchain-ai#34)
1 parent 06fec48 commit c44e3bf

File tree

5 files changed

+162
-14
lines changed

5 files changed

+162
-14
lines changed

examples/agent/client.ipynb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,45 @@
99
"Demo of a client interacting with a remote agent. "
1010
]
1111
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"You can interact with this via API directly"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 7,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"data": {
26+
"text/plain": [
27+
"{'output': {'output': 'Eugene thinks that cats like fish.'}}"
28+
]
29+
},
30+
"execution_count": 7,
31+
"metadata": {},
32+
"output_type": "execute_result"
33+
}
34+
],
35+
"source": [
36+
"import requests\n",
37+
"\n",
38+
"inputs = {\"input\": {\"input\": \"what does eugene think of cats?\"}}\n",
39+
"response = requests.post(\"http://localhost:8000/invoke\", json=inputs)\n",
40+
"\n",
41+
"response.json()"
42+
]
43+
},
44+
{
45+
"cell_type": "markdown",
46+
"metadata": {},
47+
"source": [
48+
"You can also interact with this via the RemoteRunnable interface (to use in other chains)"
49+
]
50+
},
1251
{
1352
"cell_type": "code",
1453
"execution_count": 3,

examples/chain/client.ipynb

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,46 @@
99
"Demo of client interacting with the simple chain server, which deploys a chain that tells jokes about a particular topic."
1010
]
1111
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"You can interact with this via API directly"
17+
]
18+
},
1219
{
1320
"cell_type": "code",
14-
"execution_count": 1,
15-
"metadata": {
16-
"tags": []
17-
},
18-
"outputs": [],
21+
"execution_count": 3,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"data": {
26+
"text/plain": [
27+
"{'output': {'content': \"Why don't scientists trust atoms when playing sports? \\n\\nBecause they make up everything!\",\n",
28+
" 'additional_kwargs': {},\n",
29+
" 'type': 'ai',\n",
30+
" 'example': False}}"
31+
]
32+
},
33+
"execution_count": 3,
34+
"metadata": {},
35+
"output_type": "execute_result"
36+
}
37+
],
38+
"source": [
39+
"import requests\n",
40+
"\n",
41+
"inputs = {\"input\": {\"topic\": \"sports\"}}\n",
42+
"response = requests.post(\"http://localhost:8000/invoke\", json=inputs)\n",
43+
"\n",
44+
"response.json()"
45+
]
46+
},
47+
{
48+
"cell_type": "markdown",
49+
"metadata": {},
1950
"source": [
20-
"from langchain.prompts.chat import (\n",
21-
" HumanMessagePromptTemplate,\n",
22-
" SystemMessagePromptTemplate,\n",
23-
")"
51+
"You can also interact with this via the RemoteRunnable interface (to use in other chains)"
2452
]
2553
},
2654
{
@@ -155,7 +183,7 @@
155183
"name": "python",
156184
"nbconvert_exporter": "python",
157185
"pygments_lexer": "ipython3",
158-
"version": "3.11.4"
186+
"version": "3.10.1"
159187
}
160188
},
161189
"nbformat": 4,

examples/conversational_retrieval_chain/client.ipynb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,45 @@
99
"Demo of a client interacting with a remote conversational retrieval chain. "
1010
]
1111
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"You can interact with this via API directly"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 2,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"data": {
26+
"text/plain": [
27+
"{'output': {'answer': 'Cats like fish.'}}"
28+
]
29+
},
30+
"execution_count": 2,
31+
"metadata": {},
32+
"output_type": "execute_result"
33+
}
34+
],
35+
"source": [
36+
"import requests\n",
37+
"\n",
38+
"inputs = {\"input\": {\"question\": \"what do cats like?\", \"chat_history\": \"\"}}\n",
39+
"response = requests.post(\"http://localhost:8000/invoke\", json=inputs)\n",
40+
"\n",
41+
"response.json()"
42+
]
43+
},
44+
{
45+
"cell_type": "markdown",
46+
"metadata": {},
47+
"source": [
48+
"You can also interact with this via the RemoteRunnable interface (to use in other chains)"
49+
]
50+
},
1251
{
1352
"cell_type": "code",
1453
"execution_count": 6,

examples/llm/client.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
"name": "python",
317317
"nbconvert_exporter": "python",
318318
"pygments_lexer": "ipython3",
319-
"version": "3.11.4"
319+
"version": "3.10.1"
320320
}
321321
},
322322
"nbformat": 4,

examples/retrieval/client.ipynb

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,48 @@
99
"Demo of a client interacting with a remote retriever. "
1010
]
1111
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"You can interact with this via API directly"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 4,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"data": {
26+
"text/plain": [
27+
"{'output': [{'page_content': 'dogs like sticks',\n",
28+
" 'metadata': {},\n",
29+
" 'type': 'Document'},\n",
30+
" {'page_content': 'cats like fish', 'metadata': {}, 'type': 'Document'}]}"
31+
]
32+
},
33+
"execution_count": 4,
34+
"metadata": {},
35+
"output_type": "execute_result"
36+
}
37+
],
38+
"source": [
39+
"import requests\n",
40+
"\n",
41+
"inputs = {\"input\": \"tree\"}\n",
42+
"response = requests.post(\"http://localhost:8000/invoke\", json=inputs)\n",
43+
"\n",
44+
"response.json()"
45+
]
46+
},
47+
{
48+
"cell_type": "markdown",
49+
"metadata": {},
50+
"source": [
51+
"You can also interact with this via the RemoteRunnable interface (to use in other chains)"
52+
]
53+
},
1254
{
1355
"cell_type": "code",
1456
"execution_count": 1,
@@ -39,8 +81,8 @@
3981
{
4082
"data": {
4183
"text/plain": [
42-
"[Document(page_content='dogs like sticks', metadata={}),\n",
43-
" Document(page_content='cats like fish', metadata={})]"
84+
"[Document(page_content='dogs like sticks'),\n",
85+
" Document(page_content='cats like fish')]"
4486
]
4587
},
4688
"execution_count": 2,
@@ -182,7 +224,7 @@
182224
"name": "python",
183225
"nbconvert_exporter": "python",
184226
"pygments_lexer": "ipython3",
185-
"version": "3.11.4"
227+
"version": "3.10.1"
186228
}
187229
},
188230
"nbformat": 4,

0 commit comments

Comments
 (0)