gigachat_dart

Last updated:

0 purchases

gigachat_dart Image
gigachat_dart Images
Add to Cart

Description:

gigachat dart

Gigachat Dart #




gigachat_dart #
Welcome to gigachat_dart, a Dart implementation of the GigaChat API. This project allows you to interact with the GigaChat API using the Dart programming language.
Features #

✅ Completion via Stream
✅ Get list of models
✅ Auto refresh token
✅ Completion via Future
✅ Embeddings
❌ Generate images (not tested)
❌ Get images (not tested)
❌ Functions (not tested)

Installation #
To install gigachat_dart, add the following dependency to your pubspec.yaml file:
dependencies:
gigachat_dart: ^0.1.2
copied to clipboard
Usage #
To use gigachat_dart, first initialize a new GigaChat client:
import 'package:gigachat_dart/gigachat_dart.dart';

final client = GigachatClient(
clientId: '<your uuid v4 id>',
clientSecret: '<your uuid v4 secret>');
# or

final client = GigachatClient.fromBase64(base64token: '<your base64 token>');

copied to clipboard
Then, you can use the client to interact with the GigaChat API:
final response = await client.generateAnswer(prompt: 'What is the capital of Russia?');
print(response.answer); // Output text: Moscow
copied to clipboard
For generate answer by dialog you may use generateChatCompletionStream, where event.choices![0].delta!.content contain generated text:
final r = await (c
.generateChatCompletionStream(
request: Chat(model: "GigaChat", messages: [
Message(role: MessageRole.user, content: "Почему небо голубое?")
]))
.listen((event) {
// event -- chunk of message wrapped in object, generated text in event.choices![0].delta!.content
}) // Stream
copied to clipboard
Or you can use as Future:
final r = await c.generateChatCompletion(
request: Chat(model: 'GigaChat', messages: [
Message(role: MessageRole.user, content: 'Why sky is blue?'),
Message(role: MessageRole.assistant, content: "Because!!!"),
Message(role: MessageRole.user, content: "Tell me more")
])); // generated text
copied to clipboard
Examples #
You can to read more examples in tests
License #
This project is licensed under the MIT License.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.