Skip to content

Commit e225c1a

Browse files
author
Amanda Foster
committed
minor clean-up changes
1 parent aa4f0ba commit e225c1a

File tree

2 files changed

+36
-37
lines changed

2 files changed

+36
-37
lines changed

Basic_Samples/Functions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Introduction
2-
This repository contains samples demonstrating how to use functions to extend the current capabilities of GPT Models
2+
This repository contains samples demonstrating how to use functions to extend the current capabilities of GPT Models.
33

44
## Installation
55
Install all Python modules and packages listed in the requirements.txt file using the below command.
@@ -9,7 +9,7 @@ pip install -r requirements.txt
99
```
1010

1111
### Microsoft Azure Endpoints
12-
In order to use the Open AI library or REST API with Microsoft Azure endpoints, you need to set DEPLOYMENT_NAME, OPENAI_API_BASE & OPENAI_API_VERSION in _config.json_ file.
12+
In order to use the Open AI library or REST API with Microsoft Azure endpoints, you need to set DEPLOYMENT_ID, OPENAI_API_BASE & OPENAI_API_VERSION in _config.json_ file.
1313

1414
```js
1515
{

Basic_Samples/Functions/working_with_functions.ipynb

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
{
2525
"cell_type": "code",
26-
"execution_count": 99,
26+
"execution_count": 1,
2727
"metadata": {},
2828
"outputs": [],
2929
"source": [
@@ -33,7 +33,7 @@
3333
},
3434
{
3535
"cell_type": "code",
36-
"execution_count": 100,
36+
"execution_count": 17,
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
@@ -73,7 +73,7 @@
7373
},
7474
{
7575
"cell_type": "code",
76-
"execution_count": 101,
76+
"execution_count": 18,
7777
"metadata": {},
7878
"outputs": [],
7979
"source": [
@@ -118,7 +118,7 @@
118118
},
119119
{
120120
"cell_type": "code",
121-
"execution_count": 102,
121+
"execution_count": 19,
122122
"metadata": {},
123123
"outputs": [
124124
{
@@ -127,9 +127,9 @@
127127
"text": [
128128
"Let the model decide what function to call:\n",
129129
"{\n",
130-
" \"id\": \"chatcmpl-7e9QCkcvCtXbyiZwm3eKVHHQ2waXE\",\n",
130+
" \"id\": \"chatcmpl-7e9d5AFNbVuiil0l0IWCKSX0luNPV\",\n",
131131
" \"object\": \"chat.completion\",\n",
132-
" \"created\": 1689803692,\n",
132+
" \"created\": 1689804491,\n",
133133
" \"model\": \"gpt-4\",\n",
134134
" \"prompt_annotations\": [\n",
135135
" {\n",
@@ -176,9 +176,9 @@
176176
"}\n",
177177
"Don't call any function:\n",
178178
"{\n",
179-
" \"id\": \"chatcmpl-7e9QDkseJ33uGMacx6X4MEmS12BuT\",\n",
179+
" \"id\": \"chatcmpl-7e9d6AQAqykfQ8cnGlrkJM5zEZGSl\",\n",
180180
" \"object\": \"chat.completion\",\n",
181-
" \"created\": 1689803693,\n",
181+
" \"created\": 1689804492,\n",
182182
" \"model\": \"gpt-4\",\n",
183183
" \"prompt_annotations\": [\n",
184184
" {\n",
@@ -209,7 +209,7 @@
209209
" \"finish_reason\": \"stop\",\n",
210210
" \"message\": {\n",
211211
" \"role\": \"assistant\",\n",
212-
" \"content\": \"Sure, let me just find that information for you.\"\n",
212+
" \"content\": \"Sure, let me check that for you.\\n\\nI am using the function `get_current_weather` for this purpose.\"\n",
213213
" },\n",
214214
" \"content_filter_results\": {\n",
215215
" \"hate\": {\n",
@@ -232,16 +232,16 @@
232232
" }\n",
233233
" ],\n",
234234
" \"usage\": {\n",
235-
" \"completion_tokens\": 11,\n",
235+
" \"completion_tokens\": 23,\n",
236236
" \"prompt_tokens\": 84,\n",
237-
" \"total_tokens\": 95\n",
237+
" \"total_tokens\": 107\n",
238238
" }\n",
239239
"}\n",
240240
"Force a specific function call:\n",
241241
"{\n",
242-
" \"id\": \"chatcmpl-7e9QEsAAhn44pwg7ty9osRltgwXPb\",\n",
242+
" \"id\": \"chatcmpl-7e9d7bOcTyEe3mA9rBhAPflFEqYX3\",\n",
243243
" \"object\": \"chat.completion\",\n",
244-
" \"created\": 1689803694,\n",
244+
" \"created\": 1689804493,\n",
245245
" \"model\": \"gpt-4\",\n",
246246
" \"prompt_annotations\": [\n",
247247
" {\n",
@@ -274,16 +274,16 @@
274274
" \"role\": \"assistant\",\n",
275275
" \"function_call\": {\n",
276276
" \"name\": \"get_current_weather\",\n",
277-
" \"arguments\": \"{\\n \\\"location\\\": \\\"San Francisco\\\"\\n}\"\n",
277+
" \"arguments\": \"{\\n \\\"location\\\": \\\"San Francisco, CA\\\"\\n}\"\n",
278278
" }\n",
279279
" },\n",
280280
" \"content_filter_results\": {}\n",
281281
" }\n",
282282
" ],\n",
283283
" \"usage\": {\n",
284-
" \"completion_tokens\": 10,\n",
284+
" \"completion_tokens\": 12,\n",
285285
" \"prompt_tokens\": 90,\n",
286-
" \"total_tokens\": 100\n",
286+
" \"total_tokens\": 102\n",
287287
" }\n",
288288
"}\n"
289289
]
@@ -295,7 +295,6 @@
295295
"print(\"Let the model decide what function to call:\")\n",
296296
"print (get_function_call(first_message, \"auto\"))\n",
297297
"\n",
298-
"\n",
299298
"# 'none' : Don't call any function \n",
300299
"print(\"Don't call any function:\")\n",
301300
"print (get_function_call(first_message, \"none\"))\n",
@@ -324,7 +323,7 @@
324323
},
325324
{
326325
"cell_type": "code",
327-
"execution_count": 103,
326+
"execution_count": 20,
328327
"metadata": {},
329328
"outputs": [],
330329
"source": [
@@ -347,16 +346,16 @@
347346
},
348347
{
349348
"cell_type": "code",
350-
"execution_count": 104,
349+
"execution_count": 6,
351350
"metadata": {},
352351
"outputs": [
353352
{
354353
"data": {
355354
"text/plain": [
356-
"'05:54:54 PM'"
355+
"'06:07:59 PM'"
357356
]
358357
},
359-
"execution_count": 104,
358+
"execution_count": 6,
360359
"metadata": {},
361360
"output_type": "execute_result"
362361
}
@@ -375,7 +374,7 @@
375374
},
376375
{
377376
"cell_type": "code",
378-
"execution_count": 105,
377+
"execution_count": 7,
379378
"metadata": {},
380379
"outputs": [],
381380
"source": [
@@ -408,7 +407,7 @@
408407
},
409408
{
410409
"cell_type": "code",
411-
"execution_count": 106,
410+
"execution_count": 8,
412411
"metadata": {},
413412
"outputs": [
414413
{
@@ -432,7 +431,7 @@
432431
},
433432
{
434433
"cell_type": "code",
435-
"execution_count": 107,
434+
"execution_count": 9,
436435
"metadata": {},
437436
"outputs": [],
438437
"source": [
@@ -457,7 +456,7 @@
457456
},
458457
{
459458
"cell_type": "code",
460-
"execution_count": 115,
459+
"execution_count": 10,
461460
"metadata": {},
462461
"outputs": [
463462
{
@@ -477,7 +476,7 @@
477476
"cell_type": "markdown",
478477
"metadata": {},
479478
"source": [
480-
"## 3.0 Calling a Function using GPT\n",
479+
"## 3.0 Calling a function using GPT\n",
481480
"\n",
482481
"Steps for Function Calling: \n",
483482
"\n",
@@ -491,7 +490,7 @@
491490
},
492491
{
493492
"cell_type": "code",
494-
"execution_count": 116,
493+
"execution_count": 11,
495494
"metadata": {},
496495
"outputs": [],
497496
"source": [
@@ -555,7 +554,7 @@
555554
},
556555
{
557556
"cell_type": "code",
558-
"execution_count": 117,
557+
"execution_count": 12,
559558
"metadata": {},
560559
"outputs": [],
561560
"source": [
@@ -580,7 +579,7 @@
580579
},
581580
{
582581
"cell_type": "code",
583-
"execution_count": 118,
582+
"execution_count": 13,
584583
"metadata": {},
585584
"outputs": [],
586585
"source": [
@@ -657,7 +656,7 @@
657656
},
658657
{
659658
"cell_type": "code",
660-
"execution_count": 119,
659+
"execution_count": 14,
661660
"metadata": {},
662661
"outputs": [
663662
{
@@ -671,16 +670,16 @@
671670
"}\n",
672671
"\n",
673672
"Output of function call:\n",
674-
"05:55:08 PM\n",
673+
"06:08:07 PM\n",
675674
"\n",
676675
"Messages in second request:\n",
677676
"{'role': 'user', 'content': 'What time is it in New York?'}\n",
678677
"{'role': 'assistant', 'name': 'get_current_time', 'content': '{\\n \"location\": \"America/New_York\"\\n}'}\n",
679-
"{'role': 'function', 'name': 'get_current_time', 'content': '05:55:08 PM'}\n",
678+
"{'role': 'function', 'name': 'get_current_time', 'content': '06:08:07 PM'}\n",
680679
"\n",
681680
"{\n",
682681
" \"role\": \"assistant\",\n",
683-
" \"content\": \"The current time in New York is 05:55:08 PM.\"\n",
682+
" \"content\": \"The current time in New York is 06:08 PM.\"\n",
684683
"}\n"
685684
]
686685
}
@@ -701,7 +700,7 @@
701700
},
702701
{
703702
"cell_type": "code",
704-
"execution_count": 120,
703+
"execution_count": 15,
705704
"metadata": {},
706705
"outputs": [],
707706
"source": [
@@ -781,7 +780,7 @@
781780
},
782781
{
783782
"cell_type": "code",
784-
"execution_count": 121,
783+
"execution_count": 16,
785784
"metadata": {},
786785
"outputs": [
787786
{

0 commit comments

Comments
 (0)