mistralai_client_dart 0.0.2 copy "mistralai_client_dart: ^0.0.2" to clipboard
mistralai_client_dart: ^0.0.2 copied to clipboard

This is an unofficial Dart/Flutter client for the Mistral AI API.

Mistral AI client for Dart #

.github/workflows/check.yaml style: very good analysis

Description #

This is an unofficial Dart/Flutter client for the Mistral AI API.

The implementation is inspired by the official Mistral AI JS client.

Overview (current state) #

The package is supporting Mistral AI API (0.0.1) at the moment.

Installation #

dart pub add mistralai_client_dart

Usage #

Create client #

import 'package:mistralai_client_dart/mistralai_client_dart.dart';

final client = MistralAIClient(apiKey: 'your api key here');

List models #

final modelsResult = await client.listModels();
final models = modelsResult.data.map((e) => e.id).toList();
print(models.join(', '));

Chat #

final params = ChatParams(
  model: 'mistral-tiny',
  messages: const [
    ChatMessage(role: 'user', content: 'Hello chat!'),
  ],
);
final chatCompletion = await client.chat(params);
final chatMessage = chatCompletion.choices[0].message;
print(chatMessage);

Chat stream #

final stream = client.streamChat(params);
await for (final completionChunk in stream) {
  final chatMessage = completionChunk.choices[0].delta?.content;
  if (chatMessage != null) {
    print(chatMessage);
  }
}

Embeddings #

final embeddings = await client.embeddings(
  const EmbeddingParams(
    model: 'mistral-embed',
    input: ['Hello chat!'],
  ),
);
for (final data in embeddings.data) {
  print(data.embedding);
}

Resources #

You can check the official Mistral AI docs.

Contributing #

For contributing guide please see CONTRIBUTING.md.

11
likes
0
pub points
36%
popularity

Publisher

verified publishernomtek.com

This is an unofficial Dart/Flutter client for the Mistral AI API.

Repository (GitHub)
View/report issues

Topics

#ai #nlp #llms #mistral

License

unknown (license)

Dependencies

http, json_annotation, meta

More

Packages that depend on mistralai_client_dart