From 837198ae08f07efef14d7a44a0280e23cdd1d3c9 Mon Sep 17 00:00:00 2001 From: Lorenze Jay Date: Fri, 7 Feb 2025 10:03:37 -0800 Subject: [PATCH] Add interactive Qdrant client installation prompt --- .../qdrant_search_tool.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/crewai_tools/tools/qdrant_vector_search_tool/qdrant_search_tool.py b/src/crewai_tools/tools/qdrant_vector_search_tool/qdrant_search_tool.py index bd9cd8701..c59dd29d5 100644 --- a/src/crewai_tools/tools/qdrant_vector_search_tool/qdrant_search_tool.py +++ b/src/crewai_tools/tools/qdrant_vector_search_tool/qdrant_search_tool.py @@ -82,6 +82,21 @@ class QdrantVectorSearchTool(BaseTool): url=self.qdrant_url, api_key=self.qdrant_api_key, ) + else: + import click + + if click.confirm( + "The 'qdrant-client' package is required to use the QdrantVectorSearchTool. " + "Would you like to install it?" + ): + import subprocess + + subprocess.run(["uv", "add", "qdrant-client"], check=True) + else: + raise ImportError( + "The 'qdrant-client' package is required to use the QdrantVectorSearchTool. " + "Please install it with: uv add qdrant-client" + ) def _run( self, @@ -103,11 +118,6 @@ class QdrantVectorSearchTool(BaseTool): ImportError: If qdrant-client is not installed ValueError: If Qdrant credentials are missing """ - if not QDRANT_AVAILABLE: - raise ImportError( - "The 'qdrant-client' package is required to use the QdrantVectorSearchTool. " - "Please install it with: pip install qdrant-client" - ) if not self.qdrant_url: raise ValueError("QDRANT_URL is not set")