Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types): remove footgun with streaming params #125

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/resources/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Completions extends APIResource {
options?: Core.RequestOptions,
): APIPromise<Stream<Completion>>;
create(
body: CompletionCreateParams,
body: CompletionCreateParamsBase,
options?: Core.RequestOptions,
): APIPromise<Stream<Completion> | Completion>;
create(
Expand Down Expand Up @@ -52,7 +52,9 @@ export interface Completion {
stop_reason: string;
}

export interface CompletionCreateParams {
export type CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming;

export interface CompletionCreateParamsBase {
/**
* The maximum number of tokens to generate before stopping.
*
Expand Down Expand Up @@ -158,7 +160,7 @@ export namespace CompletionCreateParams {
export type CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;
}

export interface CompletionCreateParamsNonStreaming extends CompletionCreateParams {
export interface CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase {
/**
* Whether to incrementally stream the response using server-sent events.
*
Expand All @@ -169,7 +171,7 @@ export interface CompletionCreateParamsNonStreaming extends CompletionCreatePara
stream?: false;
}

export interface CompletionCreateParamsStreaming extends CompletionCreateParams {
export interface CompletionCreateParamsStreaming extends CompletionCreateParamsBase {
/**
* Whether to incrementally stream the response using server-sent events.
*
Expand Down