Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "8c304b93",
"metadata": {},
"outputs": [],
"source": [
"# install packages\n",
"\n",
"!python3 -m pip install -qU openai pandas wget elasticsearch\n",
"! python3 -m pip install -qU openai pandas wget elasticsearch\n",
"\n",
"# import modules\n",
"\n",
Expand All @@ -54,7 +54,7 @@
"import zipfile\n",
"import pandas as pd\n",
"import json\n",
"import openai"
"from openai import OpenAI"
]
},
{
Expand Down Expand Up @@ -321,25 +321,21 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "57385c69",
"metadata": {},
"outputs": [],
"source": [
"# Get OpenAI API key\n",
"OPENAI_API_KEY = getpass(\"Enter OpenAI API key\")\n",
"\n",
"# Set API key\n",
"openai.api_key = OPENAI_API_KEY\n",
"\n",
"# Define model\n",
"EMBEDDING_MODEL = \"text-embedding-3-small\"\n",
"# Create OpenAI client\n",
"openai_client = OpenAI()\n",
"\n",
"# Define question\n",
"question = 'Is the Atlantic the biggest ocean in the world?'\n",
"\n",
"# Create embedding\n",
"question_embedding = openai.Embedding.create(input=question, model=EMBEDDING_MODEL)\n"
"question_embedding = openai_client.embeddings.create(\n",
" input=question,\n",
" model=\"text-embedding-3-small\"\n",
")"
]
},
{
Expand Down Expand Up @@ -383,7 +379,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "fc834fdd",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -764,7 +760,7 @@
" index = \"wikipedia_vector_index\",\n",
" knn={\n",
" \"field\": \"content_vector\",\n",
" \"query_vector\": question_embedding[\"data\"][0][\"embedding\"],\n",
" \"query_vector\": question_embedding.data[0].embedding,\n",
" \"k\": 10,\n",
" \"num_candidates\": 100\n",
" }\n",
Expand Down
4 changes: 2 additions & 2 deletions registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,12 @@

- title: Semantic search using Elasticsearch and OpenAI
path: examples/vector_databases/elasticsearch/elasticsearch-semantic-search.ipynb
date: 2023-08-29
date: 2025-06-13
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't change it

authors:
- leemthompo
tags:
- embeddings
- completions
- responses

- title: Using Hologres as a vector database for OpenAI embeddings
path: >-
Expand Down