Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
chore: add abstract decorator and output log when query embedding fails (#9264)
zhuhaod97d3ff5fc43
diff --git a/api/core/embedding/cached_embedding.py b/api/core/embedding/cached_embedding.pyindex 75219051cd3..31d2171e726 100644--- a/api/core/embedding/cached_embedding.py+++ b/api/core/embedding/cached_embedding.py@@ -5,6 +5,7 @@ from typing import Optional, castimport numpy as npfrom sqlalchemy.exc import IntegrityError+from configs import dify_configfrom core.embedding.embedding_constant import EmbeddingInputTypefrom core.model_manager import ModelInstancefrom core.model_runtime.entities.model_entities import ModelPropertyKey@@ -110,6 +111,8 @@ class CacheEmbedding(Embeddings):embedding_results = embedding_result.embeddings[0]embedding_results = (embedding_results / np.linalg.norm(embedding_results)).tolist()except Exception as ex:+ if dify_config.DEBUG:+ logging.exception(f"Failed to embed query text: {ex}")raise extry:@@ -122,6 +125,8 @@ class CacheEmbedding(Embeddings):encoded_str = encoded_vector.decode("utf-8")redis_client.setex(embedding_cache_key, 600, encoded_str)except Exception as ex:- logging.exception("Failed to add embedding to redis %s", ex)+ if dify_config.DEBUG:+ logging.exception("Failed to add embedding to redis %s", ex)+ raise exreturn embedding_resultsdiff --git a/api/core/rag/datasource/keyword/keyword_base.py b/api/core/rag/datasource/keyword/keyword_base.pyindex 4b9ec460e61..be00687abd5 100644--- a/api/core/rag/datasource/keyword/keyword_base.py+++ b/api/core/rag/datasource/keyword/keyword_base.py@@ -27,9 +27,11 @@ class BaseKeyword(ABC):def delete_by_ids(self, ids: list[str]) -> None:raise NotImplementedError+ @abstractmethoddef delete(self) -> None:raise NotImplementedError+ @abstractmethoddef search(self, query: str, **kwargs: Any) -> list[Document]:raise NotImplementedErrordiff --git a/api/core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py b/api/core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.pyindex f585e12b2e9..66bc31a4bfa 100644--- a/api/core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py+++ b/api/core/rag/datasource/vdb/elasticsearch/elasticsearch_vector.py@@ -77,7 +77,7 @@ class ElasticSearchVector(BaseVector):raise ValueError("Elasticsearch vector database version must be greater than 8.0.0")def get_type(self) -> str:- return "elasticsearch"+ return VectorType.ELASTICSEARCHdef add_texts(self, documents: list[Document], embeddings: list[list[float]], **kwargs):uuids = self._get_uuids(documents)