Skip to content

Commit

Permalink
refactor!: Change Ollama push model status type from enum to String (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmigloz authored and KennethKnudsen97 committed Oct 1, 2024
1 parent 5b75bb5 commit 76a6e55
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ class PushModelResponse with _$PushModelResponse {
/// Factory constructor for PushModelResponse
const factory PushModelResponse({
/// Status pushing the model.
@JsonKey(
includeIfNull: false,
unknownEnumValue: JsonKey.nullForUndefinedEnumValue,
)
PushModelStatus? status,
@JsonKey(includeIfNull: false) String? status,

/// the model's digest
@JsonKey(includeIfNull: false) String? digest,
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/ollama_dart/lib/src/generated/schema/schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ part 'pull_model_response.dart';
part 'pull_model_status.dart';
part 'push_model_request.dart';
part 'push_model_response.dart';
part 'push_model_status.dart';
39 changes: 12 additions & 27 deletions packages/ollama_dart/lib/src/generated/schema/schema.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7485,9 +7485,8 @@ PushModelResponse _$PushModelResponseFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$PushModelResponse {
/// Status pushing the model.
@JsonKey(
includeIfNull: false, unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
PushModelStatus? get status => throw _privateConstructorUsedError;
@JsonKey(includeIfNull: false)
String? get status => throw _privateConstructorUsedError;

/// the model's digest
@JsonKey(includeIfNull: false)
Expand All @@ -7514,10 +7513,7 @@ abstract class $PushModelResponseCopyWith<$Res> {
_$PushModelResponseCopyWithImpl<$Res, PushModelResponse>;
@useResult
$Res call(
{@JsonKey(
includeIfNull: false,
unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
PushModelStatus? status,
{@JsonKey(includeIfNull: false) String? status,
@JsonKey(includeIfNull: false) String? digest,
@JsonKey(includeIfNull: false) int? total,
@JsonKey(includeIfNull: false) int? completed});
Expand Down Expand Up @@ -7545,7 +7541,7 @@ class _$PushModelResponseCopyWithImpl<$Res, $Val extends PushModelResponse>
status: freezed == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as PushModelStatus?,
as String?,
digest: freezed == digest
? _value.digest
: digest // ignore: cast_nullable_to_non_nullable
Expand All @@ -7571,10 +7567,7 @@ abstract class _$$PushModelResponseImplCopyWith<$Res>
@override
@useResult
$Res call(
{@JsonKey(
includeIfNull: false,
unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
PushModelStatus? status,
{@JsonKey(includeIfNull: false) String? status,
@JsonKey(includeIfNull: false) String? digest,
@JsonKey(includeIfNull: false) int? total,
@JsonKey(includeIfNull: false) int? completed});
Expand All @@ -7600,7 +7593,7 @@ class __$$PushModelResponseImplCopyWithImpl<$Res>
status: freezed == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as PushModelStatus?,
as String?,
digest: freezed == digest
? _value.digest
: digest // ignore: cast_nullable_to_non_nullable
Expand All @@ -7621,10 +7614,7 @@ class __$$PushModelResponseImplCopyWithImpl<$Res>
@JsonSerializable()
class _$PushModelResponseImpl extends _PushModelResponse {
const _$PushModelResponseImpl(
{@JsonKey(
includeIfNull: false,
unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
this.status,
{@JsonKey(includeIfNull: false) this.status,
@JsonKey(includeIfNull: false) this.digest,
@JsonKey(includeIfNull: false) this.total,
@JsonKey(includeIfNull: false) this.completed})
Expand All @@ -7635,9 +7625,8 @@ class _$PushModelResponseImpl extends _PushModelResponse {

/// Status pushing the model.
@override
@JsonKey(
includeIfNull: false, unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
final PushModelStatus? status;
@JsonKey(includeIfNull: false)
final String? status;

/// the model's digest
@override
Expand Down Expand Up @@ -7693,10 +7682,7 @@ class _$PushModelResponseImpl extends _PushModelResponse {

abstract class _PushModelResponse extends PushModelResponse {
const factory _PushModelResponse(
{@JsonKey(
includeIfNull: false,
unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
final PushModelStatus? status,
{@JsonKey(includeIfNull: false) final String? status,
@JsonKey(includeIfNull: false) final String? digest,
@JsonKey(includeIfNull: false) final int? total,
@JsonKey(includeIfNull: false) final int? completed}) =
Expand All @@ -7709,9 +7695,8 @@ abstract class _PushModelResponse extends PushModelResponse {
@override

/// Status pushing the model.
@JsonKey(
includeIfNull: false, unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
PushModelStatus? get status;
@JsonKey(includeIfNull: false)
String? get status;
@override

/// the model's digest
Expand Down
12 changes: 2 additions & 10 deletions packages/ollama_dart/lib/src/generated/schema/schema.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions packages/ollama_dart/oas/ollama-curated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,8 @@ components:
description: Response class for pushing a model.
properties:
status:
$ref: '#/components/schemas/PushModelStatus'
type: string
description: Status pushing the model.
digest:
type: string
description: the model's digest
Expand All @@ -1052,11 +1053,3 @@ components:
format: int64
description: Total bytes transferred.
example: 2142590208
PushModelStatus:
type: string
description: Status pushing the model.
enum:
- retrieving manifest
- starting upload
- pushing manifest
- success
6 changes: 3 additions & 3 deletions packages/ollama_dart/test/ollama_dart_models_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void main() {
request: const PushModelRequest(model: 'mattw/pygmalion:latest'),
);

expect(res.status, PushModelStatus.success);
expect(res.status, equals('success'));
});

test('Test push model stream', skip: true, () async {
Expand All @@ -167,13 +167,13 @@ void main() {
);

int count = 0;
PushModelStatus? lastStatus;
String? lastStatus;
await for (final res in stream) {
lastStatus = res.status;
count++;
}
expect(count, greaterThan(1));
expect(lastStatus, equals(PushModelStatus.success));
expect(lastStatus, equals('success'));
});

test('Test check blob', skip: true, () async {
Expand Down

0 comments on commit 76a6e55

Please sign in to comment.