AI Mind Tool
AIMindTool
Section titled “AIMindTool”Description
Section titled “Description”The AIMindTool is a wrapper around AI-Minds provided by MindsDB. It allows you to query data sources in natural language by simply configuring their connection parameters. This tool is useful when you need answers to questions from your data stored in various data sources including PostgreSQL, MySQL, MariaDB, ClickHouse, Snowflake, and Google BigQuery.
Minds are AI systems that work similarly to large language models (LLMs) but go beyond by answering any question from any data. This is accomplished by:
- Selecting the most relevant data for an answer using parametric search
- Understanding the meaning and providing responses within the correct context through semantic search
- Delivering precise answers by analyzing data and using machine learning (ML) models
Installation
Section titled “Installation”To incorporate this tool into your project, you need to install the Minds SDK:
uv add minds-sdkSteps to Get Started
Section titled “Steps to Get Started”To effectively use the AIMindTool, follow these steps:
- Package Installation: Confirm that the
crewai[tools]andminds-sdkpackages are installed in your Python environment. - API Key Acquisition: Sign up for a Minds account here, and obtain an API key.
- Environment Configuration: Store your obtained API key in an environment variable named
MINDS_API_KEYto facilitate its use by the tool.
Example
Section titled “Example”The following example demonstrates how to initialize the tool and execute a query:
from crewai_tools import AIMindTool
# Initialize the AIMindToolaimind_tool = AIMindTool( datasources=[ { "description": "house sales data", "engine": "postgres", "connection_data": { "user": "demo_user", "password": "demo_password", "host": "samples.mindsdb.com", "port": 5432, "database": "demo", "schema": "demo_data" }, "tables": ["house_sales"] } ])
# Run a natural language queryresult = aimind_tool.run("How many 3 bedroom houses were sold in 2008?")print(result)Parameters
Section titled “Parameters”The AIMindTool accepts the following parameters:
- api_key: Optional. Your Minds API key. If not provided, it will be read from the
MINDS_API_KEYenvironment variable. - datasources: A list of dictionaries, each containing the following keys:
- description: A description of the data contained in the datasource.
- engine: The engine (or type) of the datasource.
- connection_data: A dictionary containing the connection parameters for the datasource.
- tables: A list of tables that the data source will use. This is optional and can be omitted if all tables in the data source are to be used.
A list of supported data sources and their connection parameters can be found here.
Agent Integration Example
Section titled “Agent Integration Example”Here’s how to integrate the AIMindTool with a CrewAI agent:
from crewai import Agentfrom crewai.project import agentfrom crewai_tools import AIMindTool
# Initialize the toolaimind_tool = AIMindTool( datasources=[ { "description": "sales data", "engine": "postgres", "connection_data": { "user": "your_user", "password": "your_password", "host": "your_host", "port": 5432, "database": "your_db", "schema": "your_schema" }, "tables": ["sales"] } ])
# Define an agent with the AIMindTool@agentdef data_analyst(self) -> Agent: return Agent( config=self.agents_config["data_analyst"], allow_delegation=False, tools=[aimind_tool] )Conclusion
Section titled “Conclusion”The AIMindTool provides a powerful way to query your data sources using natural language, making it easier to extract insights without writing complex SQL queries. By connecting to various data sources and leveraging AI-Minds technology, this tool enables agents to access and analyze data efficiently.