|
22 | 22 | }, |
23 | 23 | { |
24 | 24 | "cell_type": "code", |
25 | | - "execution_count": 3, |
| 25 | + "execution_count": null, |
26 | 26 | "metadata": { |
27 | 27 | "colab": { |
28 | 28 | "base_uri": "https://localhost:8080/" |
29 | 29 | }, |
30 | 30 | "id": "kply8eYngIAL", |
31 | 31 | "outputId": "d303bfa2-ce7e-4211-d425-1f618141a293" |
32 | 32 | }, |
33 | | - "outputs": [ |
34 | | - { |
35 | | - "name": "stdout", |
36 | | - "output_type": "stream", |
37 | | - "text": [ |
38 | | - "Requirement already satisfied: elasticsearch in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (8.17.1)\n", |
39 | | - "Collecting openai\n", |
40 | | - " Downloading openai-1.63.2-py3-none-any.whl.metadata (27 kB)\n", |
41 | | - "Requirement already satisfied: elastic-transport<9,>=8.15.1 in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from elasticsearch) (8.17.0)\n", |
42 | | - "Requirement already satisfied: anyio<5,>=3.5.0 in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from openai) (4.6.2.post1)\n", |
43 | | - "Collecting distro<2,>=1.7.0 (from openai)\n", |
44 | | - " Using cached distro-1.9.0-py3-none-any.whl.metadata (6.8 kB)\n", |
45 | | - "Requirement already satisfied: httpx<1,>=0.23.0 in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from openai) (0.27.2)\n", |
46 | | - "Collecting jiter<1,>=0.4.0 (from openai)\n", |
47 | | - " Downloading jiter-0.8.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (5.2 kB)\n", |
48 | | - "Collecting pydantic<3,>=1.9.0 (from openai)\n", |
49 | | - " Downloading pydantic-2.10.6-py3-none-any.whl.metadata (30 kB)\n", |
50 | | - "Requirement already satisfied: sniffio in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from openai) (1.3.1)\n", |
51 | | - "Requirement already satisfied: tqdm>4 in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from openai) (4.66.5)\n", |
52 | | - "Requirement already satisfied: typing-extensions<5,>=4.11 in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from openai) (4.12.2)\n", |
53 | | - "Requirement already satisfied: idna>=2.8 in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n", |
54 | | - "Requirement already satisfied: urllib3<3,>=1.26.2 in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from elastic-transport<9,>=8.15.1->elasticsearch) (2.2.3)\n", |
55 | | - "Requirement already satisfied: certifi in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from elastic-transport<9,>=8.15.1->elasticsearch) (2024.8.30)\n", |
56 | | - "Requirement already satisfied: httpcore==1.* in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n", |
57 | | - "Requirement already satisfied: h11<0.15,>=0.13 in /Users/sunilemanjee/Documents/GitHub/elasticsearch-labs/.venv/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n", |
58 | | - "Collecting annotated-types>=0.6.0 (from pydantic<3,>=1.9.0->openai)\n", |
59 | | - " Using cached annotated_types-0.7.0-py3-none-any.whl.metadata (15 kB)\n", |
60 | | - "Collecting pydantic-core==2.27.2 (from pydantic<3,>=1.9.0->openai)\n", |
61 | | - " Downloading pydantic_core-2.27.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (6.6 kB)\n", |
62 | | - "Downloading openai-1.63.2-py3-none-any.whl (472 kB)\n", |
63 | | - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m472.3/472.3 kB\u001b[0m \u001b[31m11.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n", |
64 | | - "\u001b[?25hUsing cached distro-1.9.0-py3-none-any.whl (20 kB)\n", |
65 | | - "Downloading jiter-0.8.2-cp312-cp312-macosx_11_0_arm64.whl (310 kB)\n", |
66 | | - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m310.3/310.3 kB\u001b[0m \u001b[31m25.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", |
67 | | - "\u001b[?25hDownloading pydantic-2.10.6-py3-none-any.whl (431 kB)\n", |
68 | | - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m431.7/431.7 kB\u001b[0m \u001b[31m29.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", |
69 | | - "\u001b[?25hDownloading pydantic_core-2.27.2-cp312-cp312-macosx_11_0_arm64.whl (1.8 MB)\n", |
70 | | - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m33.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", |
71 | | - "\u001b[?25hUsing cached annotated_types-0.7.0-py3-none-any.whl (13 kB)\n", |
72 | | - "Installing collected packages: pydantic-core, jiter, distro, annotated-types, pydantic, openai\n", |
73 | | - "Successfully installed annotated-types-0.7.0 distro-1.9.0 jiter-0.8.2 openai-1.63.2 pydantic-2.10.6 pydantic-core-2.27.2\n", |
74 | | - "\n", |
75 | | - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.0.1\u001b[0m\n", |
76 | | - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" |
77 | | - ] |
78 | | - } |
79 | | - ], |
| 33 | + "outputs": [], |
80 | 34 | "source": [ |
81 | 35 | "!pip install elasticsearch openai" |
82 | 36 | ] |
83 | 37 | }, |
84 | 38 | { |
85 | 39 | "cell_type": "code", |
86 | | - "execution_count": 5, |
| 40 | + "execution_count": null, |
87 | 41 | "metadata": { |
88 | 42 | "id": "wcPv-D6lwHsk" |
89 | 43 | }, |
|
121 | 75 | }, |
122 | 76 | { |
123 | 77 | "cell_type": "code", |
124 | | - "execution_count": 29, |
| 78 | + "execution_count": null, |
125 | 79 | "metadata": { |
126 | 80 | "colab": { |
127 | 81 | "base_uri": "https://localhost:8080/" |
128 | 82 | }, |
129 | 83 | "id": "U7bQisDzgThO", |
130 | 84 | "outputId": "8271b49f-7860-4429-9606-4914eeb7e935" |
131 | 85 | }, |
132 | | - "outputs": [ |
133 | | - { |
134 | | - "name": "stderr", |
135 | | - "output_type": "stream", |
136 | | - "text": [ |
137 | | - "<ipython-input-29-39a59176fe0b>:1: DeprecationWarning: The 'timeout' parameter is deprecated in favor of 'request_timeout'\n", |
138 | | - " es = Elasticsearch(\n" |
139 | | - ] |
140 | | - }, |
141 | | - { |
142 | | - "data": { |
143 | | - "text/plain": [ |
144 | | - "ObjectApiResponse({'name': 'instance-0000000001', 'cluster_name': 'c2ab8f2bea544fa98be6ab7deaa857f7', 'cluster_uuid': 'ymWuH36TQy-03wb-MIx27w', 'version': {'number': '8.17.2', 'build_flavor': 'default', 'build_type': 'docker', 'build_hash': '747663ddda3421467150de0e4301e8d4bc636b0c', 'build_date': '2025-02-05T22:10:57.067596412Z', 'build_snapshot': False, 'lucene_version': '9.12.0', 'minimum_wire_compatibility_version': '7.17.0', 'minimum_index_compatibility_version': '7.0.0'}, 'tagline': 'You Know, for Search'})" |
145 | | - ] |
146 | | - }, |
147 | | - "execution_count": 29, |
148 | | - "metadata": {}, |
149 | | - "output_type": "execute_result" |
150 | | - } |
151 | | - ], |
| 86 | + "outputs": [], |
152 | 87 | "source": [ |
153 | 88 | "es_cloud_id = getpass(prompt=\"Enter your Elasticsearch Cloud ID: \")\n", |
154 | 89 | "es_api_key = getpass(prompt=\"Enter your Elasticsearch API key: \")\n", |
|
169 | 104 | }, |
170 | 105 | { |
171 | 106 | "cell_type": "code", |
172 | | - "execution_count": 31, |
| 107 | + "execution_count": null, |
173 | 108 | "metadata": { |
174 | 109 | "id": "wbwpo08qzn4f" |
175 | 110 | }, |
|
217 | 152 | }, |
218 | 153 | { |
219 | 154 | "cell_type": "code", |
220 | | - "execution_count": 32, |
| 155 | + "execution_count": null, |
221 | 156 | "metadata": { |
222 | 157 | "id": "dgpGnZQbb7U_" |
223 | 158 | }, |
|
230 | 165 | }, |
231 | 166 | { |
232 | 167 | "cell_type": "code", |
233 | | - "execution_count": 33, |
| 168 | + "execution_count": null, |
234 | 169 | "metadata": { |
235 | 170 | "id": "fiVFDWOYUgvH" |
236 | 171 | }, |
|
298 | 233 | }, |
299 | 234 | { |
300 | 235 | "cell_type": "code", |
301 | | - "execution_count": 34, |
| 236 | + "execution_count": null, |
302 | 237 | "metadata": { |
303 | 238 | "id": "RMZoAAq5y0YA" |
304 | 239 | }, |
|
370 | 305 | }, |
371 | 306 | { |
372 | 307 | "cell_type": "code", |
373 | | - "execution_count": 35, |
| 308 | + "execution_count": null, |
374 | 309 | "metadata": { |
375 | 310 | "id": "H3xh9gbezHfO" |
376 | 311 | }, |
|
570 | 505 | }, |
571 | 506 | { |
572 | 507 | "cell_type": "code", |
573 | | - "execution_count": 36, |
| 508 | + "execution_count": null, |
574 | 509 | "metadata": { |
575 | 510 | "id": "L6E7DFWcTEnb" |
576 | 511 | }, |
|
811 | 746 | }, |
812 | 747 | { |
813 | 748 | "cell_type": "code", |
814 | | - "execution_count": 37, |
| 749 | + "execution_count": null, |
815 | 750 | "metadata": { |
816 | 751 | "id": "S28E_3t5PEib" |
817 | 752 | }, |
|
864 | 799 | }, |
865 | 800 | { |
866 | 801 | "cell_type": "code", |
867 | | - "execution_count": 38, |
| 802 | + "execution_count": null, |
868 | 803 | "metadata": { |
869 | 804 | "id": "tVWlVx0cNWUd" |
870 | 805 | }, |
|
944 | 879 | }, |
945 | 880 | { |
946 | 881 | "cell_type": "code", |
947 | | - "execution_count": 39, |
| 882 | + "execution_count": null, |
948 | 883 | "metadata": { |
949 | 884 | "id": "t2E7YSk-LH_J" |
950 | 885 | }, |
|
973 | 908 | }, |
974 | 909 | { |
975 | 910 | "cell_type": "code", |
976 | | - "execution_count": 40, |
| 911 | + "execution_count": null, |
977 | 912 | "metadata": { |
978 | 913 | "id": "1EXrB0KdLKH1" |
979 | 914 | }, |
|
1031 | 966 | }, |
1032 | 967 | { |
1033 | 968 | "cell_type": "code", |
1034 | | - "execution_count": 41, |
| 969 | + "execution_count": null, |
1035 | 970 | "metadata": { |
1036 | 971 | "colab": { |
1037 | 972 | "base_uri": "https://localhost:8080/" |
1038 | 973 | }, |
1039 | 974 | "id": "OyZKPEPEl4v5", |
1040 | 975 | "outputId": "2021e133-6828-4c28-d6a9-bc233092efa2" |
1041 | 976 | }, |
1042 | | - "outputs": [ |
1043 | | - { |
1044 | | - "name": "stdout", |
1045 | | - "output_type": "stream", |
1046 | | - "text": [ |
1047 | | - "\n", |
1048 | | - "Formatted Messages:\n", |
1049 | | - "Message 1:\n", |
1050 | | - "Role: assistant\n", |
1051 | | - "Tool Calls:\n", |
1052 | | - " Tool Call ID: call_MzuWSxe6HtXp3RhfHEmJ6Z85\n", |
1053 | | - " Function Name: extract_hotel_search_parameters\n", |
1054 | | - " Arguments: {\"query\":\"recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym\",\"distance\":\"250m\",\"rating\":4,\"location\":\"Belongil Beach\",\"attraction\":\"recently renovated,pool,gym\"}\n", |
1055 | | - "\n", |
1056 | | - "--------------------------------------------------\n", |
1057 | | - "Function Arguments for extract_hotel_search_parameters:\n", |
1058 | | - "{'query': 'recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym', 'distance': '250m', 'rating': 4, 'location': 'Belongil Beach', 'attraction': 'recently renovated,pool,gym'}\n", |
1059 | | - "Response from handle_extract_hotel_search_parameters:\n", |
1060 | | - "{\"query\": \"recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym\", \"distance\": \"250m\", \"rating\": 4, \"location\": \"Belongil Beach\", \"attraction\": \"recently renovated,pool,gym\"}\n", |
1061 | | - "Updated parameters after extract_hotel_search_parameters:\n", |
1062 | | - "{'query': 'recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym', 'distance': '250m', 'rating': 4, 'location': 'Belongil Beach', 'attraction': 'recently renovated,pool,gym'}\n", |
1063 | | - "\n", |
1064 | | - "Formatted Messages:\n", |
1065 | | - "Message 1:\n", |
1066 | | - "Role: assistant\n", |
1067 | | - "Tool Calls:\n", |
1068 | | - " Tool Call ID: call_STsRLGP8GcBhgWzRuJYnKw0k\n", |
1069 | | - " Function Name: geocode_location\n", |
1070 | | - " Arguments: {\"location\":\"Belongil Beach\"}\n", |
1071 | | - "\n", |
1072 | | - "--------------------------------------------------\n", |
1073 | | - "Updated parameters after geocode_location:\n", |
1074 | | - "{'query': 'recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym', 'distance': '250m', 'rating': 4, 'location': 'Belongil Beach', 'attraction': 'recently renovated,pool,gym', 'latitude': -28.6337328, 'longitude': 153.6003455}\n", |
1075 | | - "\n", |
1076 | | - "Formatted Messages:\n", |
1077 | | - "Message 1:\n", |
1078 | | - "Role: assistant\n", |
1079 | | - "Tool Calls:\n", |
1080 | | - " Tool Call ID: call_m2XTVPxzXT0mmu0QueYO5YLI\n", |
1081 | | - " Function Name: query_elasticsearch\n", |
1082 | | - " Arguments: {\"query\":\"recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym\",\"latitude\":-28.6337328,\"longitude\":153.6003455,\"distance\":\"250m\",\"rating\":4,\"attraction\":\"recently renovated,pool,gym\"}\n", |
1083 | | - "\n", |
1084 | | - "--------------------------------------------------\n", |
1085 | | - "Function Arguments for extract_hotel_search_parameters:\n", |
1086 | | - "{'query': 'recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym', 'latitude': -28.6337328, 'longitude': 153.6003455, 'distance': '250m', 'rating': 4, 'attraction': 'recently renovated,pool,gym'}\n", |
1087 | | - "Parameters for Elasticsearch:\n", |
1088 | | - "{'query': 'recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym', 'latitude': -28.6337328, 'longitude': 153.6003455, 'distance': '250m', 'rating': 4, 'attraction': 'recently renovated,pool,gym'}\n", |
1089 | | - "Elasticsearch Query:\n", |
1090 | | - "{\n", |
1091 | | - " \"id\": \"hotel_search_template\",\n", |
1092 | | - " \"params\": {\n", |
1093 | | - " \"query\": \"recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym\",\n", |
1094 | | - " \"latitude\": -28.6337328,\n", |
1095 | | - " \"longitude\": 153.6003455,\n", |
1096 | | - " \"distance\": \"250m\",\n", |
1097 | | - " \"rating\": 4,\n", |
1098 | | - " \"attraction\": \"recently renovated,pool,gym\"\n", |
1099 | | - " }\n", |
1100 | | - "}\n", |
1101 | | - "Elasticsearch query successful.\n", |
1102 | | - "Number of results found: 1\n", |
1103 | | - "\n", |
1104 | | - "Formatted Messages:\n", |
1105 | | - "Message 1:\n", |
1106 | | - "Role: assistant\n", |
1107 | | - "Content: I found the following recently renovated accommodation 250m from Belongil Beach with at least 4 stars, a pool, and a gym:\n", |
1108 | | - "\n", |
1109 | | - "- **Hotel Name:** Belongil Beach Apartment\n", |
1110 | | - "- **Rating:** 4 stars\n", |
1111 | | - "- **City:** Byron Bay, New South Wales\n", |
1112 | | - "- **Country:** Australia\n", |
1113 | | - "\n", |
1114 | | - "Would you like more details or assistance with anything else?\n", |
1115 | | - "\n", |
1116 | | - "--------------------------------------------------\n" |
1117 | | - ] |
1118 | | - } |
1119 | | - ], |
| 977 | + "outputs": [], |
1120 | 978 | "source": [ |
1121 | 979 | "find_a_hotel(\n", |
1122 | 980 | " \"recently renovated accommodations 250m from Belongil Beach with at least 4 stars and with a pool and gym\"\n", |
|
0 commit comments