Skip to content

Commit

Permalink
fix: Make vector store name optional in openai_dart (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmigloz committed May 25, 2024
1 parent 7b9cf22 commit 29a46c7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion packages/openai_dart/lib/openai_dart.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>? 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,
Expand All @@ -35,8 +35,8 @@ class CreateVectorStoreRequest with _$CreateVectorStoreRequest {

/// List of all property names of schema
static const List<String> propertyNames = [
'file_ids',
'name',
'file_ids',
'expires_after',
'metadata'
];
Expand All @@ -49,8 +49,8 @@ class CreateVectorStoreRequest with _$CreateVectorStoreRequest {
/// Map representation of object (not serialized)
Map<String, dynamic> toMap() {
return {
'file_ids': fileIds,
'name': name,
'file_ids': fileIds,
'expires_after': expiresAfter,
'metadata': metadata,
};
Expand Down
67 changes: 35 additions & 32 deletions packages/openai_dart/lib/src/generated/schema/schema.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>? 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 =>
Expand All @@ -44954,8 +44955,8 @@ abstract class $CreateVectorStoreRequestCopyWith<$Res> {
_$CreateVectorStoreRequestCopyWithImpl<$Res, CreateVectorStoreRequest>;
@useResult
$Res call(
{@JsonKey(name: 'file_ids', includeIfNull: false) List<String>? fileIds,
String name,
{@JsonKey(includeIfNull: false) String? name,
@JsonKey(name: 'file_ids', includeIfNull: false) List<String>? fileIds,
@JsonKey(name: 'expires_after', includeIfNull: false)
VectorStoreExpirationAfter? expiresAfter,
@JsonKey(includeIfNull: false) dynamic metadata});
Expand All @@ -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<String>?,
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
Expand Down Expand Up @@ -45026,8 +45027,8 @@ abstract class _$$CreateVectorStoreRequestImplCopyWith<$Res>
@override
@useResult
$Res call(
{@JsonKey(name: 'file_ids', includeIfNull: false) List<String>? fileIds,
String name,
{@JsonKey(includeIfNull: false) String? name,
@JsonKey(name: 'file_ids', includeIfNull: false) List<String>? fileIds,
@JsonKey(name: 'expires_after', includeIfNull: false)
VectorStoreExpirationAfter? expiresAfter,
@JsonKey(includeIfNull: false) dynamic metadata});
Expand All @@ -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<String>?,
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
Expand All @@ -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<String>? fileIds,
required this.name,
@JsonKey(name: 'expires_after', includeIfNull: false) this.expiresAfter,
@JsonKey(includeIfNull: false) this.metadata})
: _fileIds = fileIds,
Expand All @@ -45090,6 +45091,11 @@ class _$CreateVectorStoreRequestImpl extends _CreateVectorStoreRequest {
factory _$CreateVectorStoreRequestImpl.fromJson(Map<String, dynamic> 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<String>? _fileIds;

Expand All @@ -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)
Expand All @@ -45120,16 +45122,16 @@ 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
bool operator ==(Object other) {
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));
Expand All @@ -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));

Expand All @@ -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<String>? fileIds,
required final String name,
@JsonKey(name: 'expires_after', includeIfNull: false)
final VectorStoreExpirationAfter? expiresAfter,
@JsonKey(includeIfNull: false) final dynamic metadata}) =
Expand All @@ -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<String>? 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;
Expand Down
4 changes: 2 additions & 2 deletions packages/openai_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.

8 changes: 3 additions & 5 deletions packages/openai_dart/oas/openapi_curated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/openai_dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 29a46c7

Please sign in to comment.