import openai import pandas as pd import numpy as np from sklearn.metrics.pairwise import cosine_similarity import os from dotenv import load_dotenv # Initialize OpenAI client (replace with your API key) load_dotenv() # take environment variables from .env. api_key = os.getenv('OPENAI_API_KEY') # Function to get OpenAI embeddings for a text input def get_embedding(text, model="text-embedding-ada-002"): text = text.replace("\n", " ") response = openai.Embedding.create(input=[text], model=model) # Correct API call return response['data'][0]['embedding'] example_text = "How much do I have to pay for the current bill?" example_embedding = get_embedding(example_text) # Correct function call print(example_embedding)