|
import openai |
|
import pandas as pd |
|
import numpy as np |
|
from sklearn.metrics.pairwise import cosine_similarity |
|
import os |
|
from dotenv import load_dotenv |
|
|
|
|
|
load_dotenv() |
|
api_key = os.getenv('OPENAI_API_KEY') |
|
|
|
|
|
def get_embedding(text, model="text-embedding-ada-002"): |
|
text = text.replace("\n", " ") |
|
response = openai.Embedding.create(input=[text], model=model) |
|
return response['data'][0]['embedding'] |
|
|
|
example_text = "How much do I have to pay for the current bill?" |
|
example_embedding = get_embedding(example_text) |
|
print(example_embedding) |