What is an AI-Data Mind
An AI-Data Mind is like an LLM that answers questions and engages in conversations using data from your database. Creating a Mind is simple: you just configure how it accesses the database, and then you can interact with it through OpenAI's standard Completions or Assistants API. Minds are designed to assist AI agents in completing tasks that require data, making it as straightforward as interacting with a typical LLM. This simplifies the complexity of data retrieval and reasoning, allowing you to focus on building your AI applications without worrying about maintaining intricate execution and reasoning loops. Additionally, Minds can be customized for complex use cases, streamlining your development process.
Currently available data sources include ClickHouse, MariaDB, MySQL, PostgreSQL, Amazon Redshift, Snowflake, and Google BigQuery.
Support for files is coming soon!
Create a Mind
Follow these steps to get started:
- Sign up at Minds Cloud.
- Generate the Minds API key.
- In this code, we’re connecting to our sample database, see full details here.
Install the latest version of MindsDB SDK by running pip install mindsdb_sdk
.
from mindsdb_sdk.utils.mind import create_mind, DatabaseConfig
your_minds_api_key = <YOUR API KEY>
minds_name = <NAME YOU GAVE TO YOUR MIND>
# Connection details for House Sales Data in our postgres demo DB
pg_config = DatabaseConfig(
description='House Sales Data',
type='postgres',
connection_args={
'user': 'demo_user',
'password': 'demo_password',
'host': 'samples.mindsdb.com',
'port': '5432',
'database': 'demo',
'schema': 'demo_data'
},
tables=['house_sales']
)
# Create a Mind and connect your data source to it
mind = create_mind(
name=minds_name,
# API connection details
base_url='https://llm.mdb.ai/',
api_key=your_minds_api_key,
# Connect one or more data sources to your Mind listing them in the data_source_configs parameter
data_source_configs=[pg_config]
)
print(f"{mind.name} was created successfully. You can now use this Mind using the OpenAI-compatible API, see docs for next steps.")
The following arguments are required to create a Data Source:
description
is the description of the data source that helps the Mind decide which data source to use for answering certain questions.type
is the engine of the data source to be connected. See all supported data sources here.connection_args
stores the connection parameters that allow Minds to access the data source. See all supported data sources here.tables
is an optional parameter that lists specific table(s) to be accessed by the Mind. Note that if it is not provided, then the Mind accesses the entire database.
Note that Minds do not store or copy your data. Instead, Minds poll data from the connected data sources using the provided connection parameters whenever required, so all changes to your data are reflected in Minds upon querying the data.
The following arguments are required to create a Mind:
base_url
is the URL where requests are sent.api_key
is the Minds API key generated at Minds Cloud.name
is the unique name of the Mind.data_source_configs
is a list of configurations for data sources, such as databases, you can connect to your Mind. See all supported data sources here.
Now that you created the Mind, let's start the conversation with your data!
There are two options for accessing an AI-Data Mind:
- OpenAI Chat Completions API – suits for simple query-response interactions, yet is stateless.
- OpenAI Assistants API – for context persistence and advanced features like dynamic data retrieval or code execution.