PG RAG Search
PGSearchTool 被设想为一个强大的工具,用于在 PostgreSQL 数据库表中执行语义搜索。借助先进的 Retrieve and Generate(RAG)技术, 它旨在为查询数据库表内容提供高效方式,特别适合 PostgreSQL 数据库。 该工具的目标是简化通过语义搜索查询查找相关数据的过程,为需要在 PostgreSQL 环境中对大规模数据集执行高级查询的用户提供有价值的资源。
将来发布后包含 PGSearchTool 的 crewai_tools 包,可以使用以下命令安装:
pip install 'crewai[tools]'下面给出一个建议示例,展示如何在 PostgreSQL 数据库中的表上使用 PGSearchTool 进行语义搜索:
from crewai_tools import PGSearchTool
# Initialize the tool with the database URI and the target table nametool = PGSearchTool( db_uri='postgresql://user:password@localhost:5432/mydatabase', table_name='employees')PGSearchTool 设计上需要以下参数:
| Argument | Type | Description |
|---|---|---|
| db_uri | string | 必填。表示要查询的 PostgreSQL 数据库 URI 的字符串。该参数为必填项,必须包含必要的认证信息和数据库位置。 |
| table_name | string | 必填。指定要执行语义搜索的数据库表名称的字符串。该参数同样必填。 |
自定义模型和 embeddings
Section titled “自定义模型和 embeddings”该工具计划默认同时使用 OpenAI 进行 embeddings 和 summarization。用户可以使用如下 config 字典自定义模型:
tool = PGSearchTool( config=dict( llm=dict( provider="ollama", # or google, openai, anthropic, llama2, ... config=dict( model="llama2", # temperature=0.5, # top_p=1, # stream=true, ), ), embedder=dict( provider="google-generativeai", # or openai, ollama, ... config=dict( model_name="gemini-embedding-001", task_type="RETRIEVAL_DOCUMENT", # title="Embeddings", ), ), ))