Rabbitt-AI commited on
Commit
3bfc473
·
verified ·
1 Parent(s): 6f06bc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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: # conservative character cutoff
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['data'][0]['embedding'])
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['data'][0]['embedding'], dtype=np.float32)
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)