Spaces:
Sleeping
Sleeping
embed all at once
Browse files- emb_sim.py +2 -6
emb_sim.py
CHANGED
@@ -14,14 +14,10 @@ openai_api_key = os.getenv("OPENAI_API_KEY")
|
|
14 |
oai_client = OpenAI(api_key=openai_api_key)
|
15 |
|
16 |
|
17 |
-
def get_openai_embedding(word):
|
18 |
-
response = oai_client.embeddings.create(input=word, model="text-embedding-3-small")
|
19 |
-
return response.data[0].embedding
|
20 |
-
|
21 |
-
|
22 |
def calculate_embeddings(words):
|
23 |
# Get word embeddings
|
24 |
-
|
|
|
25 |
return embeddings
|
26 |
|
27 |
|
|
|
14 |
oai_client = OpenAI(api_key=openai_api_key)
|
15 |
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
def calculate_embeddings(words):
|
18 |
# Get word embeddings
|
19 |
+
response = oai_client.embeddings.create(input=words, model="text-embedding-3-small")
|
20 |
+
embeddings = [e.embedding for e in response.data]
|
21 |
return embeddings
|
22 |
|
23 |
|