Skip to content

Latest commit

 

History

History
48 lines (31 loc) · 1.29 KB

File metadata and controls

48 lines (31 loc) · 1.29 KB

OpenAI Embedding Example

This example demonstrates how to utilize OpenAI embedding for semantic search. According to OpenAI's documentation, we will use cosine similarity to calculate vector distance.

You can run this example in two ways:

Jupyter Notebook

Notebook: example.ipynb

Try it in the Google colab.

Run in Local

Create a virtual environment

python3 -m venv .venv
source .venv/bin/activate

Install the requirements

pip install -r requirements.txt

Set the environment variables

Get the OPENAI_API_KEY from OpenAI

Get the TIDB_HOST, TIDB_USERNAME, and TIDB_PASSWORD from the TiDB Cloud console, as described in the Prerequisites section.

export OPENAI_API_KEY="sk-*******"
export TIDB_HOST="gateway01.*******.shared.aws.tidbcloud.com"
export TIDB_USERNAME="****.root"
export TIDB_PASSWORD="****"

Run the example

python3 example.py