Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Fix AIMindTool import error with minds_sdk 2.0.0

Summary

Fixes issue #3885 where AIMindTool fails to initialize with ImportError claiming minds_sdk is not installed, even when it is. The root cause is that minds_sdk 2.0.0 changed its API structure - the DatabaseConfig class no longer exists.

Key changes:

  • Removed import of non-existent DatabaseConfig class
  • Updated to use new minds_sdk 2.0.0 API: minds_client.datasources.create() with individual parameters
  • Changed from passing DatabaseConfig objects to passing datasource name strings to minds.create()
  • Made description and connection_data optional with empty defaults (using .get())
  • Added comprehensive test suite (10 tests) covering the import fix and API changes

Note: The tables parameter from datasource config is no longer used, as it doesn't appear in the new minds_sdk 2.0.0 datasources.create() API.

Review & Testing Checklist for Human

This is a medium-risk change due to API compatibility assumptions and potential breaking changes:

  • Test with real minds_sdk 2.0.0: Install minds-sdk==2.0.0 and verify the tool works with an actual MindsDB instance. The unit tests use mocks and don't validate against the real API.
  • Verify API documentation: Check the minds_sdk 2.0.0 documentation to confirm the datasource creation API matches this implementation, especially:
    • Whether tables parameter should still be passed somewhere
    • Whether datasource names (strings) are the correct format for minds.create(datasources=...)
  • Check for breaking changes: The tables field is now ignored from datasource configs. Verify this doesn't break existing user workflows or if it needs to be documented as a breaking change.
  • Test datasource name generation: The prefix changed from crwai_ds_ to crwai_ds (removed underscore). Verify this doesn't cause naming conflicts.

Recommended test plan:

from crewai_tools import AIMindTool
import os

os.environ["MINDS_API_KEY"] = "your_api_key"

tool = AIMindTool(
    datasources=[{
        "description": "test database",
        "engine": "postgres",
        "connection_data": {
            "user": "test_user",
            "password": "test_pass",
            "host": "localhost",
            "port": 5432,
            "database": "test_db",
        },
        "tables": ["test_table"]  # verify this being ignored is OK
    }]
)

result = tool.run("How many rows are in test_table?")
print(result)

Notes

- Remove import of DatabaseConfig which no longer exists in minds_sdk 2.0.0
- Update code to use new minds_sdk API structure
- Create datasources directly via minds_client.datasources.create()
- Pass datasource names (strings) instead of DatabaseConfig objects to minds.create()
- Handle missing optional fields (description, connection_data) with defaults
- Add comprehensive tests to cover the import issue and prevent regression

Fixes #3885

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant