Spaces:
Sleeping
Sleeping
init
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ def calc_distance(text1, text2, api) -> str:
|
|
7 |
text1_emb = openai.Embedding.create(input=text1, model="text-embedding-ada-002", api_key=api)
|
8 |
text2_emb = openai.Embedding.create(input=text2, model="text-embedding-ada-002", api_key=api)
|
9 |
|
10 |
-
text1_emb = np.array(text1_emb)
|
11 |
-
text2_emb = np.array(text2_emb)
|
12 |
|
13 |
distance = np.linalg.norm(text1_emb-text2_emb)
|
14 |
return str(distance)
|
|
|
7 |
text1_emb = openai.Embedding.create(input=text1, model="text-embedding-ada-002", api_key=api)
|
8 |
text2_emb = openai.Embedding.create(input=text2, model="text-embedding-ada-002", api_key=api)
|
9 |
|
10 |
+
text1_emb = np.array(text1_emb["data"][0]["embedding"])
|
11 |
+
text2_emb = np.array(text2_emb["data"][0]["embedding"])
|
12 |
|
13 |
distance = np.linalg.norm(text1_emb-text2_emb)
|
14 |
return str(distance)
|