Skip to content

Commit

Permalink
feat: Add support for completions and embeddings in batch API in open…
Browse files Browse the repository at this point in the history
…ai_dart (#425)
  • Loading branch information
davidmigloz committed May 14, 2024
1 parent 71b116e commit 16fe4c6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/openai_dart/lib/src/generated/schema/batch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Batch with _$Batch {
/// The object type, which is always `batch`.
required BatchObject object,

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
required BatchEndpoint endpoint,

/// No Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ part of open_a_i_schema;
// ENUM: BatchEndpoint
// ==========================================

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
enum BatchEndpoint {
@JsonValue('/v1/chat/completions')
v1ChatCompletions,
@JsonValue('/v1/embeddings')
v1Embeddings,
@JsonValue('/v1/completions')
v1Completions,
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CreateBatchRequest with _$CreateBatchRequest {
/// Your input file must be formatted as a JSONL file, and must be uploaded with the purpose `batch`.
@JsonKey(name: 'input_file_id') required String inputFileId,

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
required BatchEndpoint endpoint,

/// The time frame within which the batch should be processed. Currently only `24h` is supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48058,7 +48058,7 @@ mixin _$CreateBatchRequest {
@JsonKey(name: 'input_file_id')
String get inputFileId => throw _privateConstructorUsedError;

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
BatchEndpoint get endpoint => throw _privateConstructorUsedError;

/// The time frame within which the batch should be processed. Currently only `24h` is supported.
Expand Down Expand Up @@ -48205,7 +48205,7 @@ class _$CreateBatchRequestImpl extends _CreateBatchRequest {
@JsonKey(name: 'input_file_id')
final String inputFileId;

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
@override
final BatchEndpoint endpoint;

Expand Down Expand Up @@ -48291,7 +48291,7 @@ abstract class _CreateBatchRequest extends CreateBatchRequest {
String get inputFileId;
@override

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
BatchEndpoint get endpoint;
@override

Expand Down Expand Up @@ -48321,7 +48321,7 @@ mixin _$Batch {
/// The object type, which is always `batch`.
BatchObject get object => throw _privateConstructorUsedError;

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
BatchEndpoint get endpoint => throw _privateConstructorUsedError;

/// No Description
Expand Down Expand Up @@ -48766,7 +48766,7 @@ class _$BatchImpl extends _Batch {
@override
final BatchObject object;

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
@override
final BatchEndpoint endpoint;

Expand Down Expand Up @@ -48986,7 +48986,7 @@ abstract class _Batch extends Batch {
BatchObject get object;
@override

/// The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
/// The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
BatchEndpoint get endpoint;
@override

Expand Down
2 changes: 2 additions & 0 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.

6 changes: 3 additions & 3 deletions packages/openai_dart/oas/openapi_curated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6130,8 +6130,8 @@ components:
nullable: true
BatchEndpoint:
type: string
enum: ["/v1/chat/completions"]
description: The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported.
enum: ["/v1/chat/completions", "/v1/embeddings", "/v1/completions"]
description: The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
BatchCompletionWindow:
type: string
enum: ["24h"]
Expand Down Expand Up @@ -6268,7 +6268,7 @@ components:
description: The HTTP method to be used for the request. Currently only `POST` is supported.
url:
type: string
description: The OpenAI API relative URL to be used for the request. Currently only `/v1/chat/completions` is supported.
description: The OpenAI API relative URL to be used for the request. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported.
BatchRequestOutput:
type: object
description: The per-line object of the batch output and error files
Expand Down

0 comments on commit 16fe4c6

Please sign in to comment.