Skip to content

Commit 54f1da1

Browse files
committed
히스토리 출력 추가
1 parent 55a4555 commit 54f1da1

File tree

1 file changed

+242
-11
lines changed

1 file changed

+242
-11
lines changed

5_gemini/function_calling.ipynb

Lines changed: 242 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"colab": {
4242
"base_uri": "https://localhost:8080/"
4343
},
44-
"outputId": "24f86463-cf9c-40b9-e3b2-aa17605e614f"
44+
"outputId": "c1930ada-fc83-46a0-c0a4-3fa1431365da"
4545
},
4646
"outputs": [
4747
{
@@ -68,7 +68,7 @@
6868
"Requirement already satisfied: uritemplate<5,>=3.0.1 in /usr/local/lib/python3.10/dist-packages (from google-api-python-client->google-generativeai==0.8.3) (4.1.1)\n",
6969
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic->google-generativeai==0.8.3) (0.7.0)\n",
7070
"Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic->google-generativeai==0.8.3) (2.23.4)\n",
71-
"Requirement already satisfied: grpcio<2.0dev,>=1.33.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.1->google-ai-generativelanguage==0.6.10->google-generativeai==0.8.3) (1.67.1)\n",
71+
"Requirement already satisfied: grpcio<2.0dev,>=1.33.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.1->google-ai-generativelanguage==0.6.10->google-generativeai==0.8.3) (1.68.0)\n",
7272
"Requirement already satisfied: grpcio-status<2.0.dev0,>=1.33.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.1->google-ai-generativelanguage==0.6.10->google-generativeai==0.8.3) (1.62.3)\n",
7373
"Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in /usr/local/lib/python3.10/dist-packages (from httplib2<1.dev0,>=0.19.0->google-api-python-client->google-generativeai==0.8.3) (3.2.0)\n",
7474
"Requirement already satisfied: pyasn1<0.7.0,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from pyasn1-modules>=0.2.1->google-auth>=2.15.0->google-generativeai==0.8.3) (0.6.1)\n",
@@ -131,7 +131,7 @@
131131
"height": 35
132132
},
133133
"id": "h1axPuPBT-Qe",
134-
"outputId": "5119e099-537d-4985-904f-2f65affa5709"
134+
"outputId": "7a849b7e-ec85-41e8-a0d5-acd82a40c830"
135135
},
136136
"execution_count": null,
137137
"outputs": [
@@ -259,10 +259,37 @@
259259
"print(response.candidates[0].content)\n"
260260
],
261261
"metadata": {
262-
"id": "cnmpoFy8UonY"
262+
"id": "cnmpoFy8UonY",
263+
"colab": {
264+
"base_uri": "https://localhost:8080/",
265+
"height": 292
266+
},
267+
"outputId": "f6d726bd-6b1c-4e78-e6bb-5670cc056a8c"
263268
},
264269
"execution_count": null,
265-
"outputs": []
270+
"outputs": [
271+
{
272+
"output_type": "stream",
273+
"name": "stdout",
274+
"text": [
275+
"parts {\n",
276+
" function_call {\n",
277+
" name: \"is_product_available\"\n",
278+
" args {\n",
279+
" fields {\n",
280+
" key: \"product_name\"\n",
281+
" value {\n",
282+
" string_value: \"갤럭시 S24\"\n",
283+
" }\n",
284+
" }\n",
285+
" }\n",
286+
" }\n",
287+
"}\n",
288+
"role: \"model\"\n",
289+
"\n"
290+
]
291+
}
292+
]
266293
},
267294
{
268295
"cell_type": "code",
@@ -277,10 +304,23 @@
277304
" print(f\"{function_name} result=>: {function_result}\")\n"
278305
],
279306
"metadata": {
280-
"id": "9ek0jsseV6pW"
307+
"id": "9ek0jsseV6pW",
308+
"colab": {
309+
"base_uri": "https://localhost:8080/"
310+
},
311+
"outputId": "10f53e75-556a-4a42-9458-1716a4b6e50a"
281312
},
282313
"execution_count": null,
283-
"outputs": []
314+
"outputs": [
315+
{
316+
"output_type": "stream",
317+
"name": "stdout",
318+
"text": [
319+
"is_product_available args=>: {'product_name': '갤럭시 S24'}\n",
320+
"is_product_available result=>: True\n"
321+
]
322+
}
323+
]
284324
},
285325
{
286326
"cell_type": "code",
@@ -302,10 +342,40 @@
302342
"print(response.candidates[0].content)\n"
303343
],
304344
"metadata": {
305-
"id": "5OKO0SSAV_-f"
345+
"id": "5OKO0SSAV_-f",
346+
"colab": {
347+
"base_uri": "https://localhost:8080/",
348+
"height": 347
349+
},
350+
"outputId": "84b9795c-f562-45cc-90b8-8fae9ecb2cb2"
306351
},
307352
"execution_count": null,
308-
"outputs": []
353+
"outputs": [
354+
{
355+
"output_type": "stream",
356+
"name": "stdout",
357+
"text": [
358+
"function_response {\n",
359+
" name: \"is_product_available\"\n",
360+
" response {\n",
361+
" fields {\n",
362+
" key: \"content\"\n",
363+
" value {\n",
364+
" bool_value: true\n",
365+
" }\n",
366+
" }\n",
367+
" }\n",
368+
"}\n",
369+
"\n",
370+
"--------------------------------------------------\n",
371+
"parts {\n",
372+
" text: \"네, 갤럭시 S24 판매 중입니다.\"\n",
373+
"}\n",
374+
"role: \"model\"\n",
375+
"\n"
376+
]
377+
}
378+
]
309379
},
310380
{
311381
"cell_type": "code",
@@ -423,10 +493,171 @@
423493
" print(f\"모델: {response.candidates[0].content.parts[0].text}\")"
424494
],
425495
"metadata": {
426-
"id": "xpMxzWSinhyL"
496+
"id": "xpMxzWSinhyL",
497+
"colab": {
498+
"base_uri": "https://localhost:8080/",
499+
"height": 219
500+
},
501+
"outputId": "ee34a126-8192-42d4-96f9-0dc73851fb6d"
427502
},
428503
"execution_count": null,
429-
"outputs": []
504+
"outputs": [
505+
{
506+
"output_type": "stream",
507+
"name": "stdout",
508+
"text": [
509+
"\n",
510+
"사용자: 갤럭시 S24 판매 중인가요?\n",
511+
"모델: 네, 갤럭시 S24 판매 중입니다.\n",
512+
"\n",
513+
"사용자: 가격은 어떻게 되나요?\n",
514+
"모델: 갤럭시 S24 가격은 1,700,000원 입니다.\n",
515+
"\n",
516+
"\n",
517+
"사용자: 서울시 종로구 종로1가 1번지로 배송부탁드립니다\n",
518+
"모델: 주문이 완료되었습니다. 서울시 종로구 종로1가 1번지로 갤럭시 S24를 배송해 드리겠습니다.\n",
519+
"\n"
520+
]
521+
}
522+
]
523+
},
524+
{
525+
"cell_type": "code",
526+
"source": [
527+
"print(f\"history:\\n{chat_session.history}\")"
528+
],
529+
"metadata": {
530+
"id": "7WVfff1SDvhX",
531+
"outputId": "babf8adc-1cee-4e49-ab6a-ed139a744788",
532+
"colab": {
533+
"base_uri": "https://localhost:8080/"
534+
}
535+
},
536+
"execution_count": null,
537+
"outputs": [
538+
{
539+
"output_type": "stream",
540+
"name": "stdout",
541+
"text": [
542+
"history:\n",
543+
"[parts {\n",
544+
" text: \"갤럭시 S24 판매 중인가요?\"\n",
545+
"}\n",
546+
"role: \"user\"\n",
547+
", parts {\n",
548+
" function_call {\n",
549+
" name: \"is_product_available\"\n",
550+
" args {\n",
551+
" fields {\n",
552+
" key: \"product_name\"\n",
553+
" value {\n",
554+
" string_value: \"갤럭시 S24\"\n",
555+
" }\n",
556+
" }\n",
557+
" }\n",
558+
" }\n",
559+
"}\n",
560+
"role: \"model\"\n",
561+
", parts {\n",
562+
" function_response {\n",
563+
" name: \"is_product_available\"\n",
564+
" response {\n",
565+
" fields {\n",
566+
" key: \"content\"\n",
567+
" value {\n",
568+
" bool_value: true\n",
569+
" }\n",
570+
" }\n",
571+
" }\n",
572+
" }\n",
573+
"}\n",
574+
"role: \"user\"\n",
575+
", parts {\n",
576+
" text: \"네, 갤럭시 S24 판매 중입니다.\"\n",
577+
"}\n",
578+
"role: \"model\"\n",
579+
", parts {\n",
580+
" text: \"가격은 어떻게 되나요?\"\n",
581+
"}\n",
582+
"role: \"user\"\n",
583+
", parts {\n",
584+
" function_call {\n",
585+
" name: \"get_product_price\"\n",
586+
" args {\n",
587+
" fields {\n",
588+
" key: \"product_name\"\n",
589+
" value {\n",
590+
" string_value: \"갤럭시 S24\"\n",
591+
" }\n",
592+
" }\n",
593+
" }\n",
594+
" }\n",
595+
"}\n",
596+
"role: \"model\"\n",
597+
", parts {\n",
598+
" function_response {\n",
599+
" name: \"get_product_price\"\n",
600+
" response {\n",
601+
" fields {\n",
602+
" key: \"content\"\n",
603+
" value {\n",
604+
" number_value: 1700000\n",
605+
" }\n",
606+
" }\n",
607+
" }\n",
608+
" }\n",
609+
"}\n",
610+
"role: \"user\"\n",
611+
", parts {\n",
612+
" text: \"갤럭시 S24 가격은 1,700,000원 입니다.\\n\"\n",
613+
"}\n",
614+
"role: \"model\"\n",
615+
", parts {\n",
616+
" text: \"서울시 종로구 종로1가 1번지로 배송부탁드립니다\"\n",
617+
"}\n",
618+
"role: \"user\"\n",
619+
", parts {\n",
620+
" function_call {\n",
621+
" name: \"place_order\"\n",
622+
" args {\n",
623+
" fields {\n",
624+
" key: \"product_name\"\n",
625+
" value {\n",
626+
" string_value: \"갤럭시 S24\"\n",
627+
" }\n",
628+
" }\n",
629+
" fields {\n",
630+
" key: \"address\"\n",
631+
" value {\n",
632+
" string_value: \"서울시 종로구 종로1가 1번지\"\n",
633+
" }\n",
634+
" }\n",
635+
" }\n",
636+
" }\n",
637+
"}\n",
638+
"role: \"model\"\n",
639+
", parts {\n",
640+
" function_response {\n",
641+
" name: \"place_order\"\n",
642+
" response {\n",
643+
" fields {\n",
644+
" key: \"content\"\n",
645+
" value {\n",
646+
" string_value: \"주문 완료\"\n",
647+
" }\n",
648+
" }\n",
649+
" }\n",
650+
" }\n",
651+
"}\n",
652+
"role: \"user\"\n",
653+
", parts {\n",
654+
" text: \"주문이 완료되었습니다. 서울시 종로구 종로1가 1번지로 갤럭시 S24를 배송해 드리겠습니다.\\n\"\n",
655+
"}\n",
656+
"role: \"model\"\n",
657+
"]\n"
658+
]
659+
}
660+
]
430661
}
431662
]
432663
}

0 commit comments

Comments
 (0)