Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix a bug when using huggingface embedding api (#8432)

Rainman49d67cbcb797
diff --git a/rag/llm/embedding_model.py b/rag/llm/embedding_model.py
index 25cbc5250e..373485b9af 100644
--- a/rag/llm/embedding_model.py
+++ b/rag/llm/embedding_model.py
@@ -871,14 +871,11 @@ class HuggingFaceEmbed(Base):
headers={'Content-Type': 'application/json'}
)
if response.status_code == 200:
- try:
- embedding = response.json()
- embeddings.append(embedding[0])
- return np.array(embeddings), sum([num_tokens_from_string(text) for text in texts])
- except Exception as _e:
- log_exception(_e, response)
+ embedding = response.json()
+ embeddings.append(embedding[0])
else:
raise Exception(f"Error: {response.status_code} - {response.text}")
+ return np.array(embeddings), sum([num_tokens_from_string(text) for text in texts])
def encode_queries(self, text):
response = requests.post(
@@ -887,11 +884,8 @@ class HuggingFaceEmbed(Base):
headers={'Content-Type': 'application/json'}
)
if response.status_code == 200:
- try:
- embedding = response.json()
- return np.array(embedding[0]), num_tokens_from_string(text)
- except Exception as _e:
- log_exception(_e, response)
+ embedding = response.json()
+ return np.array(embedding[0]), num_tokens_from_string(text)
else:
raise Exception(f"Error: {response.status_code} - {response.text}")