A command-line tool for interacting with minds
Project description
Minds command line tool
A command line tool for interacting with minds - https://mdb.ai/
Documentation for minds - https://docs.mdb.ai/docs/data_sources
Installation
Install this tool using pip:
pip install minds-cli-sdk
Usage
For help, run:
minds --help
You can also use:
python -m minds_cli --help
Getting started
Setting the Minds API Key
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>
Setting the Minds API endpoint
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
Datasources
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
Creating a Data Source
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"
}
Get a Data Source
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=[]
List all Data Sources
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=[])]
Drop a Data Source
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.
Minds
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
Creating 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"
}
Get a Mind
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>
List all Minds
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, ....]
Drop a Mind
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.
Add a datasource to Mind
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
Remove a datasource from Mind
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
Chat with a mind
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
Development
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
TODO
- Chat completion - Need a valid response from minds staging env
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file minds_cli_sdk-1.0.3.tar.gz.
File metadata
- Download URL: minds_cli_sdk-1.0.3.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
998dd721428abcb8fc87f8fae65aaa0548eac755159770a6687fa49df5c9ae08
|
|
| MD5 |
acc6dc1131ba6e230c3696c844d33126
|
|
| BLAKE2b-256 |
50553fe17b207ce47218d6048fc20077048cf12eebf24a76860c4bf0e85d43c7
|