Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jun 26, 2024
1 parent ddd461e commit ecdf615
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-a4c1214ecaa24ad37fbb3c12b8392787ebe0fd51c5e7e08bdf25d7608dc7900b.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-d9cb66d87629b96a931ce71a189b1482b6ef980aec670e03ffaf75efde6f306a.yml
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from './core';
import * as Errors from './error';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import { type Agent } from './_shims/index';
import * as Core from './core';
import * as API from './resources/index';

export interface ClientOptions {
Expand Down Expand Up @@ -75,7 +75,9 @@ export interface ClientOptions {
dangerouslyAllowBrowser?: boolean;
}

/** API Client for interfacing with the Groq API. */
/**
* API Client for interfacing with the Groq API.
*/
export class Groq extends Core.APIClient {
apiKey: string;

Expand Down Expand Up @@ -124,6 +126,7 @@ export class Groq extends Core.APIClient {
maxRetries: options.maxRetries,
fetch: options.fetch,
});

this._options = options;

this.apiKey = apiKey;
Expand Down
109 changes: 104 additions & 5 deletions src/resources/audio/transcriptions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '../../core';
import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as TranscriptionsAPI from './transcriptions';
import { type Uploadable, multipartFormRequestOptions } from '../../core';

export class Transcriptions extends APIResource {
/**
Expand All @@ -12,7 +11,7 @@ export class Transcriptions extends APIResource {
create(body: TranscriptionCreateParams, options?: Core.RequestOptions): Core.APIPromise<Transcription> {
return this._client.post(
'/openai/v1/audio/transcriptions',
multipartFormRequestOptions({ body, ...options }),
Core.multipartFormRequestOptions({ body, ...options }),
);
}
}
Expand All @@ -33,7 +32,7 @@ export interface TranscriptionCreateParams {
* The audio file object (not file name) to transcribe, in one of these formats:
* flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
*/
file: Uploadable;
file: Core.Uploadable;

/**
* ID of the model to use. Only `whisper-large-v3` is currently available.
Expand All @@ -45,7 +44,107 @@ export interface TranscriptionCreateParams {
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will
* improve accuracy and latency.
*/
language?: string;
language?:
| 'en'
| 'zh'
| 'de'
| 'es'
| 'ru'
| 'ko'
| 'fr'
| 'ja'
| 'pt'
| 'tr'
| 'pl'
| 'ca'
| 'nl'
| 'ar'
| 'sv'
| 'it'
| 'id'
| 'hi'
| 'fi'
| 'vi'
| 'he'
| 'uk'
| 'el'
| 'ms'
| 'cs'
| 'ro'
| 'da'
| 'hu'
| 'ta'
| 'no'
| 'th'
| 'ur'
| 'hr'
| 'bg'
| 'lt'
| 'la'
| 'mi'
| 'ml'
| 'cy'
| 'sk'
| 'te'
| 'fa'
| 'lv'
| 'bn'
| 'sr'
| 'az'
| 'sl'
| 'kn'
| 'et'
| 'mk'
| 'br'
| 'eu'
| 'is'
| 'hy'
| 'ne'
| 'mn'
| 'bs'
| 'kk'
| 'sq'
| 'sw'
| 'gl'
| 'mr'
| 'pa'
| 'si'
| 'km'
| 'sn'
| 'yo'
| 'so'
| 'af'
| 'oc'
| 'ka'
| 'be'
| 'tg'
| 'sd'
| 'gu'
| 'am'
| 'yi'
| 'lo'
| 'uz'
| 'fo'
| 'ht'
| 'ps'
| 'tk'
| 'nn'
| 'mt'
| 'sa'
| 'lb'
| 'my'
| 'bo'
| 'tl'
| 'mg'
| 'as'
| 'tt'
| 'haw'
| 'ln'
| 'ha'
| 'ba'
| 'jw'
| 'su'
| 'yue';

/**
* An optional text to guide the model's style or continue a previous audio
Expand Down
7 changes: 3 additions & 4 deletions src/resources/audio/translations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '../../core';
import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as TranslationsAPI from './translations';
import { type Uploadable, multipartFormRequestOptions } from '../../core';

export class Translations extends APIResource {
/**
Expand All @@ -12,7 +11,7 @@ export class Translations extends APIResource {
create(body: TranslationCreateParams, options?: Core.RequestOptions): Core.APIPromise<Translation> {
return this._client.post(
'/openai/v1/audio/translations',
multipartFormRequestOptions({ body, ...options }),
Core.multipartFormRequestOptions({ body, ...options }),
);
}
}
Expand All @@ -26,7 +25,7 @@ export interface TranslationCreateParams {
* The audio file object (not file name) translate, in one of these formats: flac,
* mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
*/
file: Uploadable;
file: Core.Uploadable;

/**
* ID of the model to use. Only `whisper-large-v3` is currently available.
Expand Down
31 changes: 28 additions & 3 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '../../core';
import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as ChatCompletionsAPI from './completions';
import * as CompletionsAPI from '../completions';
import * as Shared from '../shared';
Expand Down Expand Up @@ -123,6 +123,11 @@ export interface ChatCompletionAssistantMessageParam {
*/
name?: string;

/**
* DO NOT USE. This field is present because OpenAI allows it and userssend it.
*/
tool_call_id?: string | null;

/**
* The tool calls generated by the model, such as function calls.
*/
Expand All @@ -141,12 +146,12 @@ export namespace ChatCompletionAssistantMessageParam {
* hallucinate parameters not defined by your function schema. Validate the
* arguments in your code before calling your function.
*/
arguments: string;
arguments?: string;

/**
* The name of the function to call.
*/
name: string;
name?: string;
}
}

Expand Down Expand Up @@ -392,6 +397,11 @@ export interface ChatCompletionFunctionMessageParam {
* The role of the messages author, in this case `function`.
*/
role: 'function';

/**
* DO NOT USE. This field is present because OpenAI allows it and users send it.
*/
tool_call_id?: string | null;
}

/**
Expand Down Expand Up @@ -528,6 +538,11 @@ export interface ChatCompletionSystemMessageParam {
* differentiate between participants of the same role.
*/
name?: string;

/**
* DO NOT USE. This field is present because OpenAI allows it and userssend it.
*/
tool_call_id?: string | null;
}

export interface ChatCompletionTokenLogprob {
Expand Down Expand Up @@ -620,6 +635,11 @@ export interface ChatCompletionToolMessageParam {
* Tool call that this message is responding to.
*/
tool_call_id: string;

/**
* DO NOT USE. This field is present because OpenAI allows it and userssend it.
*/
name?: string;
}

export interface ChatCompletionUserMessageParam {
Expand All @@ -638,6 +658,11 @@ export interface ChatCompletionUserMessageParam {
* differentiate between participants of the same role.
*/
name?: string;

/**
* DO NOT USE. This field is present because OpenAI allows it and userssend it.
*/
tool_call_id?: string | null;
}

export interface CompletionCreateParams {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/embeddings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '../core';
import { APIResource } from '../resource';
import * as Core from '../core';
import * as EmbeddingsAPI from './embeddings';

export class Embeddings extends APIResource {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/models.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '../core';
import { APIResource } from '../resource';
import * as Core from '../core';
import * as ModelsAPI from './models';

export class Models extends APIResource {
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/audio/transcriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('resource transcriptions', () => {
const response = await groq.audio.transcriptions.create({
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
model: 'whisper-large-v3',
language: 'string',
language: 'en',
prompt: 'string',
response_format: 'json',
temperature: 0,
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/chat/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('resource completions', () => {

test('create: required and optional params', async () => {
const response = await groq.chat.completions.create({
messages: [{ content: 'string', role: 'system', name: 'string' }],
messages: [{ content: 'string', role: 'system', name: 'string', tool_call_id: 'string' }],
model: 'string',
frequency_penalty: -2,
function_call: 'none',
Expand Down
9 changes: 6 additions & 3 deletions tests/stringifyQuery.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { APIClient } from 'groq-sdk/core';
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

const { stringifyQuery } = APIClient.prototype as any;
import { Groq } from 'groq-sdk';

describe('APIClient.stringifyQuery', () => {
const { stringifyQuery } = Groq.prototype as any;

describe(stringifyQuery, () => {
for (const [input, expected] of [
[{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'],
[{ a: null, b: false, c: undefined }, 'a=&b=false'],
Expand All @@ -18,6 +20,7 @@ describe('APIClient.stringifyQuery', () => {
expect(stringifyQuery(input)).toEqual(expected);
});
}

for (const value of [[], {}, new Date()]) {
it(`${JSON.stringify(value)} -> <error>`, () => {
expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`);
Expand Down

0 comments on commit ecdf615

Please sign in to comment.