From d6202e9b12fa79c69fbe65c58fc716cd464f52f0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:27:52 +0000 Subject: [PATCH] feat: update via SDK Studio (#5) --- bin/check-release-environment | 4 ++-- src/core.ts | 16 ------------- src/resources/chat/completions.ts | 37 +++---------------------------- 3 files changed, 5 insertions(+), 52 deletions(-) diff --git a/bin/check-release-environment b/bin/check-release-environment index 096d87a..47417cf 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -6,9 +6,9 @@ if [ -z "${NPM_TOKEN}" ]; then errors+=("The GROQ_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi -len=${#errors[@]} +lenErrors=${#errors[@]} -if [[ len -gt 0 ]]; then +if [[ lenErrors -gt 0 ]]; then echo -e "Found the following errors in the release environment:\n" for error in "${errors[@]}"; do diff --git a/src/core.ts b/src/core.ts index 4e476b7..6875045 100644 --- a/src/core.ts +++ b/src/core.ts @@ -1,5 +1,4 @@ import { VERSION } from './version'; -import { Stream } from './lib/streaming'; import { GroqError, APIError, @@ -39,19 +38,6 @@ type APIResponseProps = { async function defaultParseResponse(props: APIResponseProps): Promise { const { response } = props; - if (props.options.stream) { - debug('response', response.status, response.url, response.headers, response.body); - - // Note: there is an invariant here that isn't represented in the type system - // that if you set `stream: true` the response type must also be `Stream` - - if (props.options.__streamClass) { - return props.options.__streamClass.fromSSEResponse(response, props.controller) as any; - } - - return Stream.fromSSEResponse(response, props.controller) as any; - } - // fetch refuses to read the body when the status code is 204. if (response.status === 204) { return null as T; @@ -750,7 +736,6 @@ export type RequestOptions | Readable> = idempotencyKey?: string; __binaryResponse?: boolean | undefined; - __streamClass?: typeof Stream; }; // This is required so that we can determine if a given object matches the RequestOptions @@ -771,7 +756,6 @@ const requestOptionsKeys: KeysEnum = { idempotencyKey: true, __binaryResponse: true, - __streamClass: true, }; export const isRequestOptions = (obj: unknown): obj is RequestOptions => { diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 55c210b..a4db5f6 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -3,32 +3,13 @@ import * as Core from 'groq-sdk/core'; import { APIResource } from 'groq-sdk/resource'; import * as CompletionsAPI from 'groq-sdk/resources/chat/completions'; -import { Stream } from 'groq-sdk/lib/streaming'; -import { ChatCompletionChunk } from 'groq-sdk/lib/chat_completions_ext'; export class Completions extends APIResource { /** * Creates a completion for a chat prompt */ - create( - body: ChatCompletionCreateParamsNonStreaming, - options?: Core.RequestOptions, - ): Core.APIPromise; - create( - body: ChatCompletionCreateParamsStreaming, - options?: Core.RequestOptions, - ): Core.APIPromise>; - create( - body: ChatCompletionCreateParamsBase, - options?: Core.RequestOptions, - ): Core.APIPromise | ChatCompletion>; - create( - body: ChatCompletionCreateParams, - options?: Core.RequestOptions, - ): Core.APIPromise | Core.APIPromise> { - return this._client.post('/openai/v1/chat/completions', { body, ...options, stream: body.stream ?? false }) as - | Core.APIPromise - | Core.APIPromise>; + create(body: CompletionCreateParams, options?: Core.RequestOptions): Core.APIPromise { + return this._client.post('/openai/v1/chat/completions', { body, ...options }); } } @@ -128,7 +109,7 @@ export namespace ChatCompletion { } } -export interface ChatCompletionCreateParamsBase { +export interface CompletionCreateParams { messages: Array; model: string; @@ -252,15 +233,3 @@ export namespace Completions { export import ChatCompletion = CompletionsAPI.ChatCompletion; export import CompletionCreateParams = CompletionsAPI.CompletionCreateParams; } - -export interface ChatCompletionCreateParamsNonStreaming extends ChatCompletionCreateParamsBase { - stream?: false; -} - -export interface ChatCompletionCreateParamsStreaming extends ChatCompletionCreateParamsBase { - stream: true; -} - -export type ChatCompletionCreateParams = - | ChatCompletionCreateParamsNonStreaming - | ChatCompletionCreateParamsStreaming;