from openai import OpenAI with open('.openai-secret', 'r') as f: OPENAI_API_KEY = f.read() class QueryEmbedder: def __init__(self) -> None: self.client = OpenAI(api_key=OPENAI_API_KEY) def embed_query(self, query): res = self.client.embeddings.create( model="text-embedding-3-small", input=query[0:8000], encoding_format="float" ) return res.dict()['data'][0]['embedding']