Skip to content

Commit

Permalink
fix:logs and rm unused codes in CacheEmbedding (langgenius#8409)
Browse files Browse the repository at this point in the history
  • Loading branch information
Howe829 authored Sep 14, 2024
1 parent f55e06d commit 0123498
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions api/core/embedding/cached_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def embed_documents(self, texts: list[str]) -> list[list[float]]:
except IntegrityError:
db.session.rollback()
except Exception as e:
logging.exception("Failed transform embedding: ", e)
logging.exception("Failed transform embedding: %s", e)
cache_embeddings = []
try:
for i, embedding in zip(embedding_queue_indices, embedding_queue_embeddings):
Expand All @@ -85,7 +85,7 @@ def embed_documents(self, texts: list[str]) -> list[list[float]]:
db.session.rollback()
except Exception as ex:
db.session.rollback()
logger.error("Failed to embed documents: ", ex)
logger.error("Failed to embed documents: %s", ex)
raise ex

return text_embeddings
Expand Down Expand Up @@ -116,10 +116,7 @@ def embed_query(self, text: str) -> list[float]:
# Transform to string
encoded_str = encoded_vector.decode("utf-8")
redis_client.setex(embedding_cache_key, 600, encoded_str)

except IntegrityError:
db.session.rollback()
except:
logging.exception("Failed to add embedding to redis")
except Exception as ex:
logging.exception("Failed to add embedding to redis %s", ex)

return embedding_results

0 comments on commit 0123498

Please sign in to comment.