From fad68ec83e20e2f6034dfcdf80b804ddd9145445 Mon Sep 17 00:00:00 2001 From: David Miguel Lozano Date: Sat, 25 May 2024 16:32:51 +0200 Subject: [PATCH] fix: Make vector store name optional in openai_dart (#436) --- packages/openai_dart/lib/openai_dart.dart | 2 +- .../schema/create_vector_store_request.dart | 10 +-- .../src/generated/schema/schema.freezed.dart | 67 ++++++++++--------- .../lib/src/generated/schema/schema.g.dart | 4 +- packages/openai_dart/oas/openapi_curated.yaml | 8 +-- packages/openai_dart/pubspec.yaml | 2 +- 6 files changed, 47 insertions(+), 46 deletions(-) diff --git a/packages/openai_dart/lib/openai_dart.dart b/packages/openai_dart/lib/openai_dart.dart index 87830981..7600ced2 100644 --- a/packages/openai_dart/lib/openai_dart.dart +++ b/packages/openai_dart/lib/openai_dart.dart @@ -1,4 +1,4 @@ -/// Dart Client for the OpenAI API (completions, chat, embeddings, etc.). +/// Dart client for the OpenAI API. Supports completions (GPT-3.5 Turbo), chat (GPT-4o, etc.), embeddings (Embedding v3), images (DALL·E 3), assistants v2 (threads, runs, vector stores, etc.) batch, fine-tuning, etc. library; export 'src/client.dart'; diff --git a/packages/openai_dart/lib/src/generated/schema/create_vector_store_request.dart b/packages/openai_dart/lib/src/generated/schema/create_vector_store_request.dart index cce0ccd3..bb9e83d7 100644 --- a/packages/openai_dart/lib/src/generated/schema/create_vector_store_request.dart +++ b/packages/openai_dart/lib/src/generated/schema/create_vector_store_request.dart @@ -15,12 +15,12 @@ class CreateVectorStoreRequest with _$CreateVectorStoreRequest { /// Factory constructor for CreateVectorStoreRequest const factory CreateVectorStoreRequest({ + /// The name of the vector store. + @JsonKey(includeIfNull: false) String? name, + /// A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. @JsonKey(name: 'file_ids', includeIfNull: false) List? fileIds, - /// The name of the vector store. - required String name, - /// The expiration policy for a vector store. @JsonKey(name: 'expires_after', includeIfNull: false) VectorStoreExpirationAfter? expiresAfter, @@ -35,8 +35,8 @@ class CreateVectorStoreRequest with _$CreateVectorStoreRequest { /// List of all property names of schema static const List propertyNames = [ - 'file_ids', 'name', + 'file_ids', 'expires_after', 'metadata' ]; @@ -49,8 +49,8 @@ class CreateVectorStoreRequest with _$CreateVectorStoreRequest { /// Map representation of object (not serialized) Map toMap() { return { - 'file_ids': fileIds, 'name': name, + 'file_ids': fileIds, 'expires_after': expiresAfter, 'metadata': metadata, }; diff --git a/packages/openai_dart/lib/src/generated/schema/schema.freezed.dart b/packages/openai_dart/lib/src/generated/schema/schema.freezed.dart index abfb4fc9..1395bc5a 100644 --- a/packages/openai_dart/lib/src/generated/schema/schema.freezed.dart +++ b/packages/openai_dart/lib/src/generated/schema/schema.freezed.dart @@ -44925,13 +44925,14 @@ CreateVectorStoreRequest _$CreateVectorStoreRequestFromJson( /// @nodoc mixin _$CreateVectorStoreRequest { + /// The name of the vector store. + @JsonKey(includeIfNull: false) + String? get name => throw _privateConstructorUsedError; + /// A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. @JsonKey(name: 'file_ids', includeIfNull: false) List? get fileIds => throw _privateConstructorUsedError; - /// The name of the vector store. - String get name => throw _privateConstructorUsedError; - /// The expiration policy for a vector store. @JsonKey(name: 'expires_after', includeIfNull: false) VectorStoreExpirationAfter? get expiresAfter => @@ -44954,8 +44955,8 @@ abstract class $CreateVectorStoreRequestCopyWith<$Res> { _$CreateVectorStoreRequestCopyWithImpl<$Res, CreateVectorStoreRequest>; @useResult $Res call( - {@JsonKey(name: 'file_ids', includeIfNull: false) List? fileIds, - String name, + {@JsonKey(includeIfNull: false) String? name, + @JsonKey(name: 'file_ids', includeIfNull: false) List? fileIds, @JsonKey(name: 'expires_after', includeIfNull: false) VectorStoreExpirationAfter? expiresAfter, @JsonKey(includeIfNull: false) dynamic metadata}); @@ -44977,20 +44978,20 @@ class _$CreateVectorStoreRequestCopyWithImpl<$Res, @pragma('vm:prefer-inline') @override $Res call({ + Object? name = freezed, Object? fileIds = freezed, - Object? name = null, Object? expiresAfter = freezed, Object? metadata = freezed, }) { return _then(_value.copyWith( + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, fileIds: freezed == fileIds ? _value.fileIds : fileIds // ignore: cast_nullable_to_non_nullable as List?, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, expiresAfter: freezed == expiresAfter ? _value.expiresAfter : expiresAfter // ignore: cast_nullable_to_non_nullable @@ -45026,8 +45027,8 @@ abstract class _$$CreateVectorStoreRequestImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: 'file_ids', includeIfNull: false) List? fileIds, - String name, + {@JsonKey(includeIfNull: false) String? name, + @JsonKey(name: 'file_ids', includeIfNull: false) List? fileIds, @JsonKey(name: 'expires_after', includeIfNull: false) VectorStoreExpirationAfter? expiresAfter, @JsonKey(includeIfNull: false) dynamic metadata}); @@ -45049,20 +45050,20 @@ class __$$CreateVectorStoreRequestImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ + Object? name = freezed, Object? fileIds = freezed, - Object? name = null, Object? expiresAfter = freezed, Object? metadata = freezed, }) { return _then(_$CreateVectorStoreRequestImpl( + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, fileIds: freezed == fileIds ? _value._fileIds : fileIds // ignore: cast_nullable_to_non_nullable as List?, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, expiresAfter: freezed == expiresAfter ? _value.expiresAfter : expiresAfter // ignore: cast_nullable_to_non_nullable @@ -45079,9 +45080,9 @@ class __$$CreateVectorStoreRequestImplCopyWithImpl<$Res> @JsonSerializable() class _$CreateVectorStoreRequestImpl extends _CreateVectorStoreRequest { const _$CreateVectorStoreRequestImpl( - {@JsonKey(name: 'file_ids', includeIfNull: false) + {@JsonKey(includeIfNull: false) this.name, + @JsonKey(name: 'file_ids', includeIfNull: false) final List? fileIds, - required this.name, @JsonKey(name: 'expires_after', includeIfNull: false) this.expiresAfter, @JsonKey(includeIfNull: false) this.metadata}) : _fileIds = fileIds, @@ -45090,6 +45091,11 @@ class _$CreateVectorStoreRequestImpl extends _CreateVectorStoreRequest { factory _$CreateVectorStoreRequestImpl.fromJson(Map json) => _$$CreateVectorStoreRequestImplFromJson(json); + /// The name of the vector store. + @override + @JsonKey(includeIfNull: false) + final String? name; + /// A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. final List? _fileIds; @@ -45104,10 +45110,6 @@ class _$CreateVectorStoreRequestImpl extends _CreateVectorStoreRequest { return EqualUnmodifiableListView(value); } - /// The name of the vector store. - @override - final String name; - /// The expiration policy for a vector store. @override @JsonKey(name: 'expires_after', includeIfNull: false) @@ -45120,7 +45122,7 @@ class _$CreateVectorStoreRequestImpl extends _CreateVectorStoreRequest { @override String toString() { - return 'CreateVectorStoreRequest(fileIds: $fileIds, name: $name, expiresAfter: $expiresAfter, metadata: $metadata)'; + return 'CreateVectorStoreRequest(name: $name, fileIds: $fileIds, expiresAfter: $expiresAfter, metadata: $metadata)'; } @override @@ -45128,8 +45130,8 @@ class _$CreateVectorStoreRequestImpl extends _CreateVectorStoreRequest { return identical(this, other) || (other.runtimeType == runtimeType && other is _$CreateVectorStoreRequestImpl && - const DeepCollectionEquality().equals(other._fileIds, _fileIds) && (identical(other.name, name) || other.name == name) && + const DeepCollectionEquality().equals(other._fileIds, _fileIds) && (identical(other.expiresAfter, expiresAfter) || other.expiresAfter == expiresAfter) && const DeepCollectionEquality().equals(other.metadata, metadata)); @@ -45139,8 +45141,8 @@ class _$CreateVectorStoreRequestImpl extends _CreateVectorStoreRequest { @override int get hashCode => Object.hash( runtimeType, - const DeepCollectionEquality().hash(_fileIds), name, + const DeepCollectionEquality().hash(_fileIds), expiresAfter, const DeepCollectionEquality().hash(metadata)); @@ -45161,9 +45163,9 @@ class _$CreateVectorStoreRequestImpl extends _CreateVectorStoreRequest { abstract class _CreateVectorStoreRequest extends CreateVectorStoreRequest { const factory _CreateVectorStoreRequest( - {@JsonKey(name: 'file_ids', includeIfNull: false) + {@JsonKey(includeIfNull: false) final String? name, + @JsonKey(name: 'file_ids', includeIfNull: false) final List? fileIds, - required final String name, @JsonKey(name: 'expires_after', includeIfNull: false) final VectorStoreExpirationAfter? expiresAfter, @JsonKey(includeIfNull: false) final dynamic metadata}) = @@ -45175,15 +45177,16 @@ abstract class _CreateVectorStoreRequest extends CreateVectorStoreRequest { @override + /// The name of the vector store. + @JsonKey(includeIfNull: false) + String? get name; + @override + /// A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. @JsonKey(name: 'file_ids', includeIfNull: false) List? get fileIds; @override - /// The name of the vector store. - String get name; - @override - /// The expiration policy for a vector store. @JsonKey(name: 'expires_after', includeIfNull: false) VectorStoreExpirationAfter? get expiresAfter; diff --git a/packages/openai_dart/lib/src/generated/schema/schema.g.dart b/packages/openai_dart/lib/src/generated/schema/schema.g.dart index eeb6a84e..4062dc95 100644 --- a/packages/openai_dart/lib/src/generated/schema/schema.g.dart +++ b/packages/openai_dart/lib/src/generated/schema/schema.g.dart @@ -4373,10 +4373,10 @@ Map _$$VectorStoreObjectFileCountsImplToJson( _$CreateVectorStoreRequestImpl _$$CreateVectorStoreRequestImplFromJson( Map json) => _$CreateVectorStoreRequestImpl( + name: json['name'] as String?, fileIds: (json['file_ids'] as List?) ?.map((e) => e as String) .toList(), - name: json['name'] as String, expiresAfter: json['expires_after'] == null ? null : VectorStoreExpirationAfter.fromJson( @@ -4394,8 +4394,8 @@ Map _$$CreateVectorStoreRequestImplToJson( } } + writeNotNull('name', instance.name); writeNotNull('file_ids', instance.fileIds); - val['name'] = instance.name; writeNotNull('expires_after', instance.expiresAfter?.toJson()); writeNotNull('metadata', instance.metadata); return val; diff --git a/packages/openai_dart/oas/openapi_curated.yaml b/packages/openai_dart/oas/openapi_curated.yaml index 46201dd4..b1a945bc 100644 --- a/packages/openai_dart/oas/openapi_curated.yaml +++ b/packages/openai_dart/oas/openapi_curated.yaml @@ -5669,23 +5669,21 @@ components: description: Request object for the Create assistant file endpoint. additionalProperties: false properties: + name: + description: The name of the vector store. + type: string file_ids: description: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. type: array maxItems: 500 items: type: string - name: - description: The name of the vector store. - type: string expires_after: $ref: "#/components/schemas/VectorStoreExpirationAfter" metadata: description: *metadata_description type: object nullable: true - required: - - name UpdateVectorStoreRequest: type: object description: Request object for the Update vector store endpoint. diff --git a/packages/openai_dart/pubspec.yaml b/packages/openai_dart/pubspec.yaml index e34a047d..ee8442e2 100644 --- a/packages/openai_dart/pubspec.yaml +++ b/packages/openai_dart/pubspec.yaml @@ -1,5 +1,5 @@ name: openai_dart -description: Dart Client for the OpenAI API (completions, chat, embeddings, etc.). +description: Dart client for the OpenAI API. Supports completions (GPT-3.5 Turbo), chat (GPT-4o, etc.), embeddings (Embedding v3), images (DALL·E 3), assistants v2 (threads, runs, vector stores, etc.) batch, fine-tuning, etc. version: 0.3.2+1 repository: https://github.com/davidmigloz/langchain_dart/tree/main/packages/openai_dart issue_tracker: https://github.com/davidmigloz/langchain_dart/issues?q=label:p:openai_dart