You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from crewai_tools import PGSearchTool
postgresql_tool = PGSearchTool(
db_uri="postgresql://localhost:password@localhost:5432/database",
table_name='users'
)
And it appeared an error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 22
15 convert_task = Task(
16 description='Convert the following natural language input into a rule-based command: Chỉ lấy các ứng viên dưới 30 tuổi nếu là nữ, trên 40 tuổi và đã có gia đình nếu là nam. Nhà giàu, ngoại hình ưa nhìn, đang sống ở Đà Nẵng',
17 agent=rules_creator_agent, # Assigning the task to the researcher
18 expected_output='A refined finalized version of the structured format rules which can be used to query the SQL table with JSON data'
19 )
21 # Initialize the tool with the database URI and the target table name
---> 22 postgresql_tool = PGSearchTool(
23 db_uri=os.getenv("POSTGRESQL_URL"),
24 table_name='candidates'
25 )
27 query_agent = Agent(
28 role='Database Query Specialist',
29 goal='Execute SQL queries on the database and return results',
(...)
35 tools=[postgresql_tool]
36 )
37 query_task = Task(
38 description="Query the table 'candidates' and retrieve data where 'raw_data' column matches specific criteria",
39 expected_output="List resume_id of candidates matched criteria",
40 agent=query_agent
41 )
File ~/Desktop/cc-ai-poc-openai_fine_tune/venv/lib/python3.11/site-packages/crewai_tools/tools/pg_seach_tool/pg_search_tool.py:26, in PGSearchTool.__init__(self, table_name, **kwargs)
24 def __init__(self, table_name: str, **kwargs):
25 super().__init__(**kwargs)
---> 26 self.add(table_name)
27 self.description = f"A tool that can be used to semantic search a query the {table_name} database table's content."
28 self._generate_description()
File ~/Desktop/cc-ai-poc-openai_fine_tune/venv/lib/python3.11/site-packages/crewai_tools/tools/pg_seach_tool/pg_search_tool.py:36, in PGSearchTool.add(self, table_name, **kwargs)
30 def add(
31 self,
32 table_name: str,
33 **kwargs: Any,
34 ) -> None:
35 kwargs["data_type"] = "postgres"
---> 36 kwargs["loader"] = PostgresLoader(config=dict(url=self.db_uri))
37 super().add(f"SELECT * FROM {table_name};", **kwargs)
File ~/Desktop/cc-ai-poc-openai_fine_tune/venv/lib/python3.11/site-packages/embedchain/loaders/postgres.py:18, in PostgresLoader.__init__(self, config)
16 self.connection = None
17 self.cursor = None
---> 18 self._setup_loader(config=config)
File ~/Desktop/cc-ai-poc-openai_fine_tune/venv/lib/python3.11/site-packages/embedchain/loaders/postgres.py:22, in PostgresLoader._setup_loader(self, config)
20 def _setup_loader(self, config: dict[str, Any]):
21 try:
---> 22 import psycopg
23 except ImportError as e:
24 raise ImportError(
25 "Unable to import required packages. \
26 Run `pip install --upgrade 'embedchain[postgres]'`"
27 ) from e
File ~/Desktop/cc-ai-poc-openai_fine_tune/venv/lib/python3.11/site-packages/psycopg/__init__.py:9
5 # Copyright (C) 2020 The Psycopg Team
7 import logging
----> 9 from . import pq # noqa: F401 import early to stabilize side effects
10 from . import types
11 from . import postgres
File ~/Desktop/cc-ai-poc-openai_fine_tune/venv/lib/python3.11/site-packages/psycopg/pq/__init__.py:118
109 sattempts = "\n".join(f"- {attempt}" for attempt in attempts)
110 raise ImportError(
111 f"""\
112 no pq wrapper available.
113 Attempts made:
114 {sattempts}"""
115 )
--> 118 import_from_libpq()
120 __all__ = (
121 "ConnStatus",
122 "PipelineStatus",
(...)
137 "version_pretty",
138 )
File ~/Desktop/cc-ai-poc-openai_fine_tune/venv/lib/python3.11/site-packages/psycopg/pq/__init__.py:104, in import_from_libpq()
102 Escaping = module.Escaping
103 PGcancel = module.PGcancel
--> 104 PGcancelConn = module.PGcancelConn
105 __build_version__ = module.__build_version__
106 elif impl:
AttributeError: module 'psycopg_binary.pq' has no attribute 'PGcancelConn'
The text was updated successfully, but these errors were encountered:
Python 3.11
pip list:
My code:
And it appeared an error:
The text was updated successfully, but these errors were encountered: