Skip to content

Commit af72f95

Browse files
committed
bot.py fixes
1 parent b1c9188 commit af72f95

8 files changed

+425
-283
lines changed

10-API-Search.ipynb

+45-31
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
{
3131
"cell_type": "code",
32-
"execution_count": 2,
32+
"execution_count": 1,
3333
"id": "c1fb79a3-4856-4721-988c-112813690a90",
3434
"metadata": {},
3535
"outputs": [],
@@ -64,7 +64,7 @@
6464
},
6565
{
6666
"cell_type": "code",
67-
"execution_count": 3,
67+
"execution_count": 2,
6868
"id": "258a6e99-2d4f-4147-b8ee-c64c85296181",
6969
"metadata": {},
7070
"outputs": [],
@@ -75,7 +75,7 @@
7575
},
7676
{
7777
"cell_type": "code",
78-
"execution_count": 4,
78+
"execution_count": 3,
7979
"id": "9d3daf03-77e2-466e-a255-2f06bee3561b",
8080
"metadata": {},
8181
"outputs": [],
@@ -85,6 +85,8 @@
8585
"\n",
8686
"COMPLETION_TOKENS = 2000\n",
8787
"\n",
88+
"\n",
89+
"# This notebook needs GPT-4-Turbo (context size of 128k tokens)\n",
8890
"llm = AzureChatOpenAI(deployment_name=os.environ[\"GPT4_DEPLOYMENT_NAME\"], \n",
8991
" temperature=0.5, max_tokens=COMPLETION_TOKENS, \n",
9092
" streaming=True, callback_manager=cb_manager)"
@@ -137,7 +139,7 @@
137139
},
138140
{
139141
"cell_type": "code",
140-
"execution_count": 9,
142+
"execution_count": 4,
141143
"id": "8efd8698-aea1-4de3-b810-e9c4782f04c4",
142144
"metadata": {},
143145
"outputs": [],
@@ -163,7 +165,7 @@
163165
},
164166
{
165167
"cell_type": "code",
166-
"execution_count": 10,
168+
"execution_count": 5,
167169
"id": "94503afc-c398-458a-b369-610c5dbe682d",
168170
"metadata": {},
169171
"outputs": [],
@@ -174,7 +176,7 @@
174176
},
175177
{
176178
"cell_type": "code",
177-
"execution_count": 11,
179+
"execution_count": 6,
178180
"id": "57d77e9b-6f3f-4ec4-bc01-baac18984937",
179181
"metadata": {},
180182
"outputs": [
@@ -202,6 +204,14 @@
202204
"Sometimes it makes sense to reduce the size of the API Specs by using the `reduce_openapi_spec` function. It's optional."
203205
]
204206
},
207+
{
208+
"cell_type": "markdown",
209+
"id": "cd8c3b3e-959e-4b19-b34d-66de3501b1b1",
210+
"metadata": {},
211+
"source": [
212+
"#### NOTE: As you can see, a large context LLM is needed. `GPT4-turbo` is necessary for this notebook to run succesfully."
213+
]
214+
},
205215
{
206216
"cell_type": "markdown",
207217
"id": "9a945386-39eb-405d-9310-3b67c9af77bb",
@@ -213,7 +223,7 @@
213223
},
214224
{
215225
"cell_type": "code",
216-
"execution_count": 21,
226+
"execution_count": 7,
217227
"id": "d020b5de-7ebe-4fb9-9b71-f6c71956149d",
218228
"metadata": {},
219229
"outputs": [],
@@ -242,7 +252,7 @@
242252
},
243253
{
244254
"cell_type": "code",
245-
"execution_count": 13,
255+
"execution_count": 8,
246256
"id": "96731b5f-988b-49ec-a5c3-3a344b7085da",
247257
"metadata": {},
248258
"outputs": [],
@@ -253,17 +263,9 @@
253263
"requests_wrapper = RequestsWrapper(headers=headers)"
254264
]
255265
},
256-
{
257-
"cell_type": "markdown",
258-
"id": "1fd6a140-f675-40db-98ad-b5c955a4f7b6",
259-
"metadata": {},
260-
"source": [
261-
"**Note**: Notice that we are using GPT-3.5 (llm_2) below for this chain since it doesn't need too many instructions or reasoning"
262-
]
263-
},
264266
{
265267
"cell_type": "code",
266-
"execution_count": 14,
268+
"execution_count": 9,
267269
"id": "426fab6f-ea04-4c07-8211-d9cc5c70ac8e",
268270
"metadata": {},
269271
"outputs": [],
@@ -283,12 +285,12 @@
283285
"id": "1707e590-809b-4391-bdcd-c7d285ec8fb1",
284286
"metadata": {},
285287
"source": [
286-
"These are the prompts on the APIChain class (on to create the URL endpoint and the other one to use it and get the answer):"
288+
"These are the prompts on the APIChain class (one to create the URL endpoint and the other one to use it and get the answer):"
287289
]
288290
},
289291
{
290292
"cell_type": "code",
291-
"execution_count": 15,
293+
"execution_count": 10,
292294
"id": "9f80d2bb-e285-4d30-88c8-5677e86cebe2",
293295
"metadata": {},
294296
"outputs": [
@@ -298,7 +300,7 @@
298300
"'You are given the below API Documentation:\\n{api_docs}\\nUsing this documentation, generate the full API url to call for answering the user question.\\nYou should build the API url in order to get a response that is as short as possible, while still getting the necessary information to answer the question. Pay attention to deliberately exclude any unnecessary pieces of data in the API call.\\n\\nQuestion:{question}\\nAPI url:'"
299301
]
300302
},
301-
"execution_count": 15,
303+
"execution_count": 10,
302304
"metadata": {},
303305
"output_type": "execute_result"
304306
}
@@ -309,7 +311,7 @@
309311
},
310312
{
311313
"cell_type": "code",
312-
"execution_count": 16,
314+
"execution_count": 11,
313315
"id": "ccc7e9dc-f36b-45e1-867a-1b92d639e941",
314316
"metadata": {},
315317
"outputs": [
@@ -319,7 +321,7 @@
319321
"'You are given the below API Documentation:\\n{api_docs}\\nUsing this documentation, generate the full API url to call for answering the user question.\\nYou should build the API url in order to get a response that is as short as possible, while still getting the necessary information to answer the question. Pay attention to deliberately exclude any unnecessary pieces of data in the API call.\\n\\nQuestion:{question}\\nAPI url: {api_url}\\n\\nHere is the response from the API:\\n\\n{api_response}\\n\\nSummarize this response to answer the original question.\\n\\nSummary:'"
320322
]
321323
},
322-
"execution_count": 16,
324+
"execution_count": 11,
323325
"metadata": {},
324326
"output_type": "execute_result"
325327
}
@@ -330,26 +332,38 @@
330332
},
331333
{
332334
"cell_type": "code",
333-
"execution_count": 17,
335+
"execution_count": 12,
334336
"id": "d7f60335-5551-4ee0-ba4e-1cd84f3a9f48",
335337
"metadata": {},
336338
"outputs": [
337339
{
338340
"name": "stdout",
339341
"output_type": "stream",
340342
"text": [
341-
"To answer the user's question, we need to make three separate API calls to get the price of Bitcoin against USD, the latest OHLC values for Ethereum, and the bid and ask for Euro. Here are the API URLs for the required information:\n",
343+
"To get the price of Bitcoin against USD, we will use the `Ticker` endpoint. The `pair` parameter should specify `XXBTZUSD` which is the pair for Bitcoin against USD.\n",
344+
"\n",
345+
"For the latest OHLC values for Ethereum, we will use the `OHLC` endpoint. The `pair` parameter should specify `XETHZUSD` which is the pair for Ethereum against USD.\n",
342346
"\n",
343-
"1. Price of Bitcoin against USD:\n",
344-
" `GET https://api.kraken.com/0/public/Ticker?pair=XBTUSD`\n",
347+
"For the bid and ask for Euro, we will use the `Ticker` endpoint again. The `pair` parameter should specify `ZEURZUSD` which is the pair for Euro against USD.\n",
345348
"\n",
346-
"2. Latest OHLC values for Ethereum:\n",
347-
" `GET https://api.kraken.com/0/public/OHLC?pair=ETHUSD`\n",
349+
"Since we want to make the response as short as possible, we will only include the necessary pairs in the `pair` parameter for each call.\n",
348350
"\n",
349-
"3. Bid and ask for Euro:\n",
350-
" `GET https://api.kraken.com/0/public/Ticker?pair=EURUSD`\n",
351+
"API url for Bitcoin price against USD (Ticker):\n",
352+
"```\n",
353+
"https://api.kraken.com/0/public/Ticker?pair=XXBTZUSD\n",
354+
"```\n",
355+
"\n",
356+
"API url for the latest OHLC values for Ethereum (OHLC):\n",
357+
"```\n",
358+
"https://api.kraken.com/0/public/OHLC?pair=XETHZUSD&interval=1\n",
359+
"```\n",
360+
"\n",
361+
"API url for the bid and ask for Euro (Ticker):\n",
362+
"```\n",
363+
"https://api.kraken.com/0/public/Ticker?pair=ZEURZUSD\n",
364+
"```\n",
351365
"\n",
352-
"Please note that the pair names (`XBTUSD`, `ETHUSD`, and `EURUSD`) are based on the common naming convention used by Kraken and may need to be adjusted if Kraken uses different identifiers for these pairs."
366+
"Please note that these URLs should be used with a `GET` request."
353367
]
354368
}
355369
],

0 commit comments

Comments
 (0)