Squashed 'packages/tools/' changes from 78317b9c..0b3f00e6

0b3f00e6 chore: update project version to 0.73.0 and revise uv.lock dependencies (#455)
ad19b074 feat: replace embedchain with native crewai adapter (#451)

git-subtree-dir: packages/tools
git-subtree-split: 0b3f00e67c0dae24d188c292dc99759fd1c841f7
This commit is contained in:
Greyson LaLonde
2025-09-18 23:38:08 -04:00
parent e16606672a
commit c960f26601
35 changed files with 4897 additions and 3951 deletions

View File

@@ -1,14 +1,9 @@
from typing import Any, Type
try:
from embedchain.loaders.postgres import PostgresLoader
EMBEDCHAIN_AVAILABLE = True
except ImportError:
EMBEDCHAIN_AVAILABLE = False
from pydantic import BaseModel, Field
from ..rag.rag_tool import RagTool
from crewai_tools.rag.data_types import DataType
class PGSearchToolSchema(BaseModel):
@@ -27,12 +22,8 @@ class PGSearchTool(RagTool):
db_uri: str = Field(..., description="Mandatory database URI")
def __init__(self, table_name: str, **kwargs):
if not EMBEDCHAIN_AVAILABLE:
raise ImportError("embedchain is not installed. Please install it with `pip install crewai-tools[embedchain]`")
super().__init__(**kwargs)
kwargs["data_type"] = "postgres"
kwargs["loader"] = PostgresLoader(config=dict(url=self.db_uri))
self.add(table_name)
self.add(table_name, data_type=DataType.POSTGRES, metadata={"db_uri": self.db_uri})
self.description = f"A tool that can be used to semantic search a query the {table_name} database table's content."
self._generate_description()
@@ -46,6 +37,8 @@ class PGSearchTool(RagTool):
def _run(
self,
search_query: str,
similarity_threshold: float | None = None,
limit: int | None = None,
**kwargs: Any,
) -> Any:
return super()._run(query=search_query, **kwargs)
return super()._run(query=search_query, similarity_threshold=similarity_threshold, limit=limit, **kwargs)