Skip to content

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

fix(beartype): remove package-wide import hooks (#19531)

Sbaaoui Idriss9ee43ae7950b
diff --git a/deepdoc/__init__.py b/deepdoc/__init__.py
index 3c485c025d..f0289b06ec 100644
--- a/deepdoc/__init__.py
+++ b/deepdoc/__init__.py
@@ -14,6 +14,11 @@
# limitations under the License.
#
-from beartype.claw import beartype_this_package
+# Keep runtime validation when beartype is installed, while allowing slim
+# builds to import without the optional checker.
+try:
+ from beartype.claw import beartype_this_package
-beartype_this_package()
+ beartype_this_package()
+except ImportError:
+ pass
diff --git a/pyproject.toml b/pyproject.toml
index 84a857e6d0..f5e0cb82c5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -74,7 +74,7 @@ dependencies = [
"moodlepy>=0.23.0",
"mypy-boto3-s3==1.40.26",
"Office365-REST-Python-Client==2.6.2",
- "ollama>=0.5.0",
+ "ollama>=0.5.1",
"onnxruntime==1.23.2; sys_platform == 'darwin' or platform_machine != 'x86_64'", # Python-side only; versioned independently of the Go native ORT static lib (internal/common.DeepDocORTVersion)
"onnxruntime-gpu==1.23.2; sys_platform != 'darwin' and platform_machine == 'x86_64'", # Python-side only; versioned independently of the Go native ORT static lib (internal/common.DeepDocORTVersion)
"opencv-python==4.10.0.84",
diff --git a/sdk/python/ragflow_sdk/__init__.py b/sdk/python/ragflow_sdk/__init__.py
index 0bd89e8ee3..d717b5e1b2 100644
--- a/sdk/python/ragflow_sdk/__init__.py
+++ b/sdk/python/ragflow_sdk/__init__.py
@@ -14,9 +14,14 @@
# limitations under the License.
#
-from beartype.claw import beartype_this_package
+# Keep runtime validation when beartype is installed, while allowing slim
+# SDK installs to import without the optional checker.
+try:
+ from beartype.claw import beartype_this_package
-beartype_this_package()
+ beartype_this_package()
+except ImportError:
+ pass
import importlib.metadata
diff --git a/sdk/python/uv.lock b/sdk/python/uv.lock
index d13bba7d74..bfd9447eb3 100644
--- a/sdk/python/uv.lock
+++ b/sdk/python/uv.lock
@@ -353,7 +353,7 @@ version = "2.7.0"
source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" }
sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/53/0c/06f8b233b8fd13b9e5ee11424ef85419ba0d8ba0b3138bf360be2ff56953/urllib3-2.7.0.tar.gz", hash = "sha256:231e0ec3b63ceb14667c67be60f2f2c40a518cb38b03af60abc813da26505f4c", size = 433602, upload-time = "2026-05-07T16:13:18.596Z" }
wheels = [
- { url = "https://pypi.tuna.tsinghua.edu.cn/packages/7f/3e/5db95bcf282c52709639744ca2a8b149baccf648e39c8cc87553df9eae0c/urllib3-2.7.0-py3-none-any.whl", hash = "sha256:9fb4c81ebbb1ce9531cce37674bbc6f1360472bc18ca9a553ede278ef7276897", size = 131087, upload-time = "2026-05-07T16:13:17.471Z" },
+ { url = "https://pypi.tuna.tsinghua.edu.cn/packages/7f/3e/5db95bcf282c52709639744ca2a8b149baccf648e39c8cc87553df9eae0c/urllib3-2.7.0-py3-none-any.whl", hash = "sha256:9fb4c81ebbb1ce9531cce37674bbc6f1360472bc18ca9a553ede278ef7276897", size = 131087, upload-time = "2026-05-07T16:13:17.151Z" },
]
[[package]]
diff --git a/tools/chatgpt-on-wechat/plugins/__init__.py b/tools/chatgpt-on-wechat/plugins/__init__.py
index 29ad3f6e6f..4ae0b59365 100644
--- a/tools/chatgpt-on-wechat/plugins/__init__.py
+++ b/tools/chatgpt-on-wechat/plugins/__init__.py
@@ -14,9 +14,14 @@
# limitations under the License.
#
-from beartype.claw import beartype_this_package
+# Keep runtime validation when beartype is installed, while allowing slim
+# plugin installs to import without the optional checker.
+try:
+ from beartype.claw import beartype_this_package
-beartype_this_package()
+ beartype_this_package()
+except ImportError:
+ pass
from .ragflow_chat import RAGFlowChat
diff --git a/uv.lock b/uv.lock
index 9221a8c7ec..3a674429b7 100644
--- a/uv.lock
+++ b/uv.lock
@@ -4198,12 +4198,12 @@ name = "onnxruntime-gpu"
version = "1.23.2"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
- { name = "coloredlogs" },
- { name = "flatbuffers" },
- { name = "numpy" },
- { name = "packaging" },
- { name = "protobuf" },
- { name = "sympy" },
+ { name = "coloredlogs", marker = "(platform_machine != 'aarch64' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')" },
+ { name = "flatbuffers", marker = "(platform_machine != 'aarch64' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')" },
+ { name = "numpy", marker = "(platform_machine != 'aarch64' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')" },
+ { name = "packaging", marker = "(platform_machine != 'aarch64' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')" },
+ { name = "protobuf", marker = "(platform_machine != 'aarch64' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')" },
+ { name = "sympy", marker = "(platform_machine != 'aarch64' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')" },
]
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/03/05/40d561636e4114b54aa06d2371bfbca2d03e12cfdf5d4b85814802f18a75/onnxruntime_gpu-1.23.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1e8f75af5da07329d0c3a5006087f4051d8abd133b4be7c9bae8cdab7bea4c26" },
@@ -8283,6 +8283,7 @@ dependencies = [
{ name = "ranx" },
{ name = "rapidfuzz" },
{ name = "readability-lxml" },
+ { name = "regex" },
{ name = "replicate" },
{ name = "reportlab" },
{ name = "roman-numbers" },
@@ -8330,7 +8331,6 @@ test = [
{ name = "pytest-xdist" },
{ name = "python-docx" },
{ name = "python-pptx" },
- { name = "regex" },
{ name = "reportlab" },
{ name = "requests" },
{ name = "requests-toolbelt" },
@@ -8416,7 +8416,7 @@ requires-dist = [
{ name = "mysql-connector-python", specifier = ">=9.0.0,<10.0.0" },
{ name = "nest-asyncio", specifier = ">=1.6.0,<2.0.0" },
{ name = "office365-rest-python-client", specifier = "==2.6.2" },
- { name = "ollama", specifier = ">=0.5.0" },
+ { name = "ollama", specifier = ">=0.5.1" },
{ name = "onnxruntime", marker = "platform_machine != 'x86_64' or sys_platform == 'darwin'", specifier = "==1.23.2" },
{ name = "onnxruntime-gpu", marker = "platform_machine == 'x86_64' and sys_platform != 'darwin'", specifier = "==1.23.2" },
{ name = "opencv-python", specifier = "==4.10.0.84" },