Skip to content

🎯 MindsAI SDK for Dart for efficient interaction...

License

Notifications You must be signed in to change notification settings

ArnavK-09/mdb_dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Minds Dart 🎯


hero



pub verion repo size repo release Tests license

Note

A powerful and intuitive Dart SDK for interacting with the Minds AI API. Seamlessly integrate machine learning capabilities into your Dart applications!

πŸ“š Table of Contents


πŸš€ Features

  • πŸ” Secure API Authentication
    Safeguard your application with cutting-edge authentication methods that ensure your connection to the Minds API remains protected and confidential. Experience peace of mind while accessing advanced AI functionalities.

  • πŸ“Š Intuitive Data Source Management
    Easily manage and configure your data sources with sdk. Add, modify, or remove data connections effortlessly, allowing your AI models to access the most relevant and up-to-date information.

  • 🧠 Tailored AI Model Creation (Minds AI)
    Design bespoke AI models that suit your specific requirements. With our platform, you can create, customize, and optimize Minds that deliver personalized responses, making your applications smarter and more intuitive.

  • πŸ”„ Effortless Minds API Integration
    Experience a hassle-free integration with the Minds API, enabling you to tap into the full spectrum of AI capabilities quickly. Connect your systems and workflows seamlessly, enhancing your application’s functionality.

  • πŸ“‘ Real-time Interaction Capabilities
    Engage your users in real-time with interactive responses! Our real-time streaming support enables you to build applications that deliver immediate feedback, making conversations more dynamic and engaging.

  • πŸ“¦ Modular Architecture
    Benefit from a flexible, modular architecture that allows you to extend and customize the functionality of your application easily. Add new features and capabilities as your project evolves, ensuring long-term adaptability.

πŸŽͺ Installation

Add mdb_dart to your project!

terminal
dart pub add mdb_dart

🏁 Getting Started

Import the library and create a client:

import 'package:mdb_dart/mdb_dart.dart';

void main() async {
  final client = Client('YOUR_API_KEY');
  // Now you're ready to use the SDK!!!
}

Checkout demo code!


πŸ“˜ API Reference

Property Description
RestAPI api Instance for making API calls
Datasources datasources Manages data sources
Minds minds Manages minds (AI models)
Method Description
list() List all datasources
get(String name) Get a specific datasource
create(DatabaseConfig dsConfig, {bool replace = false}) Create a new datasource
drop(String name) Delete a datasource
Method Description
Datasource({String name, String engine, String description, Map<String, dynamic>? connectionData, List<String>? tables}) Creates a new Datasource instance with required parameters name, engine, description, and optional connectionData, tables. Inherits from DatabaseConfig.
fromJson(Map<String, dynamic> json) Creates a new Datasource instance from a JSON map. Inherited fields include name, engine, description, connectionData, and tables.
toJson() Converts the Datasource instance into a JSON-compatible map. Inherited from DatabaseConfig.
Method Description
list() List all minds (AI models)
get(String name) Get a specific mind (AI model)
create({required String name, modelName, provider, promptTemplate, datasources}) Create a new mind
drop(String name) Delete a mind
Method Description
update({String? name, modelName, provider, promptTemplate, datasources, parameters}) Updates the properties of the mind.
addDatasource(dynamic datasource) Adds a new datasource to the mind.
delDatasource(dynamic datasource) Deletes a specific datasource from the mind.
completion(String message) Sends a chat message to the Mind API and retrieves a completion response.
streamCompletion(String message) Streams chat completions from the Mind API based on a user's message.
fromJson(Client client, Map<String, dynamic> json) Creates a new instance of Mind from a JSON map.
toJson() Converts the Mind instance into a JSON map.

Exceptions

Exception Description
ObjectNotFound([String message = 'Object not found.']) Thrown when a requested object cannot be found.
ObjectAlreadyExists([String message = 'Object already exists.']) Thrown when trying to create an object that already exists.
ObjectNotSupported([String message = 'Object not supported.']) Thrown when an unsupported operation is attempted.
Forbidden([String message = 'Access forbidden.']) Thrown when access is forbidden.
Unauthorized([String message = 'Unauthorized access.']) Thrown when access is unauthorized.
UnknownError([String message = 'An unknown error occurred.']) Thrown for unspecified errors.
ValueError(String message) Thrown when a value is invalid or out of range.

🌟 Usage Examples

πŸ’Ώ Managing Datasources

List Datasources

List<Datasource> datasources = await client.datasources.list();
for (var ds in datasources) {
  print('Datasource: ${ds.name}');
}

Create a Datasource

final newDatasource = await client.datasources.create(
  DatabaseConfig(
    name: 'my_postgres_db',
    engine: 'postgres',
    description: 'My PostgreSQL Database',
    connectionData: {
      'host': 'localhost',
      'port': 5432,
      'user': 'username',
      'password': 'password',
      'database': 'mydb',
    },
  )
);
print('Created datasource: ${newDatasource.name}');

Get a Datasource

Datasource datasource = await client.datasources.get('my_postgres_db');
print('Datasource engine: ${datasource.engine}');

Delete a Datasource

await client.datasources.drop('my_postgres_db');
print('Datasource deleted successfully');

🧠 Managing Minds

List Minds

List<Mind> minds = await client.minds.list();
for (var mind in minds) {
  print('Mind: ${mind.name}');
}

Create a Mind

final newMind = await client.minds.create(
  name: 'my_predictor',
  modelName: 'gpt-4o',
  provider: 'openai',
  promptTemplate: 'Predict the next value: {{input}}',
  datasources: ['my_postgres_db'],
);
print('Created mind: ${newMind.name}');

Get a Mind

Mind mind = await client.minds.get('my_predictor');
print('Mind model: ${mind.modelName}');

Delete a Mind

await client.minds.drop('my_predictor');
print('Mind deleted successfully');

Using a Mind for Predictions

Mind mind = await client.minds.get('my_predictor');
final completion = await mind.completion('What will be the stock price tomorrow?');
print('Prediction: ${completion.choices.first.message.content?.first.text}');

Streaming Completions

Mind mind = await client.minds.get('my_predictor');
final stream = await mind.streamCompletion('Explain quantum computing');
await for (var chunk in stream) {
  print('Chunk: ${chunk.choices.first.delta.content?.first?.text}');
}

πŸ“Ή Contributing

We welcome contributions to improve and expand the Minds AI Dart SDK! To get started with contributing, please follow the guidelines outlined in our CONTRIBUTING file.

πŸ“„ License

This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.


If you find this project helpful, please give it a ⭐ on GitHub!


Warning

This repository is heavily influenced by the minds_python_sdk and mirrors its structure and functionality.