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

Communicating with the Yandex Foundation Models API.

yandex_gpt_rest_api #

Library for communicating with the Yandex Foundation Models API.

UNDER WORK #

Receiving data from the API is now working.

Asynchronous generation does not work.

The signature of the methods may change.

Getting started #

Create YandexGptApi instance.

final api = YandexGptApiClient(
  token: "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

Communicating with the Yandex Foundation Models API.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

async, http

More

Packages that depend on yandex_gpt_rest_api