Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 15, 2024
1 parent 0b3c24e commit 193be3e
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 34 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ jobs:
node-version: '18'

- name: Install dependencies
run: |
yarn install
run: yarn install

- name: Check types
run: |
yarn build
run: ./scripts/lint
test:
name: test
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 6
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-0a3089666368ff1ff668f2a73ea3b40d8b20420d8403a18579a1168dd67f2220.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-c28de228634e737a173375583a09eef5e0d7fa81fcdf7090d14d194e6ef4fdc5.yml
9 changes: 7 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ Types:
Types:

- <code><a href="./src/resources/audio/transcriptions.ts">Transcription</a></code>
- <code><a href="./src/resources/audio/transcriptions.ts">TranscriptionCreateResponse</a></code>

Methods:

- <code title="post /openai/v1/audio/transcriptions">client.audio.transcriptions.<a href="./src/resources/audio/transcriptions.ts">create</a>({ ...params }) -> Transcription</code>
- <code title="post /openai/v1/audio/transcriptions">client.audio.transcriptions.<a href="./src/resources/audio/transcriptions.ts">create</a>({ ...params }) -> TranscriptionCreateResponse</code>

## Translations

Types:

- <code><a href="./src/resources/audio/translations.ts">TranslationCreateResponse</a></code>

Methods:

- <code title="post /openai/v1/audio/translations">client.audio.translations.<a href="./src/resources/audio/translations.ts">create</a>({ ...params }) -> Translation</code>
- <code title="post /openai/v1/audio/translations">client.audio.translations.<a href="./src/resources/audio/translations.ts">create</a>({ ...params }) -> TranslationCreateResponse</code>

# Models

Expand Down
8 changes: 8 additions & 0 deletions scripts/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

echo "==> Running eslint --fix"
./node_modules/.bin/eslint --fix --ext ts,js .
1 change: 1 addition & 0 deletions scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ set -e

cd "$(dirname "$0")/.."

echo "==> Running eslint"
./node_modules/.bin/eslint --ext ts,js .
1 change: 0 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ else
echo
fi

# Run tests
echo "==> Running tests"
./node_modules/.bin/jest "$@"
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as Core from './core';
import * as Errors from './error';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import * as API from 'groq-sdk/resources/index';
import * as API from './resources/index';

export interface ClientOptions {
/**
Expand Down
10 changes: 6 additions & 4 deletions src/resources/audio/audio.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 { APIResource } from 'groq-sdk/resource';
import * as AudioAPI from 'groq-sdk/resources/audio/audio';
import * as TranscriptionsAPI from 'groq-sdk/resources/audio/transcriptions';
import * as TranslationsAPI from 'groq-sdk/resources/audio/translations';
import { APIResource } from '../../resource';
import * as AudioAPI from './audio';
import * as TranscriptionsAPI from './transcriptions';
import * as TranslationsAPI from './translations';

export class Audio extends APIResource {
transcriptions: TranscriptionsAPI.Transcriptions = new TranscriptionsAPI.Transcriptions(this._client);
Expand All @@ -18,7 +18,9 @@ export namespace Audio {
export import Translation = AudioAPI.Translation;
export import Transcriptions = TranscriptionsAPI.Transcriptions;
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionCreateResponse = TranscriptionsAPI.TranscriptionCreateResponse;
export import TranscriptionCreateParams = TranscriptionsAPI.TranscriptionCreateParams;
export import Translations = TranslationsAPI.Translations;
export import TranslationCreateResponse = TranslationsAPI.TranslationCreateResponse;
export import TranslationCreateParams = TranslationsAPI.TranslationCreateParams;
}
9 changes: 7 additions & 2 deletions src/resources/audio/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Transcription, TranscriptionCreateParams, Transcriptions } from './transcriptions';
export {
Transcription,
TranscriptionCreateResponse,
TranscriptionCreateParams,
Transcriptions,
} from './transcriptions';
export { Translation, Audio } from './audio';
export { TranslationCreateParams, Translations } from './translations';
export { TranslationCreateResponse, TranslationCreateParams, Translations } from './translations';
129 changes: 124 additions & 5 deletions src/resources/audio/transcriptions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

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

export class Transcriptions extends APIResource {
/**
* Transcribes audio into the input language.
*/
create(body: TranscriptionCreateParams, options?: Core.RequestOptions): Core.APIPromise<Transcription> {
create(
body: TranscriptionCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<TranscriptionCreateResponse> {
return this._client.post(
'/openai/v1/audio/transcriptions',
multipartFormRequestOptions({ body, ...options }),
Expand All @@ -28,6 +31,121 @@ export interface Transcription {
text: string;
}

/**
* Represents a transcription response returned by model, based on the provided
* input.
*/
export type TranscriptionCreateResponse =
| Transcription
| TranscriptionCreateResponse.CreateTranscriptionResponseVerboseJson;

export namespace TranscriptionCreateResponse {
/**
* Represents a verbose json transcription response returned by model, based on the
* provided input.
*/
export interface CreateTranscriptionResponseVerboseJson {
/**
* The duration of the input audio.
*/
duration: string;

/**
* The language of the input audio.
*/
language: string;

/**
* The transcribed text.
*/
text: string;

/**
* Segments of the transcribed text and their corresponding details.
*/
segments?: Array<CreateTranscriptionResponseVerboseJson.Segment>;

/**
* Extracted words and their corresponding timestamps.
*/
words?: Array<CreateTranscriptionResponseVerboseJson.Word>;
}

export namespace CreateTranscriptionResponseVerboseJson {
export interface Segment {
/**
* Unique identifier of the segment.
*/
id: number;

/**
* Average logprob of the segment. If the value is lower than -1, consider the
* logprobs failed.
*/
avg_logprob: number;

/**
* Compression ratio of the segment. If the value is greater than 2.4, consider the
* compression failed.
*/
compression_ratio: number;

/**
* End time of the segment in seconds.
*/
end: number;

/**
* Probability of no speech in the segment. If the value is higher than 1.0 and the
* `avg_logprob` is below -1, consider this segment silent.
*/
no_speech_prob: number;

/**
* Seek offset of the segment.
*/
seek: number;

/**
* Start time of the segment in seconds.
*/
start: number;

/**
* Temperature parameter used for generating the segment.
*/
temperature: number;

/**
* Text content of the segment.
*/
text: string;

/**
* Array of token IDs for the text content.
*/
tokens: Array<number>;
}

export interface Word {
/**
* End time of the word in seconds.
*/
end: number;

/**
* Start time of the word in seconds.
*/
start: number;

/**
* The text content of the word.
*/
word: string;
}
}
}

export interface TranscriptionCreateParams {
/**
* The audio file object (not file name) to transcribe, in one of these formats:
Expand Down Expand Up @@ -81,5 +199,6 @@ export interface TranscriptionCreateParams {

export namespace Transcriptions {
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionCreateResponse = TranscriptionsAPI.TranscriptionCreateResponse;
export import TranscriptionCreateParams = TranscriptionsAPI.TranscriptionCreateParams;
}
98 changes: 92 additions & 6 deletions src/resources/audio/translations.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from 'groq-sdk/core';
import { APIResource } from 'groq-sdk/resource';
import * as TranslationsAPI from 'groq-sdk/resources/audio/translations';
import * as AudioAPI from 'groq-sdk/resources/audio/audio';
import { type Uploadable, multipartFormRequestOptions } from 'groq-sdk/core';
import * as Core from '../../core';
import { APIResource } from '../../resource';
import * as TranslationsAPI from './translations';
import * as AudioAPI from './audio';
import { type Uploadable, multipartFormRequestOptions } from '../../core';

export class Translations extends APIResource {
/**
Expand All @@ -13,14 +13,99 @@ export class Translations extends APIResource {
create(
body: TranslationCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<AudioAPI.Translation> {
): Core.APIPromise<TranslationCreateResponse> {
return this._client.post(
'/openai/v1/audio/translations',
multipartFormRequestOptions({ body, ...options }),
);
}
}

export type TranslationCreateResponse =
| AudioAPI.Translation
| TranslationCreateResponse.CreateTranslationResponseVerboseJson;

export namespace TranslationCreateResponse {
export interface CreateTranslationResponseVerboseJson {
/**
* The duration of the input audio.
*/
duration: string;

/**
* The language of the output translation (always `english`).
*/
language: string;

/**
* The translated text.
*/
text: string;

/**
* Segments of the translated text and their corresponding details.
*/
segments?: Array<CreateTranslationResponseVerboseJson.Segment>;
}

export namespace CreateTranslationResponseVerboseJson {
export interface Segment {
/**
* Unique identifier of the segment.
*/
id: number;

/**
* Average logprob of the segment. If the value is lower than -1, consider the
* logprobs failed.
*/
avg_logprob: number;

/**
* Compression ratio of the segment. If the value is greater than 2.4, consider the
* compression failed.
*/
compression_ratio: number;

/**
* End time of the segment in seconds.
*/
end: number;

/**
* Probability of no speech in the segment. If the value is higher than 1.0 and the
* `avg_logprob` is below -1, consider this segment silent.
*/
no_speech_prob: number;

/**
* Seek offset of the segment.
*/
seek: number;

/**
* Start time of the segment in seconds.
*/
start: number;

/**
* Temperature parameter used for generating the segment.
*/
temperature: number;

/**
* Text content of the segment.
*/
text: string;

/**
* Array of token IDs for the text content.
*/
tokens: Array<number>;
}
}
}

export interface TranslationCreateParams {
/**
* The audio file object (not file name) translate, in one of these formats: flac,
Expand Down Expand Up @@ -57,5 +142,6 @@ export interface TranslationCreateParams {
}

export namespace Translations {
export import TranslationCreateResponse = TranslationsAPI.TranslationCreateResponse;
export import TranslationCreateParams = TranslationsAPI.TranslationCreateParams;
}
4 changes: 2 additions & 2 deletions src/resources/chat/chat.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 { APIResource } from 'groq-sdk/resource';
import * as CompletionsAPI from 'groq-sdk/resources/chat/completions';
import { APIResource } from '../../resource';
import * as CompletionsAPI from './completions';

export class Chat extends APIResource {
completions: CompletionsAPI.Completions = new CompletionsAPI.Completions(this._client);
Expand Down
Loading

0 comments on commit 193be3e

Please sign in to comment.