|
25 | 25 | "- An Elastic deployment with minimum **4GB machine learning node**\n",
|
26 | 26 | " - We'll be using [Elastic Cloud](https://www.elastic.co/guide/en/cloud/current/ec-getting-started.html) for this example (available with a [free trial](https://cloud.elastic.co/registration?utm_source=github&utm_content=elasticsearch-labs-notebook))\n",
|
27 | 27 | " \n",
|
28 |
| - "- An [OpenAI account](https://openai.com/) is required to use the Inference API with \n", |
29 |
| - "the OpenAI service. " |
| 28 | + "- A paid [OpenAI account](https://openai.com/) is required to use the Inference API with \n", |
| 29 | + "the OpenAI service as the OpenAI free trial API usage is limited. " |
30 | 30 | ]
|
31 | 31 | },
|
32 | 32 | {
|
|
109 | 109 | "metadata": {},
|
110 | 110 | "outputs": [],
|
111 | 111 | "source": [
|
112 |
| - "# Found in the 'Manage Deployment' page\n", |
113 |
| - "CLOUD_ID = getpass.getpass('Enter Elastic Cloud ID: ')\n", |
| 112 | + "# https://www.elastic.co/search-labs/tutorials/install-elasticsearch/elastic-cloud#finding-your-cloud-id\n", |
| 113 | + "ELASTIC_CLOUD_ID = getpass(\"Elastic Cloud ID: \")\n", |
114 | 114 | "\n",
|
115 |
| - "# Password for the 'elastic' user generated by Elasticsearch\n", |
116 |
| - "ELASTIC_PASSWORD = getpass.getpass('Enter Elastic password: ')\n", |
| 115 | + "# https://www.elastic.co/search-labs/tutorials/install-elasticsearch/elastic-cloud#creating-an-api-key\n", |
| 116 | + "ELASTIC_API_KEY = getpass(\"Elastic Api Key: \")\n", |
117 | 117 | "\n",
|
118 | 118 | "# Create the client instance\n",
|
119 | 119 | "client = Elasticsearch(\n",
|
120 |
| - " cloud_id=CLOUD_ID,\n", |
121 |
| - " basic_auth=(\"elastic\", ELASTIC_PASSWORD)\n", |
| 120 | + " # For local development\n", |
| 121 | + " # hosts=[\"http://localhost:9200\"] \n", |
| 122 | + " cloud_id=ELASTIC_CLOUD_ID,\n", |
| 123 | + " api_key=ELASTIC_API_KEY,\n", |
122 | 124 | ")"
|
123 | 125 | ]
|
124 | 126 | },
|
|
159 | 161 | "\n",
|
160 | 162 | "Let's create the inference task by using the [Create inference API](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html).\n",
|
161 | 163 | "\n",
|
162 |
| - "You'll need an OpenAI API key for this that you can find in your OpenAI account under the [API keys section](https://platform.openai.com/api-keys)." |
| 164 | + "You'll need an OpenAI API key for this that you can find in your OpenAI account under the [API keys section](https://platform.openai.com/api-keys). A paid membership is required to complete the steps in this notebook as the OpenAI free trial API usage is limited." |
163 | 165 | ]
|
164 | 166 | },
|
165 | 167 | {
|
|
241 | 243 | "source": [
|
242 | 244 | "## Create index\n",
|
243 | 245 | "\n",
|
244 |
| - "The mapping of the destination index - the index that contains the embeddings that the model will create based on your input text - must be created. The destination index must have a field with the [dense_vector](https://www.elastic.co/guide/en/elasticsearch/reference/current/dense-vector.html) field type to index the output of the OpenAI model.\n", |
| 246 | + "The mapping of the destination index – the index that contains the embeddings that the model will create based on your input text – must be created. The destination index must have a field with the [dense_vector](https://www.elastic.co/guide/en/elasticsearch/reference/current/dense-vector.html) field type to index the output of the OpenAI model.\n", |
245 | 247 | "\n",
|
246 | 248 | "Let's create an index named `openai-movie-embeddings` with the mappings we need."
|
247 | 249 | ]
|
|
265 | 267 | " \"properties\": {\n",
|
266 | 268 | " \"plot_embedding\": { \n",
|
267 | 269 | " \"type\": \"dense_vector\", \n",
|
268 |
| - " \"dims\": 1536, \n", |
269 |
| - " \"element_type\": \"byte\",\n", |
| 270 | + " \"dims\": 1536,\n", |
270 | 271 | " \"similarity\": \"dot_product\" \n",
|
271 | 272 | " },\n",
|
272 | 273 | " \"plot\": { \n",
|
|
282 | 283 | "id": "e9d4bfd2",
|
283 | 284 | "metadata": {},
|
284 | 285 | "source": [
|
285 |
| - "## Insert Documents (option 1)\n", |
| 286 | + "## Insert Documents\n", |
286 | 287 | "\n",
|
287 |
| - "Let's insert our example dataset of 12 movies." |
| 288 | + "Let's insert our example dataset of 12 movies. You need a paid OpenAI account to complete this step, otherwise the documentation ingest will time out due to the API request rate limits." |
288 | 289 | ]
|
289 | 290 | },
|
290 | 291 | {
|
|
0 commit comments