yandex_gpt_rest_api 0.4.0 copy "yandex_gpt_rest_api: ^0.4.0" to clipboard
yandex_gpt_rest_api: ^0.4.0 copied to clipboard

Dart package for calling the Foundation Models RESTfull API.

yandex_gpt_rest_api #

Test CI codecov

UNDER WORK #

The signature of the methods may change.

Getting started #

Create YandexGptApi instance.


final api = YandexGptApiClient(
  token: AuthToken.iam("your_token"),
  catalog: "your_catalog_id", // Not necessary
);

Now you can use the Foundation Models API.

API capabilities #

Text Generation #

Generate text

void main() async {
  final response = await api.generateText(
    TextGenerationRequest(
      modelUri: GModel.yandexGpt('folder_id'),
      messages: const [
        Message.system("Some joke"),
        Message.user("Generate joke"),
      ],
    ),
  );
  print(response.alternatives.first.message);
  print(response.usage.totalTokens);
}

Generate async text

UNDER_WORK

void main() async {
  final response = await api.generateAsyncText(
    TextGenerationRequest(
      model: GModel.yandexGpt('folder_id'),
      messages: const [
        Message.system("Some joke"),
        Message.user("Generate joke"),
      ],
    ),
  );
  print(response.done);
}

Tokenize #

Tokenize completion

void main() async {
  final response = await api.tokenizeCompletion(
    TextGenerationRequest(
      model: GModel.yandexGpt('folder_id'),
      messages: const [
        Message.system("Some joke"),
        Message.user("Generate joke"),
      ],
    ),
  );
  print(response.tokens.length);
}

Tokenize text

void main() async {
  final response = await api.tokenizeText(
    TokenizeTextRequest(
      model: GModel.yandexGpt('folder_id'),
      text: 'some_response_text',
    ),
  );
  print(response.tokens.length);
}

Embeddings #

void main() async {
  final response = await api.getTextEmbedding(
    EmbeddingRequest(
      model: VModel.documentation('folder_id'),
      text: 'Some text',
    ),
  );
  print(response.embedding);
}
3
likes
0
points
74
downloads

Publisher

unverified uploader

Weekly Downloads

Dart package for calling the Foundation Models RESTfull API.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

async, http

More

Packages that depend on yandex_gpt_rest_api