Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ def get_text_embedding_with_rate_limit(text_list, initial_delay=2, max_retries=1
|
|
| 31 |
delay = initial_delay
|
| 32 |
while retries < max_retries:
|
| 33 |
try:
|
| 34 |
-
if len(text) > 8192:
|
| 35 |
logging.warning("Text chunk exceeds the token limit. Truncating the text.")
|
| 36 |
text = text[:8192]
|
| 37 |
|
|
@@ -39,7 +39,7 @@ def get_text_embedding_with_rate_limit(text_list, initial_delay=2, max_retries=1
|
|
| 39 |
model="text-embedding-3-small",
|
| 40 |
input=[text]
|
| 41 |
)
|
| 42 |
-
embeddings.append(response
|
| 43 |
time.sleep(delay)
|
| 44 |
break
|
| 45 |
except Exception as e:
|
|
@@ -145,7 +145,7 @@ class MistralRAGChatbot:
|
|
| 145 |
model=model,
|
| 146 |
input=[text]
|
| 147 |
)
|
| 148 |
-
return np.array(response
|
| 149 |
except Exception as e:
|
| 150 |
logging.error(f"Error fetching OpenAI embedding: {e}")
|
| 151 |
return np.zeros((1536,), dtype=np.float32)
|
|
|
|
| 31 |
delay = initial_delay
|
| 32 |
while retries < max_retries:
|
| 33 |
try:
|
| 34 |
+
if len(text) > 8192:
|
| 35 |
logging.warning("Text chunk exceeds the token limit. Truncating the text.")
|
| 36 |
text = text[:8192]
|
| 37 |
|
|
|
|
| 39 |
model="text-embedding-3-small",
|
| 40 |
input=[text]
|
| 41 |
)
|
| 42 |
+
embeddings.append(response.data[0].embedding) # ✅ dot notation
|
| 43 |
time.sleep(delay)
|
| 44 |
break
|
| 45 |
except Exception as e:
|
|
|
|
| 145 |
model=model,
|
| 146 |
input=[text]
|
| 147 |
)
|
| 148 |
+
return np.array(response.data[0].embedding, dtype=np.float32) # ✅ dot notation
|
| 149 |
except Exception as e:
|
| 150 |
logging.error(f"Error fetching OpenAI embedding: {e}")
|
| 151 |
return np.zeros((1536,), dtype=np.float32)
|