A command line tool for interacting with minds - https://mdb.ai/
Documentation for minds - https://docs.mdb.ai/docs/data_sources
Install this tool using pip
:
pip install minds-cli-sdk
For help, run:
minds --help
You can also use:
python -m minds_cli --help
Set the environment variable MINDS_API_KEY
to the api key from minds.
To create an API key - Login to minds (https://mdb.ai) and create an API key.
export MINDS_API_KEY=<api-key>
This is optional. If the API endpoint is not provided, the cloud endpoint (https://mdb.ai) is taken by default.
If you have a self-hosted instance of minds, set the environment variable MINDS_API_KEY
to the new endpoint.
export MINDS_BASE_ENDPOINT=https://staging.mdb.ai
All commands and options related to datasources are as follows:
minds datasources --help
Output:
Usage: minds datasources [OPTIONS] COMMAND [ARGS]...
Command group to deal with datasources
Options:
--help Show this message and exit.
Commands:
create Create a datasource
drop Drop a datasource
get Get a datasource
list List the datasources
The command and the different options to be passed is as follows:
minds datasources create --help
Output:
Usage: minds datasources create [OPTIONS]
Create a datasource
Options:
--name TEXT name of datatasource. [required]
--engine TEXT type of database handler, for example
'postgres', 'mysql', ... [required]
--description TEXT description of the database. Used by mind to
know what data can be got from it. [required]
--connection_data_file FILE Credentials json file to connect to database.
Refer https://docs.mdb.ai/docs/data_sources
[required]
--tables TEXT Comma-separated list of allowed tables,
optional. Ex. --tables table1,table2,table3
--replace if true - to remove existing datasource,
default is false
--help Show this message and exit.
Example to create a postgres datasource:
minds datasources create --name pssql --engine postgres --description "new pssql db" --connection_data_file /Users/abhi/Downloads/ps_conn.json
Output:
pssql successfully created.
The connection_data_file contains the connection json string which is as follows:
{
"user": "demo_user",
"password": "demo_password",
"host": "samples.mindsdb.com",
"port": "5432",
"database": "demo",
"schema": "demo_data"
}
The command and the different options to be passed is as follows:
minds datasources create --help
Output:
Usage: minds datasources get [OPTIONS] DATASOURCE_NAME
Get a datasource
Options:
--help Show this message and exit.
Example:
minds datasources get pssql
Output:
name='pssql' engine='postgres' description='new pssql db' connection_data={'database': 'demo', 'host': 'samples.mindsdb.com', 'password': 'demo_password', 'port': '5432', 'schema': 'demo_data', 'user': 'demo_user'} tables=[]
The command and the different options to be passed is as follows:
minds datasources list --help
Output:
Usage: minds datasources list [OPTIONS]
List the datasources
Options:
--help Show this message and exit.
Example:
minds datasources list
Output:
[Datasource(name='pssql1', engine='postgres', description='new pssql db', connection_data={'database': 'demo', 'host': 'samples.mindsdb.com', 'password': 'demo_password', 'port': '5432', 'schema': 'demo_data', 'user': 'demo_user'}, tables=[])]
The command and the different options to be passed is as follows:
minds datasources drop --help
Output:
Usage: minds datasources drop [OPTIONS] DATASOURCE_NAME
Drop a datasource
Options:
--help Show this message and exit.
Example:
minds datasources drop pssql
Output:
pssql successfully deleted.
All commands and options related to minds are as follows:
minds minds --help
Output:
Usage: minds minds [OPTIONS] COMMAND [ARGS]...
Command group to deal with minds
Options:
--help Show this message and exit.
Commands:
add_datasource Add a datasource to a mind
chat Chat completion with minds
create Create a mind
drop Drop a mind
drop_datasource Drop a datasource to a mind
get Get a mind
list List the minds
update Update a mind
The command and the different options to be passed is as follows:
minds minds create --help
Output:
Usage: minds minds create [OPTIONS]
Create a mind
Options:
--name TEXT name of the mind [required]
--model_name TEXT llm model name, optional
--provider TEXT llm provider, optional. Ex. openai
--prompt_template TEXT instructions to llm, optional
--datasources TEXT Comma-separated list of datasources used by mind,
optional. Ex. --datasources testds, testds1, testds2
--parameters TEXT other parameters of the mind, optional. This is a
json string.
--replace if true - to remove existing mind, default is false
--help Show this message and exit.
Example to create a postgres datasource:
minds minds create --name newMind --model_name gpt-3.5 --datasources pssql1,testds --parameters "{\"owner\":\"abhi\"}" --replace
Output:
newMind successfully created.
The connection_data_file contains the connection json string which is as follows:
{
"user": "demo_user",
"password": "demo_password",
"host": "samples.mindsdb.com",
"port": "5432",
"database": "demo",
"schema": "demo_data"
}
The command and the different options to be passed is as follows:
minds minds get --help
Output:
Usage: minds minds get [OPTIONS] MIND_NAME
Get a mind
Options:
--help Show this message and exit.
Example:
minds minds get newMind
Output:
<Mind Object details>
The command and the different options to be passed is as follows:
minds minds list --help
Output:
Usage: minds minds list [OPTIONS]
List the minds
Options:
--help Show this message and exit.
Example:
minds minds list
Output:
[Mind Object1, Mind Object2, ....]
The command and the different options to be passed is as follows:
minds minds drop --help
Output:
Usage: minds minds drop [OPTIONS] MIND_NAME
Drop a mind
Options:
--help Show this message and exit.
Example:
minds minds drop newMind
Output:
newMind successfully deleted.
The command and the different options to be passed is as follows:
minds minds add_datasource --help
Output:
Usage: minds minds add_datasource [OPTIONS] MIND_NAME DATASOURCE_NAME
Add a datasource to a mind
Options:
--help Show this message and exit.
Example:
minds minds add_datasource newMind newds
Output:
newds added to newMind
The command and the different options to be passed is as follows:
minds minds drop_datasource --help
Output:
Usage: minds minds drop_datasource [OPTIONS] MIND_NAME DATASOURCE_NAME
Drop a datasource from a mind
Options:
--help Show this message and exit.
Example:
minds minds drop_datasource newMind newds
Output:
newds dropped from newMind
The command and the different options to be passed is as follows:
minds minds chat --help
Output:
Usage: cli.py minds chat [OPTIONS]
Chat completion with minds
Options:
--name TEXT name of the mind [required]
--message TEXT Chat message [required]
--stream if stream is enabled, default is false
--help Show this message and exit.
Example:
minds chat --name test --message "Hi, how are you?"
Enable chat streaming:
minds chat --name test --message "Hi, how are you?" --stream
Output:
I'm good today
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd minds-cli-sdk
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
python -m pytest