Skip to content

Commit

Permalink
version 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pwrshi committed May 29, 2024
1 parent 817d73c commit 3b0df5a
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 54 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"yaml.schemas": {
"openapi:v3": "file:///home/pwrshi/pets/gigachat_dart/oas/gigachat_offical.yaml"
}
},
"cSpell.words": [
"goptions",
"ndjson",
"PERS"
]
}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
- Initial version.

## 0.1.1
- Add scope option
- Add scope option

## 0.1.2
- Fix types in embeddings
- clean dependencies
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)
[![License: MIT][license_badge]][license_link]
[![Coverage](https://raw.githubusercontent.com/pwrshi/gigachat_dart/main/coverage_badge.svg)]()

# 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

- [x] Completion Stream
- [x] Completion via Stream
- [x] Get list of models
- [x] Auto refresh token
- [x] Completion Future
- [ ] Get image by id (not tested)
- [ ] Embeddings (not tested)
- [x] Completion via Future
- [x] Embeddings
- [ ] Generate images (not tested)
- [ ] Get images (not tested)
- [ ] Functions (not tested)



## Installation
Expand All @@ -23,7 +27,7 @@ To install gigachat_dart, add the following dependency to your `pubspec.yaml` fi

```yaml
dependencies:
gigachat_dart: ^0.1.0
gigachat_dart: ^0.1.2
```
## Usage
Expand Down Expand Up @@ -72,6 +76,10 @@ final r = await c.generateChatCompletion(
])); // generated text
```

## Examples

You can to read more examples in tests


## License

Expand Down
39 changes: 39 additions & 0 deletions coverage/lcov.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
SF:/home/pwrshi/pets/gigachat_dart/test/src/gigachat_dart_test.dart
DA:7,1
DA:9,2
DA:10,1
DA:11,2
DA:12,2
DA:15,2
DA:16,2
DA:17,1
DA:18,2
DA:19,5
DA:22,2
DA:23,1
DA:24,1
DA:26,2
DA:27,1
DA:31,1
DA:34,2
DA:35,1
DA:36,1
DA:39,2
DA:40,1
DA:44,1
DA:48,2
DA:49,2
DA:51,1
DA:52,1
DA:54,1
DA:55,1
DA:62,6
DA:63,1
DA:66,2
DA:67,2
DA:68,1
DA:69,2
DA:71,4
LF:35
LH:35
end_of_record
1 change: 1 addition & 0 deletions coverage/test/src/gigachat_dart_test.dart.vm.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GigachatClient {
);
}

/// Used for versioning between corporates or individuals,
/// Used for versioning between corporate or individuals,
/// GIGACHAT_API_CORP and GIGACHAT_API_PERS, respectively
late final String scope;
final _uuid = Uuid(goptions: GlobalOptions(CryptoRNG()));
Expand Down Expand Up @@ -84,7 +84,7 @@ class GigachatClient {
_client.bearerToken = token.accessToken!;
}

/// method check if token is null or exired then fetch new
/// method check if token is null or expired then fetch new
@protected
Future<void> checkAccessTokenValidity() async {
if (accessToken?.expiresAt == null ||
Expand All @@ -94,7 +94,7 @@ class GigachatClient {
}
}

/// return list of aviable models
/// return list of available models
Future<Models> getModels() async {
await checkAccessTokenValidity();
return _client.getModels();
Expand Down
8 changes: 4 additions & 4 deletions lib/src/generated/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class GigachatClient {
if (body != null) {
switch (requestType) {
case 'application/x-www-form-urlencoded':
List<String> parts = [];
var parts = <String>[];
Map<String, String> bodyMap =
Map<String, String>.from(body as Map<dynamic, dynamic>);

Expand Down Expand Up @@ -493,8 +493,9 @@ class GigachatClient {
/// `request`: No description
///
/// `POST` `https://gigachat.devices.sberbank.ru/api/v1/tokens/count`
// Future<TokensCount> postTokensCount({TokensCountBody? request,}) async {

// Future<TokensCount> postTokensCount({
// TokensCountBody? request,
// }) async {
// final r = await makeRequest(
// baseUrl: 'https://gigachat.devices.sberbank.ru/api/v1',
// path: '/tokens/count',
Expand All @@ -503,7 +504,6 @@ class GigachatClient {
// requestType: 'application/json',
// responseType: 'application/json',
// body: request,

// );
// return TokensCount.fromJson(_jsonDecode(r));
// }
Expand Down
2 changes: 1 addition & 1 deletion lib/src/generated/schema/embedding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class EmbeddingDataInner with _$EmbeddingDataInner {
required String object,

/// Массив чисел, представляющих значения эмбеддинга для предоставленного текста.
required List<int> embedding,
required List<double> embedding,

/// Индекс соответствующий индексу текста, полученного в массиве `input` запроса.
required int index,
Expand Down
1 change: 1 addition & 0 deletions lib/src/generated/schema/schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ part 'choices.dart';
part 'choices_chunk.dart';
part 'token.dart';
part 'tokens_count.dart';
part 'token_count_item.dart';
part 'embedding.dart';
part 'tokens_count_body.dart';
part 'embeddings_body.dart';
Expand Down
Loading

0 comments on commit 3b0df5a

Please sign in to comment.