minds-sdk


Nameminds-sdk JSON
Version 1.0.7 PyPI version JSON
download
home_pagehttps://github.com/mindsdb/minds_python_sdk
SummaryAn AI-Data Mind is an LLM with the built-in power to answer data questions for Agents
upload_time2024-09-26 18:05:07
maintainerNone
docs_urlNone
authorMindsDB Inc
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Minds SDK

### Installation

To install the SDK, use pip:

```bash
pip install minds-sdk
```

### Getting Started

1. Initialize the Client

To get started, you'll need to initialize the Client with your API key. If you're using a different server, you can also specify a custom base URL.

```python
from minds.client import Client

# Default connection to MindsDB Cloud
client = Client("YOUR_API_KEY")

# Custom MindsDB Cloud server
base_url = 'https://custom_cloud.mdb.ai/'
client = Client("YOUR_API_KEY", base_url)
```

2. Creating a Data Source

You can connect to various databases, such as PostgreSQL, by configuring your data source. Use the DatabaseConfig to define the connection details for your data source.

```python

from minds.datasources import DatabaseConfig

postgres_config = DatabaseConfig(
    name='my_datasource',
    description='<DESCRIPTION-OF-YOUR-DATA>',
    engine='postgres',
    connection_data={
        'user': 'demo_user',
        'password': 'demo_password',
        'host': 'samples.mindsdb.com',
        'port': 5432,
        'database': 'demo',
        'schema': 'demo_data'
    },
    tables=['<TABLE-1>', '<TABLE-2>']
)
```

3. Creating a Mind

You can create a `mind` and associate it with a data source.

```python

# Create a mind with a data source
mind = client.minds.create(name='mind_name', datasources=[postgres_config])

# Alternatively, create a data source separately and add it to a mind later
datasource = client.datasources.create(postgres_config)
mind2 = client.minds.create(name='mind_name', datasources=[datasource])
```

You can also add a data source to an existing mind:

```python

# Create a mind without a data source
mind3 = client.minds.create(name='mind_name')

# Add a data source to the mind
mind3.add_datasource(postgres_config)  # Using the config
mind3.add_datasource(datasource)       # Using the data source object
```

### Managing Minds

You can create a mind or replace an existing one with the same name.

```python

mind = client.minds.create(name='mind_name', replace=True, datasources=[postgres_config])
```

To update a mind, specify the new name and data sources. The provided data sources will replace the existing ones.

```python

mind.update(
    name='mind_name',
    datasources=[postgres_config]
)
```

#### List Minds

You can list all the minds you’ve created.

```python

print(client.minds.list())
```

#### Get a Mind by Name

You can fetch details of a mind by its name.

```python

mind = client.minds.get('mind_name')
```

#### Remove a Mind

To delete a mind, use the following command:

```python

client.minds.drop('mind_name')
```

### Managing Data Sources

To view all data sources:

```python

print(client.datasources.list())
```

#### Get a Data Source by Name

You can fetch details of a specific data source by its name.

```python

datasource = client.datasources.get('my_datasource')
```

#### Remove a Data Source

To delete a data source, use the following command:

```python

client.datasources.drop('my_datasource')
```
>Note: The SDK currently does not support automatically removing a data source if it is no longer connected to any mind.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mindsdb/minds_python_sdk",
    "name": "minds-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "MindsDB Inc",
    "author_email": "hello@mindsdb.com",
    "download_url": "https://files.pythonhosted.org/packages/63/69/d6bd50edd5c60d814e7e8c87595096f93e87118bc9d14b3d67d5cd3b9773/minds_sdk-1.0.7.tar.gz",
    "platform": null,
    "description": "# Minds SDK\n\n### Installation\n\nTo install the SDK, use pip:\n\n```bash\npip install minds-sdk\n```\n\n### Getting Started\n\n1. Initialize the Client\n\nTo get started, you'll need to initialize the Client with your API key. If you're using a different server, you can also specify a custom base URL.\n\n```python\nfrom minds.client import Client\n\n# Default connection to MindsDB Cloud\nclient = Client(\"YOUR_API_KEY\")\n\n# Custom MindsDB Cloud server\nbase_url = 'https://custom_cloud.mdb.ai/'\nclient = Client(\"YOUR_API_KEY\", base_url)\n```\n\n2. Creating a Data Source\n\nYou can connect to various databases, such as PostgreSQL, by configuring your data source. Use the DatabaseConfig to define the connection details for your data source.\n\n```python\n\nfrom minds.datasources import DatabaseConfig\n\npostgres_config = DatabaseConfig(\n    name='my_datasource',\n    description='<DESCRIPTION-OF-YOUR-DATA>',\n    engine='postgres',\n    connection_data={\n        'user': 'demo_user',\n        'password': 'demo_password',\n        'host': 'samples.mindsdb.com',\n        'port': 5432,\n        'database': 'demo',\n        'schema': 'demo_data'\n    },\n    tables=['<TABLE-1>', '<TABLE-2>']\n)\n```\n\n3. Creating a Mind\n\nYou can create a `mind` and associate it with a data source.\n\n```python\n\n# Create a mind with a data source\nmind = client.minds.create(name='mind_name', datasources=[postgres_config])\n\n# Alternatively, create a data source separately and add it to a mind later\ndatasource = client.datasources.create(postgres_config)\nmind2 = client.minds.create(name='mind_name', datasources=[datasource])\n```\n\nYou can also add a data source to an existing mind:\n\n```python\n\n# Create a mind without a data source\nmind3 = client.minds.create(name='mind_name')\n\n# Add a data source to the mind\nmind3.add_datasource(postgres_config)  # Using the config\nmind3.add_datasource(datasource)       # Using the data source object\n```\n\n### Managing Minds\n\nYou can create a mind or replace an existing one with the same name.\n\n```python\n\nmind = client.minds.create(name='mind_name', replace=True, datasources=[postgres_config])\n```\n\nTo update a mind, specify the new name and data sources. The provided data sources will replace the existing ones.\n\n```python\n\nmind.update(\n    name='mind_name',\n    datasources=[postgres_config]\n)\n```\n\n#### List Minds\n\nYou can list all the minds you\u2019ve created.\n\n```python\n\nprint(client.minds.list())\n```\n\n#### Get a Mind by Name\n\nYou can fetch details of a mind by its name.\n\n```python\n\nmind = client.minds.get('mind_name')\n```\n\n#### Remove a Mind\n\nTo delete a mind, use the following command:\n\n```python\n\nclient.minds.drop('mind_name')\n```\n\n### Managing Data Sources\n\nTo view all data sources:\n\n```python\n\nprint(client.datasources.list())\n```\n\n#### Get a Data Source by Name\n\nYou can fetch details of a specific data source by its name.\n\n```python\n\ndatasource = client.datasources.get('my_datasource')\n```\n\n#### Remove a Data Source\n\nTo delete a data source, use the following command:\n\n```python\n\nclient.datasources.drop('my_datasource')\n```\n>Note: The SDK currently does not support automatically removing a data source if it is no longer connected to any mind.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An AI-Data Mind is an LLM with the built-in power to answer data questions for Agents",
    "version": "1.0.7",
    "project_urls": {
        "Download": "https://pypi.org/project/mindsdb/",
        "Homepage": "https://github.com/mindsdb/minds_python_sdk"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6369d6bd50edd5c60d814e7e8c87595096f93e87118bc9d14b3d67d5cd3b9773",
                "md5": "ecdc99ca1e137eafe24d5efe7821829e",
                "sha256": "2fe5449bc715aec7a18f7a66698251487b70fcbb066b012fb16eb95cce63f33d"
            },
            "downloads": -1,
            "filename": "minds_sdk-1.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "ecdc99ca1e137eafe24d5efe7821829e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7323,
            "upload_time": "2024-09-26T18:05:07",
            "upload_time_iso_8601": "2024-09-26T18:05:07.274376Z",
            "url": "https://files.pythonhosted.org/packages/63/69/d6bd50edd5c60d814e7e8c87595096f93e87118bc9d14b3d67d5cd3b9773/minds_sdk-1.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-26 18:05:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mindsdb",
    "github_project": "minds_python_sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "minds-sdk"
}
        
Elapsed time: 0.34388s