V1 with working cmdline interface for easy of using GIT
This commit is contained in:
+78
@@ -0,0 +1,78 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as SpeechAPI from './speech';
|
||||
import { Speech, SpeechCreateParams, SpeechModel } from './speech';
|
||||
import * as TranscriptionsAPI from './transcriptions';
|
||||
import {
|
||||
Transcription,
|
||||
TranscriptionCreateParams,
|
||||
TranscriptionCreateParamsNonStreaming,
|
||||
TranscriptionCreateParamsStreaming,
|
||||
TranscriptionCreateResponse,
|
||||
TranscriptionInclude,
|
||||
TranscriptionSegment,
|
||||
TranscriptionStreamEvent,
|
||||
TranscriptionTextDeltaEvent,
|
||||
TranscriptionTextDoneEvent,
|
||||
TranscriptionVerbose,
|
||||
TranscriptionWord,
|
||||
Transcriptions,
|
||||
} from './transcriptions';
|
||||
import * as TranslationsAPI from './translations';
|
||||
import {
|
||||
Translation,
|
||||
TranslationCreateParams,
|
||||
TranslationCreateResponse,
|
||||
TranslationVerbose,
|
||||
Translations,
|
||||
} from './translations';
|
||||
|
||||
export class Audio extends APIResource {
|
||||
transcriptions: TranscriptionsAPI.Transcriptions = new TranscriptionsAPI.Transcriptions(this._client);
|
||||
translations: TranslationsAPI.Translations = new TranslationsAPI.Translations(this._client);
|
||||
speech: SpeechAPI.Speech = new SpeechAPI.Speech(this._client);
|
||||
}
|
||||
|
||||
export type AudioModel = 'whisper-1' | 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe';
|
||||
|
||||
/**
|
||||
* The format of the output, in one of these options: `json`, `text`, `srt`,
|
||||
* `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
|
||||
* the only supported format is `json`.
|
||||
*/
|
||||
export type AudioResponseFormat = 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
|
||||
|
||||
Audio.Transcriptions = Transcriptions;
|
||||
Audio.Translations = Translations;
|
||||
Audio.Speech = Speech;
|
||||
|
||||
export declare namespace Audio {
|
||||
export { type AudioModel as AudioModel, type AudioResponseFormat as AudioResponseFormat };
|
||||
|
||||
export {
|
||||
Transcriptions as Transcriptions,
|
||||
type Transcription as Transcription,
|
||||
type TranscriptionInclude as TranscriptionInclude,
|
||||
type TranscriptionSegment as TranscriptionSegment,
|
||||
type TranscriptionStreamEvent as TranscriptionStreamEvent,
|
||||
type TranscriptionTextDeltaEvent as TranscriptionTextDeltaEvent,
|
||||
type TranscriptionTextDoneEvent as TranscriptionTextDoneEvent,
|
||||
type TranscriptionVerbose as TranscriptionVerbose,
|
||||
type TranscriptionWord as TranscriptionWord,
|
||||
type TranscriptionCreateResponse as TranscriptionCreateResponse,
|
||||
type TranscriptionCreateParams as TranscriptionCreateParams,
|
||||
type TranscriptionCreateParamsNonStreaming as TranscriptionCreateParamsNonStreaming,
|
||||
type TranscriptionCreateParamsStreaming as TranscriptionCreateParamsStreaming,
|
||||
};
|
||||
|
||||
export {
|
||||
Translations as Translations,
|
||||
type Translation as Translation,
|
||||
type TranslationVerbose as TranslationVerbose,
|
||||
type TranslationCreateResponse as TranslationCreateResponse,
|
||||
type TranslationCreateParams as TranslationCreateParams,
|
||||
};
|
||||
|
||||
export { Speech as Speech, type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Audio, type AudioModel, type AudioResponseFormat } from './audio';
|
||||
export { Speech, type SpeechModel, type SpeechCreateParams } from './speech';
|
||||
export {
|
||||
Transcriptions,
|
||||
type Transcription,
|
||||
type TranscriptionInclude,
|
||||
type TranscriptionSegment,
|
||||
type TranscriptionStreamEvent,
|
||||
type TranscriptionTextDeltaEvent,
|
||||
type TranscriptionTextDoneEvent,
|
||||
type TranscriptionVerbose,
|
||||
type TranscriptionWord,
|
||||
type TranscriptionCreateResponse,
|
||||
type TranscriptionCreateParams,
|
||||
type TranscriptionCreateParamsNonStreaming,
|
||||
type TranscriptionCreateParamsStreaming,
|
||||
} from './transcriptions';
|
||||
export {
|
||||
Translations,
|
||||
type Translation,
|
||||
type TranslationVerbose,
|
||||
type TranslationCreateResponse,
|
||||
type TranslationCreateParams,
|
||||
} from './translations';
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as Core from '../../core';
|
||||
import { type Response } from '../../_shims/index';
|
||||
|
||||
export class Speech extends APIResource {
|
||||
/**
|
||||
* Generates audio from the input text.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const speech = await client.audio.speech.create({
|
||||
* input: 'input',
|
||||
* model: 'string',
|
||||
* voice: 'ash',
|
||||
* });
|
||||
*
|
||||
* const content = await speech.blob();
|
||||
* console.log(content);
|
||||
* ```
|
||||
*/
|
||||
create(body: SpeechCreateParams, options?: Core.RequestOptions): Core.APIPromise<Response> {
|
||||
return this._client.post('/audio/speech', {
|
||||
body,
|
||||
...options,
|
||||
headers: { Accept: 'application/octet-stream', ...options?.headers },
|
||||
__binaryResponse: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export type SpeechModel = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts';
|
||||
|
||||
export interface SpeechCreateParams {
|
||||
/**
|
||||
* The text to generate audio for. The maximum length is 4096 characters.
|
||||
*/
|
||||
input: string;
|
||||
|
||||
/**
|
||||
* One of the available [TTS models](https://platform.openai.com/docs/models#tts):
|
||||
* `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
|
||||
*/
|
||||
model: (string & {}) | SpeechModel;
|
||||
|
||||
/**
|
||||
* The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
|
||||
* `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
|
||||
* `verse`. Previews of the voices are available in the
|
||||
* [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
|
||||
*/
|
||||
voice:
|
||||
| (string & {})
|
||||
| 'alloy'
|
||||
| 'ash'
|
||||
| 'ballad'
|
||||
| 'coral'
|
||||
| 'echo'
|
||||
| 'fable'
|
||||
| 'onyx'
|
||||
| 'nova'
|
||||
| 'sage'
|
||||
| 'shimmer'
|
||||
| 'verse';
|
||||
|
||||
/**
|
||||
* Control the voice of your generated audio with additional instructions. Does not
|
||||
* work with `tts-1` or `tts-1-hd`.
|
||||
*/
|
||||
instructions?: string;
|
||||
|
||||
/**
|
||||
* The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
|
||||
* `wav`, and `pcm`.
|
||||
*/
|
||||
response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
|
||||
|
||||
/**
|
||||
* The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
|
||||
* the default. Does not work with `gpt-4o-mini-tts`.
|
||||
*/
|
||||
speed?: number;
|
||||
}
|
||||
|
||||
export declare namespace Speech {
|
||||
export { type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
|
||||
}
|
||||
+473
@@ -0,0 +1,473 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as Core from '../../core';
|
||||
import * as TranscriptionsAPI from './transcriptions';
|
||||
import * as AudioAPI from './audio';
|
||||
import { Stream } from '../../streaming';
|
||||
|
||||
export class Transcriptions extends APIResource {
|
||||
/**
|
||||
* Transcribes audio into the input language.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const transcription =
|
||||
* await client.audio.transcriptions.create({
|
||||
* file: fs.createReadStream('speech.mp3'),
|
||||
* model: 'gpt-4o-transcribe',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
create(
|
||||
body: TranscriptionCreateParamsNonStreaming<'json' | undefined>,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<Transcription>;
|
||||
create(
|
||||
body: TranscriptionCreateParamsNonStreaming<'verbose_json'>,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<TranscriptionVerbose>;
|
||||
create(
|
||||
body: TranscriptionCreateParamsNonStreaming<'srt' | 'vtt' | 'text'>,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<string>;
|
||||
create(
|
||||
body: TranscriptionCreateParamsNonStreaming,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<Transcription>;
|
||||
create(
|
||||
body: TranscriptionCreateParamsStreaming,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<Stream<TranscriptionStreamEvent>>;
|
||||
create(
|
||||
body: TranscriptionCreateParamsStreaming,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<TranscriptionCreateResponse | string | Stream<TranscriptionStreamEvent>>;
|
||||
create(
|
||||
body: TranscriptionCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<TranscriptionCreateResponse | string | Stream<TranscriptionStreamEvent>> {
|
||||
return this._client.post(
|
||||
'/audio/transcriptions',
|
||||
Core.multipartFormRequestOptions({
|
||||
body,
|
||||
...options,
|
||||
stream: body.stream ?? false,
|
||||
__metadata: { model: body.model },
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a transcription response returned by model, based on the provided
|
||||
* input.
|
||||
*/
|
||||
export interface Transcription {
|
||||
/**
|
||||
* The transcribed text.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The log probabilities of the tokens in the transcription. Only returned with the
|
||||
* models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added
|
||||
* to the `include` array.
|
||||
*/
|
||||
logprobs?: Array<Transcription.Logprob>;
|
||||
}
|
||||
|
||||
export namespace Transcription {
|
||||
export interface Logprob {
|
||||
/**
|
||||
* The token in the transcription.
|
||||
*/
|
||||
token?: string;
|
||||
|
||||
/**
|
||||
* The bytes of the token.
|
||||
*/
|
||||
bytes?: Array<number>;
|
||||
|
||||
/**
|
||||
* The log probability of the token.
|
||||
*/
|
||||
logprob?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export type TranscriptionInclude = 'logprobs';
|
||||
|
||||
export interface TranscriptionSegment {
|
||||
/**
|
||||
* 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>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted when there is an additional text delta. This is also the first event
|
||||
* emitted when the transcription starts. Only emitted when you
|
||||
* [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
||||
* with the `Stream` parameter set to `true`.
|
||||
*/
|
||||
export type TranscriptionStreamEvent = TranscriptionTextDeltaEvent | TranscriptionTextDoneEvent;
|
||||
|
||||
/**
|
||||
* Emitted when there is an additional text delta. This is also the first event
|
||||
* emitted when the transcription starts. Only emitted when you
|
||||
* [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
||||
* with the `Stream` parameter set to `true`.
|
||||
*/
|
||||
export interface TranscriptionTextDeltaEvent {
|
||||
/**
|
||||
* The text delta that was additionally transcribed.
|
||||
*/
|
||||
delta: string;
|
||||
|
||||
/**
|
||||
* The type of the event. Always `transcript.text.delta`.
|
||||
*/
|
||||
type: 'transcript.text.delta';
|
||||
|
||||
/**
|
||||
* The log probabilities of the delta. Only included if you
|
||||
* [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
||||
* with the `include[]` parameter set to `logprobs`.
|
||||
*/
|
||||
logprobs?: Array<TranscriptionTextDeltaEvent.Logprob>;
|
||||
}
|
||||
|
||||
export namespace TranscriptionTextDeltaEvent {
|
||||
export interface Logprob {
|
||||
/**
|
||||
* The token that was used to generate the log probability.
|
||||
*/
|
||||
token?: string;
|
||||
|
||||
/**
|
||||
* The bytes that were used to generate the log probability.
|
||||
*/
|
||||
bytes?: Array<unknown>;
|
||||
|
||||
/**
|
||||
* The log probability of the token.
|
||||
*/
|
||||
logprob?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted when the transcription is complete. Contains the complete transcription
|
||||
* text. Only emitted when you
|
||||
* [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
||||
* with the `Stream` parameter set to `true`.
|
||||
*/
|
||||
export interface TranscriptionTextDoneEvent {
|
||||
/**
|
||||
* The text that was transcribed.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the event. Always `transcript.text.done`.
|
||||
*/
|
||||
type: 'transcript.text.done';
|
||||
|
||||
/**
|
||||
* The log probabilities of the individual tokens in the transcription. Only
|
||||
* included if you
|
||||
* [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
||||
* with the `include[]` parameter set to `logprobs`.
|
||||
*/
|
||||
logprobs?: Array<TranscriptionTextDoneEvent.Logprob>;
|
||||
}
|
||||
|
||||
export namespace TranscriptionTextDoneEvent {
|
||||
export interface Logprob {
|
||||
/**
|
||||
* The token that was used to generate the log probability.
|
||||
*/
|
||||
token?: string;
|
||||
|
||||
/**
|
||||
* The bytes that were used to generate the log probability.
|
||||
*/
|
||||
bytes?: Array<unknown>;
|
||||
|
||||
/**
|
||||
* The log probability of the token.
|
||||
*/
|
||||
logprob?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a verbose json transcription response returned by model, based on the
|
||||
* provided input.
|
||||
*/
|
||||
export interface TranscriptionVerbose {
|
||||
/**
|
||||
* The duration of the input audio.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* The language of the input audio.
|
||||
*/
|
||||
language: string;
|
||||
|
||||
/**
|
||||
* The transcribed text.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Segments of the transcribed text and their corresponding details.
|
||||
*/
|
||||
segments?: Array<TranscriptionSegment>;
|
||||
|
||||
/**
|
||||
* Extracted words and their corresponding timestamps.
|
||||
*/
|
||||
words?: Array<TranscriptionWord>;
|
||||
}
|
||||
|
||||
export interface TranscriptionWord {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a transcription response returned by model, based on the provided
|
||||
* input.
|
||||
*/
|
||||
export type TranscriptionCreateResponse = Transcription | TranscriptionVerbose;
|
||||
|
||||
export type TranscriptionCreateParams<
|
||||
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
|
||||
> = TranscriptionCreateParamsNonStreaming<ResponseFormat> | TranscriptionCreateParamsStreaming;
|
||||
|
||||
export interface TranscriptionCreateParamsBase<
|
||||
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
|
||||
> {
|
||||
/**
|
||||
* 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: Core.Uploadable;
|
||||
|
||||
/**
|
||||
* ID of the model to use. The options are `gpt-4o-transcribe`,
|
||||
* `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
|
||||
* Whisper V2 model).
|
||||
*/
|
||||
model: (string & {}) | AudioAPI.AudioModel;
|
||||
|
||||
/**
|
||||
* Controls how the audio is cut into chunks. When set to `"auto"`, the server
|
||||
* first normalizes loudness and then uses voice activity detection (VAD) to choose
|
||||
* boundaries. `server_vad` object can be provided to tweak VAD detection
|
||||
* parameters manually. If unset, the audio is transcribed as a single block.
|
||||
*/
|
||||
chunking_strategy?: 'auto' | TranscriptionCreateParams.VadConfig | null;
|
||||
|
||||
/**
|
||||
* Additional information to include in the transcription response. `logprobs` will
|
||||
* return the log probabilities of the tokens in the response to understand the
|
||||
* model's confidence in the transcription. `logprobs` only works with
|
||||
* response_format set to `json` and only with the models `gpt-4o-transcribe` and
|
||||
* `gpt-4o-mini-transcribe`.
|
||||
*/
|
||||
include?: Array<TranscriptionInclude>;
|
||||
|
||||
/**
|
||||
* The language of the input audio. Supplying the input language in
|
||||
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
|
||||
* format will improve accuracy and latency.
|
||||
*/
|
||||
language?: string;
|
||||
|
||||
/**
|
||||
* An optional text to guide the model's style or continue a previous audio
|
||||
* segment. The
|
||||
* [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
|
||||
* should match the audio language.
|
||||
*/
|
||||
prompt?: string;
|
||||
|
||||
/**
|
||||
* The format of the output, in one of these options: `json`, `text`, `srt`,
|
||||
* `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
|
||||
* the only supported format is `json`.
|
||||
*/
|
||||
response_format?: ResponseFormat;
|
||||
|
||||
/**
|
||||
* If set to true, the model response data will be streamed to the client as it is
|
||||
* generated using
|
||||
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
|
||||
* See the
|
||||
* [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)
|
||||
* for more information.
|
||||
*
|
||||
* Note: Streaming is not supported for the `whisper-1` model and will be ignored.
|
||||
*/
|
||||
stream?: boolean | null;
|
||||
|
||||
/**
|
||||
* The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
|
||||
* output more random, while lower values like 0.2 will make it more focused and
|
||||
* deterministic. If set to 0, the model will use
|
||||
* [log probability](https://en.wikipedia.org/wiki/Log_probability) to
|
||||
* automatically increase the temperature until certain thresholds are hit.
|
||||
*/
|
||||
temperature?: number;
|
||||
|
||||
/**
|
||||
* The timestamp granularities to populate for this transcription.
|
||||
* `response_format` must be set `verbose_json` to use timestamp granularities.
|
||||
* Either or both of these options are supported: `word`, or `segment`. Note: There
|
||||
* is no additional latency for segment timestamps, but generating word timestamps
|
||||
* incurs additional latency.
|
||||
*/
|
||||
timestamp_granularities?: Array<'word' | 'segment'>;
|
||||
}
|
||||
|
||||
export namespace TranscriptionCreateParams {
|
||||
export interface VadConfig {
|
||||
/**
|
||||
* Must be set to `server_vad` to enable manual chunking using server side VAD.
|
||||
*/
|
||||
type: 'server_vad';
|
||||
|
||||
/**
|
||||
* Amount of audio to include before the VAD detected speech (in milliseconds).
|
||||
*/
|
||||
prefix_padding_ms?: number;
|
||||
|
||||
/**
|
||||
* Duration of silence to detect speech stop (in milliseconds). With shorter values
|
||||
* the model will respond more quickly, but may jump in on short pauses from the
|
||||
* user.
|
||||
*/
|
||||
silence_duration_ms?: number;
|
||||
|
||||
/**
|
||||
* Sensitivity threshold (0.0 to 1.0) for voice activity detection. A higher
|
||||
* threshold will require louder audio to activate the model, and thus might
|
||||
* perform better in noisy environments.
|
||||
*/
|
||||
threshold?: number;
|
||||
}
|
||||
|
||||
export type TranscriptionCreateParamsNonStreaming = TranscriptionsAPI.TranscriptionCreateParamsNonStreaming;
|
||||
export type TranscriptionCreateParamsStreaming = TranscriptionsAPI.TranscriptionCreateParamsStreaming;
|
||||
}
|
||||
|
||||
export interface TranscriptionCreateParamsNonStreaming<
|
||||
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
|
||||
> extends TranscriptionCreateParamsBase<ResponseFormat> {
|
||||
/**
|
||||
* If set to true, the model response data will be streamed to the client as it is
|
||||
* generated using
|
||||
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
|
||||
* See the
|
||||
* [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)
|
||||
* for more information.
|
||||
*
|
||||
* Note: Streaming is not supported for the `whisper-1` model and will be ignored.
|
||||
*/
|
||||
stream?: false | null;
|
||||
}
|
||||
|
||||
export interface TranscriptionCreateParamsStreaming extends TranscriptionCreateParamsBase {
|
||||
/**
|
||||
* If set to true, the model response data will be streamed to the client as it is
|
||||
* generated using
|
||||
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
|
||||
* See the
|
||||
* [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)
|
||||
* for more information.
|
||||
*
|
||||
* Note: Streaming is not supported for the `whisper-1` model and will be ignored.
|
||||
*/
|
||||
stream: true;
|
||||
}
|
||||
|
||||
export declare namespace Transcriptions {
|
||||
export {
|
||||
type Transcription as Transcription,
|
||||
type TranscriptionInclude as TranscriptionInclude,
|
||||
type TranscriptionSegment as TranscriptionSegment,
|
||||
type TranscriptionStreamEvent as TranscriptionStreamEvent,
|
||||
type TranscriptionTextDeltaEvent as TranscriptionTextDeltaEvent,
|
||||
type TranscriptionTextDoneEvent as TranscriptionTextDoneEvent,
|
||||
type TranscriptionVerbose as TranscriptionVerbose,
|
||||
type TranscriptionWord as TranscriptionWord,
|
||||
type TranscriptionCreateResponse as TranscriptionCreateResponse,
|
||||
type TranscriptionCreateParams as TranscriptionCreateParams,
|
||||
type TranscriptionCreateParamsNonStreaming as TranscriptionCreateParamsNonStreaming,
|
||||
type TranscriptionCreateParamsStreaming as TranscriptionCreateParamsStreaming,
|
||||
};
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as Core from '../../core';
|
||||
import * as AudioAPI from './audio';
|
||||
import * as TranscriptionsAPI from './transcriptions';
|
||||
|
||||
export class Translations extends APIResource {
|
||||
/**
|
||||
* Translates audio into English.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const translation = await client.audio.translations.create({
|
||||
* file: fs.createReadStream('speech.mp3'),
|
||||
* model: 'whisper-1',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
create(
|
||||
body: TranslationCreateParams<'json' | undefined>,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<Translation>;
|
||||
create(
|
||||
body: TranslationCreateParams<'verbose_json'>,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<TranslationVerbose>;
|
||||
create(
|
||||
body: TranslationCreateParams<'text' | 'srt' | 'vtt'>,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<string>;
|
||||
create(body: TranslationCreateParams, options?: Core.RequestOptions): Core.APIPromise<Translation>;
|
||||
create(
|
||||
body: TranslationCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<TranslationCreateResponse | string> {
|
||||
return this._client.post(
|
||||
'/audio/translations',
|
||||
Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export interface Translation {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface TranslationVerbose {
|
||||
/**
|
||||
* The duration of the input audio.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* 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<TranscriptionsAPI.TranscriptionSegment>;
|
||||
}
|
||||
|
||||
export type TranslationCreateResponse = Translation | TranslationVerbose;
|
||||
|
||||
export interface TranslationCreateParams<
|
||||
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
|
||||
> {
|
||||
/**
|
||||
* The audio file object (not file name) translate, in one of these formats: flac,
|
||||
* mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
|
||||
*/
|
||||
file: Core.Uploadable;
|
||||
|
||||
/**
|
||||
* ID of the model to use. Only `whisper-1` (which is powered by our open source
|
||||
* Whisper V2 model) is currently available.
|
||||
*/
|
||||
model: (string & {}) | AudioAPI.AudioModel;
|
||||
|
||||
/**
|
||||
* An optional text to guide the model's style or continue a previous audio
|
||||
* segment. The
|
||||
* [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
|
||||
* should be in English.
|
||||
*/
|
||||
prompt?: string;
|
||||
|
||||
/**
|
||||
* The format of the output, in one of these options: `json`, `text`, `srt`,
|
||||
* `verbose_json`, or `vtt`.
|
||||
*/
|
||||
response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
|
||||
|
||||
/**
|
||||
* The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
|
||||
* output more random, while lower values like 0.2 will make it more focused and
|
||||
* deterministic. If set to 0, the model will use
|
||||
* [log probability](https://en.wikipedia.org/wiki/Log_probability) to
|
||||
* automatically increase the temperature until certain thresholds are hit.
|
||||
*/
|
||||
temperature?: number;
|
||||
}
|
||||
|
||||
export declare namespace Translations {
|
||||
export {
|
||||
type Translation as Translation,
|
||||
type TranslationVerbose as TranslationVerbose,
|
||||
type TranslationCreateResponse as TranslationCreateResponse,
|
||||
type TranslationCreateParams as TranslationCreateParams,
|
||||
};
|
||||
}
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../resource';
|
||||
import { isRequestOptions } from '../core';
|
||||
import * as Core from '../core';
|
||||
import * as BatchesAPI from './batches';
|
||||
import * as Shared from './shared';
|
||||
import { CursorPage, type CursorPageParams } from '../pagination';
|
||||
|
||||
export class Batches extends APIResource {
|
||||
/**
|
||||
* Creates and executes a batch from an uploaded file of requests
|
||||
*/
|
||||
create(body: BatchCreateParams, options?: Core.RequestOptions): Core.APIPromise<Batch> {
|
||||
return this._client.post('/batches', { body, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a batch.
|
||||
*/
|
||||
retrieve(batchId: string, options?: Core.RequestOptions): Core.APIPromise<Batch> {
|
||||
return this._client.get(`/batches/${batchId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* List your organization's batches.
|
||||
*/
|
||||
list(query?: BatchListParams, options?: Core.RequestOptions): Core.PagePromise<BatchesPage, Batch>;
|
||||
list(options?: Core.RequestOptions): Core.PagePromise<BatchesPage, Batch>;
|
||||
list(
|
||||
query: BatchListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<BatchesPage, Batch> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list({}, query);
|
||||
}
|
||||
return this._client.getAPIList('/batches', BatchesPage, { query, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels an in-progress batch. The batch will be in status `cancelling` for up to
|
||||
* 10 minutes, before changing to `cancelled`, where it will have partial results
|
||||
* (if any) available in the output file.
|
||||
*/
|
||||
cancel(batchId: string, options?: Core.RequestOptions): Core.APIPromise<Batch> {
|
||||
return this._client.post(`/batches/${batchId}/cancel`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class BatchesPage extends CursorPage<Batch> {}
|
||||
|
||||
export interface Batch {
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The time frame within which the batch should be processed.
|
||||
*/
|
||||
completion_window: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The OpenAI API endpoint used by the batch.
|
||||
*/
|
||||
endpoint: string;
|
||||
|
||||
/**
|
||||
* The ID of the input file for the batch.
|
||||
*/
|
||||
input_file_id: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always `batch`.
|
||||
*/
|
||||
object: 'batch';
|
||||
|
||||
/**
|
||||
* The current status of the batch.
|
||||
*/
|
||||
status:
|
||||
| 'validating'
|
||||
| 'failed'
|
||||
| 'in_progress'
|
||||
| 'finalizing'
|
||||
| 'completed'
|
||||
| 'expired'
|
||||
| 'cancelling'
|
||||
| 'cancelled';
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch was cancelled.
|
||||
*/
|
||||
cancelled_at?: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch started cancelling.
|
||||
*/
|
||||
cancelling_at?: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch was completed.
|
||||
*/
|
||||
completed_at?: number;
|
||||
|
||||
/**
|
||||
* The ID of the file containing the outputs of requests with errors.
|
||||
*/
|
||||
error_file_id?: string;
|
||||
|
||||
errors?: Batch.Errors;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch expired.
|
||||
*/
|
||||
expired_at?: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch will expire.
|
||||
*/
|
||||
expires_at?: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch failed.
|
||||
*/
|
||||
failed_at?: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch started finalizing.
|
||||
*/
|
||||
finalizing_at?: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the batch started processing.
|
||||
*/
|
||||
in_progress_at?: number;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The ID of the file containing the outputs of successfully executed requests.
|
||||
*/
|
||||
output_file_id?: string;
|
||||
|
||||
/**
|
||||
* The request counts for different statuses within the batch.
|
||||
*/
|
||||
request_counts?: BatchRequestCounts;
|
||||
}
|
||||
|
||||
export namespace Batch {
|
||||
export interface Errors {
|
||||
data?: Array<BatchesAPI.BatchError>;
|
||||
|
||||
/**
|
||||
* The object type, which is always `list`.
|
||||
*/
|
||||
object?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface BatchError {
|
||||
/**
|
||||
* An error code identifying the error type.
|
||||
*/
|
||||
code?: string;
|
||||
|
||||
/**
|
||||
* The line number of the input file where the error occurred, if applicable.
|
||||
*/
|
||||
line?: number | null;
|
||||
|
||||
/**
|
||||
* A human-readable message providing more details about the error.
|
||||
*/
|
||||
message?: string;
|
||||
|
||||
/**
|
||||
* The name of the parameter that caused the error, if applicable.
|
||||
*/
|
||||
param?: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The request counts for different statuses within the batch.
|
||||
*/
|
||||
export interface BatchRequestCounts {
|
||||
/**
|
||||
* Number of requests that have been completed successfully.
|
||||
*/
|
||||
completed: number;
|
||||
|
||||
/**
|
||||
* Number of requests that have failed.
|
||||
*/
|
||||
failed: number;
|
||||
|
||||
/**
|
||||
* Total number of requests in the batch.
|
||||
*/
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface BatchCreateParams {
|
||||
/**
|
||||
* The time frame within which the batch should be processed. Currently only `24h`
|
||||
* is supported.
|
||||
*/
|
||||
completion_window: '24h';
|
||||
|
||||
/**
|
||||
* The endpoint to be used for all requests in the batch. Currently
|
||||
* `/v1/responses`, `/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.
|
||||
*/
|
||||
endpoint: '/v1/responses' | '/v1/chat/completions' | '/v1/embeddings' | '/v1/completions';
|
||||
|
||||
/**
|
||||
* The ID of an uploaded file that contains requests for the new batch.
|
||||
*
|
||||
* See [upload file](https://platform.openai.com/docs/api-reference/files/create)
|
||||
* for how to upload a file.
|
||||
*
|
||||
* Your input file must be formatted as a
|
||||
* [JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
|
||||
* and must be uploaded with the purpose `batch`. The file can contain up to 50,000
|
||||
* requests, and can be up to 200 MB in size.
|
||||
*/
|
||||
input_file_id: string;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
export interface BatchListParams extends CursorPageParams {}
|
||||
|
||||
Batches.BatchesPage = BatchesPage;
|
||||
|
||||
export declare namespace Batches {
|
||||
export {
|
||||
type Batch as Batch,
|
||||
type BatchError as BatchError,
|
||||
type BatchRequestCounts as BatchRequestCounts,
|
||||
BatchesPage as BatchesPage,
|
||||
type BatchCreateParams as BatchCreateParams,
|
||||
type BatchListParams as BatchListParams,
|
||||
};
|
||||
}
|
||||
+1559
File diff suppressed because it is too large
Load Diff
+199
@@ -0,0 +1,199 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as AssistantsAPI from './assistants';
|
||||
import * as ChatAPI from './chat/chat';
|
||||
import {
|
||||
Assistant,
|
||||
AssistantCreateParams,
|
||||
AssistantDeleted,
|
||||
AssistantListParams,
|
||||
AssistantStreamEvent,
|
||||
AssistantTool,
|
||||
AssistantUpdateParams,
|
||||
Assistants,
|
||||
AssistantsPage,
|
||||
CodeInterpreterTool,
|
||||
FileSearchTool,
|
||||
FunctionTool,
|
||||
MessageStreamEvent,
|
||||
RunStepStreamEvent,
|
||||
RunStreamEvent,
|
||||
ThreadStreamEvent,
|
||||
} from './assistants';
|
||||
import * as RealtimeAPI from './realtime/realtime';
|
||||
import {
|
||||
ConversationCreatedEvent,
|
||||
ConversationItem,
|
||||
ConversationItemContent,
|
||||
ConversationItemCreateEvent,
|
||||
ConversationItemCreatedEvent,
|
||||
ConversationItemDeleteEvent,
|
||||
ConversationItemDeletedEvent,
|
||||
ConversationItemInputAudioTranscriptionCompletedEvent,
|
||||
ConversationItemInputAudioTranscriptionDeltaEvent,
|
||||
ConversationItemInputAudioTranscriptionFailedEvent,
|
||||
ConversationItemRetrieveEvent,
|
||||
ConversationItemTruncateEvent,
|
||||
ConversationItemTruncatedEvent,
|
||||
ConversationItemWithReference,
|
||||
ErrorEvent,
|
||||
InputAudioBufferAppendEvent,
|
||||
InputAudioBufferClearEvent,
|
||||
InputAudioBufferClearedEvent,
|
||||
InputAudioBufferCommitEvent,
|
||||
InputAudioBufferCommittedEvent,
|
||||
InputAudioBufferSpeechStartedEvent,
|
||||
InputAudioBufferSpeechStoppedEvent,
|
||||
RateLimitsUpdatedEvent,
|
||||
Realtime,
|
||||
RealtimeClientEvent,
|
||||
RealtimeResponse,
|
||||
RealtimeResponseStatus,
|
||||
RealtimeResponseUsage,
|
||||
RealtimeServerEvent,
|
||||
ResponseAudioDeltaEvent,
|
||||
ResponseAudioDoneEvent,
|
||||
ResponseAudioTranscriptDeltaEvent,
|
||||
ResponseAudioTranscriptDoneEvent,
|
||||
ResponseCancelEvent,
|
||||
ResponseContentPartAddedEvent,
|
||||
ResponseContentPartDoneEvent,
|
||||
ResponseCreateEvent,
|
||||
ResponseCreatedEvent,
|
||||
ResponseDoneEvent,
|
||||
ResponseFunctionCallArgumentsDeltaEvent,
|
||||
ResponseFunctionCallArgumentsDoneEvent,
|
||||
ResponseOutputItemAddedEvent,
|
||||
ResponseOutputItemDoneEvent,
|
||||
ResponseTextDeltaEvent,
|
||||
ResponseTextDoneEvent,
|
||||
SessionCreatedEvent,
|
||||
SessionUpdateEvent,
|
||||
SessionUpdatedEvent,
|
||||
TranscriptionSessionUpdate,
|
||||
TranscriptionSessionUpdatedEvent,
|
||||
} from './realtime/realtime';
|
||||
import * as ThreadsAPI from './threads/threads';
|
||||
import {
|
||||
AssistantResponseFormatOption,
|
||||
AssistantToolChoice,
|
||||
AssistantToolChoiceFunction,
|
||||
AssistantToolChoiceOption,
|
||||
Thread,
|
||||
ThreadCreateAndRunParams,
|
||||
ThreadCreateAndRunParamsNonStreaming,
|
||||
ThreadCreateAndRunParamsStreaming,
|
||||
ThreadCreateAndRunPollParams,
|
||||
ThreadCreateAndRunStreamParams,
|
||||
ThreadCreateParams,
|
||||
ThreadDeleted,
|
||||
ThreadUpdateParams,
|
||||
Threads,
|
||||
} from './threads/threads';
|
||||
import { Chat } from './chat/chat';
|
||||
|
||||
export class Beta extends APIResource {
|
||||
realtime: RealtimeAPI.Realtime = new RealtimeAPI.Realtime(this._client);
|
||||
chat: ChatAPI.Chat = new ChatAPI.Chat(this._client);
|
||||
assistants: AssistantsAPI.Assistants = new AssistantsAPI.Assistants(this._client);
|
||||
threads: ThreadsAPI.Threads = new ThreadsAPI.Threads(this._client);
|
||||
}
|
||||
|
||||
Beta.Realtime = Realtime;
|
||||
Beta.Assistants = Assistants;
|
||||
Beta.AssistantsPage = AssistantsPage;
|
||||
Beta.Threads = Threads;
|
||||
|
||||
export declare namespace Beta {
|
||||
export {
|
||||
Realtime as Realtime,
|
||||
type ConversationCreatedEvent as ConversationCreatedEvent,
|
||||
type ConversationItem as ConversationItem,
|
||||
type ConversationItemContent as ConversationItemContent,
|
||||
type ConversationItemCreateEvent as ConversationItemCreateEvent,
|
||||
type ConversationItemCreatedEvent as ConversationItemCreatedEvent,
|
||||
type ConversationItemDeleteEvent as ConversationItemDeleteEvent,
|
||||
type ConversationItemDeletedEvent as ConversationItemDeletedEvent,
|
||||
type ConversationItemInputAudioTranscriptionCompletedEvent as ConversationItemInputAudioTranscriptionCompletedEvent,
|
||||
type ConversationItemInputAudioTranscriptionDeltaEvent as ConversationItemInputAudioTranscriptionDeltaEvent,
|
||||
type ConversationItemInputAudioTranscriptionFailedEvent as ConversationItemInputAudioTranscriptionFailedEvent,
|
||||
type ConversationItemRetrieveEvent as ConversationItemRetrieveEvent,
|
||||
type ConversationItemTruncateEvent as ConversationItemTruncateEvent,
|
||||
type ConversationItemTruncatedEvent as ConversationItemTruncatedEvent,
|
||||
type ConversationItemWithReference as ConversationItemWithReference,
|
||||
type ErrorEvent as ErrorEvent,
|
||||
type InputAudioBufferAppendEvent as InputAudioBufferAppendEvent,
|
||||
type InputAudioBufferClearEvent as InputAudioBufferClearEvent,
|
||||
type InputAudioBufferClearedEvent as InputAudioBufferClearedEvent,
|
||||
type InputAudioBufferCommitEvent as InputAudioBufferCommitEvent,
|
||||
type InputAudioBufferCommittedEvent as InputAudioBufferCommittedEvent,
|
||||
type InputAudioBufferSpeechStartedEvent as InputAudioBufferSpeechStartedEvent,
|
||||
type InputAudioBufferSpeechStoppedEvent as InputAudioBufferSpeechStoppedEvent,
|
||||
type RateLimitsUpdatedEvent as RateLimitsUpdatedEvent,
|
||||
type RealtimeClientEvent as RealtimeClientEvent,
|
||||
type RealtimeResponse as RealtimeResponse,
|
||||
type RealtimeResponseStatus as RealtimeResponseStatus,
|
||||
type RealtimeResponseUsage as RealtimeResponseUsage,
|
||||
type RealtimeServerEvent as RealtimeServerEvent,
|
||||
type ResponseAudioDeltaEvent as ResponseAudioDeltaEvent,
|
||||
type ResponseAudioDoneEvent as ResponseAudioDoneEvent,
|
||||
type ResponseAudioTranscriptDeltaEvent as ResponseAudioTranscriptDeltaEvent,
|
||||
type ResponseAudioTranscriptDoneEvent as ResponseAudioTranscriptDoneEvent,
|
||||
type ResponseCancelEvent as ResponseCancelEvent,
|
||||
type ResponseContentPartAddedEvent as ResponseContentPartAddedEvent,
|
||||
type ResponseContentPartDoneEvent as ResponseContentPartDoneEvent,
|
||||
type ResponseCreateEvent as ResponseCreateEvent,
|
||||
type ResponseCreatedEvent as ResponseCreatedEvent,
|
||||
type ResponseDoneEvent as ResponseDoneEvent,
|
||||
type ResponseFunctionCallArgumentsDeltaEvent as ResponseFunctionCallArgumentsDeltaEvent,
|
||||
type ResponseFunctionCallArgumentsDoneEvent as ResponseFunctionCallArgumentsDoneEvent,
|
||||
type ResponseOutputItemAddedEvent as ResponseOutputItemAddedEvent,
|
||||
type ResponseOutputItemDoneEvent as ResponseOutputItemDoneEvent,
|
||||
type ResponseTextDeltaEvent as ResponseTextDeltaEvent,
|
||||
type ResponseTextDoneEvent as ResponseTextDoneEvent,
|
||||
type SessionCreatedEvent as SessionCreatedEvent,
|
||||
type SessionUpdateEvent as SessionUpdateEvent,
|
||||
type SessionUpdatedEvent as SessionUpdatedEvent,
|
||||
type TranscriptionSessionUpdate as TranscriptionSessionUpdate,
|
||||
type TranscriptionSessionUpdatedEvent as TranscriptionSessionUpdatedEvent,
|
||||
};
|
||||
|
||||
export { Chat };
|
||||
|
||||
export {
|
||||
Assistants as Assistants,
|
||||
type Assistant as Assistant,
|
||||
type AssistantDeleted as AssistantDeleted,
|
||||
type AssistantStreamEvent as AssistantStreamEvent,
|
||||
type AssistantTool as AssistantTool,
|
||||
type CodeInterpreterTool as CodeInterpreterTool,
|
||||
type FileSearchTool as FileSearchTool,
|
||||
type FunctionTool as FunctionTool,
|
||||
type MessageStreamEvent as MessageStreamEvent,
|
||||
type RunStepStreamEvent as RunStepStreamEvent,
|
||||
type RunStreamEvent as RunStreamEvent,
|
||||
type ThreadStreamEvent as ThreadStreamEvent,
|
||||
AssistantsPage as AssistantsPage,
|
||||
type AssistantCreateParams as AssistantCreateParams,
|
||||
type AssistantUpdateParams as AssistantUpdateParams,
|
||||
type AssistantListParams as AssistantListParams,
|
||||
};
|
||||
|
||||
export {
|
||||
Threads as Threads,
|
||||
type AssistantResponseFormatOption as AssistantResponseFormatOption,
|
||||
type AssistantToolChoice as AssistantToolChoice,
|
||||
type AssistantToolChoiceFunction as AssistantToolChoiceFunction,
|
||||
type AssistantToolChoiceOption as AssistantToolChoiceOption,
|
||||
type Thread as Thread,
|
||||
type ThreadDeleted as ThreadDeleted,
|
||||
type ThreadCreateParams as ThreadCreateParams,
|
||||
type ThreadUpdateParams as ThreadUpdateParams,
|
||||
type ThreadCreateAndRunParams as ThreadCreateAndRunParams,
|
||||
type ThreadCreateAndRunParamsNonStreaming as ThreadCreateAndRunParamsNonStreaming,
|
||||
type ThreadCreateAndRunParamsStreaming as ThreadCreateAndRunParamsStreaming,
|
||||
type ThreadCreateAndRunPollParams,
|
||||
type ThreadCreateAndRunStreamParams,
|
||||
};
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import * as CompletionsAPI from './completions';
|
||||
|
||||
export class Chat extends APIResource {
|
||||
completions: CompletionsAPI.Completions = new CompletionsAPI.Completions(this._client);
|
||||
}
|
||||
|
||||
export namespace Chat {
|
||||
export import Completions = CompletionsAPI.Completions;
|
||||
}
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import * as Core from '../../../core';
|
||||
import { APIResource } from '../../../resource';
|
||||
import { ChatCompletionRunner, ChatCompletionFunctionRunnerParams } from '../../../lib/ChatCompletionRunner';
|
||||
import {
|
||||
ChatCompletionStreamingRunner,
|
||||
ChatCompletionStreamingFunctionRunnerParams,
|
||||
} from '../../../lib/ChatCompletionStreamingRunner';
|
||||
import { BaseFunctionsArgs } from '../../../lib/RunnableFunction';
|
||||
import { RunnerOptions } from '../../../lib/AbstractChatCompletionRunner';
|
||||
import { ChatCompletionToolRunnerParams } from '../../../lib/ChatCompletionRunner';
|
||||
import { ChatCompletionStreamingToolRunnerParams } from '../../../lib/ChatCompletionStreamingRunner';
|
||||
import { ChatCompletionStream, type ChatCompletionStreamParams } from '../../../lib/ChatCompletionStream';
|
||||
import {
|
||||
ChatCompletion,
|
||||
ChatCompletionCreateParamsNonStreaming,
|
||||
ChatCompletionMessage,
|
||||
ChatCompletionMessageToolCall,
|
||||
} from '../../chat/completions';
|
||||
import { ExtractParsedContentFromParams, parseChatCompletion, validateInputTools } from '../../../lib/parser';
|
||||
|
||||
export {
|
||||
ChatCompletionStreamingRunner,
|
||||
type ChatCompletionStreamingFunctionRunnerParams,
|
||||
} from '../../../lib/ChatCompletionStreamingRunner';
|
||||
export {
|
||||
type RunnableFunction,
|
||||
type RunnableFunctions,
|
||||
type RunnableFunctionWithParse,
|
||||
type RunnableFunctionWithoutParse,
|
||||
ParsingFunction,
|
||||
ParsingToolFunction,
|
||||
} from '../../../lib/RunnableFunction';
|
||||
export { type ChatCompletionToolRunnerParams } from '../../../lib/ChatCompletionRunner';
|
||||
export { type ChatCompletionStreamingToolRunnerParams } from '../../../lib/ChatCompletionStreamingRunner';
|
||||
export { ChatCompletionStream, type ChatCompletionStreamParams } from '../../../lib/ChatCompletionStream';
|
||||
export {
|
||||
ChatCompletionRunner,
|
||||
type ChatCompletionFunctionRunnerParams,
|
||||
} from '../../../lib/ChatCompletionRunner';
|
||||
|
||||
export interface ParsedFunction extends ChatCompletionMessageToolCall.Function {
|
||||
parsed_arguments?: unknown;
|
||||
}
|
||||
|
||||
export interface ParsedFunctionToolCall extends ChatCompletionMessageToolCall {
|
||||
function: ParsedFunction;
|
||||
}
|
||||
|
||||
export interface ParsedChatCompletionMessage<ParsedT> extends ChatCompletionMessage {
|
||||
parsed: ParsedT | null;
|
||||
tool_calls?: Array<ParsedFunctionToolCall>;
|
||||
}
|
||||
|
||||
export interface ParsedChoice<ParsedT> extends ChatCompletion.Choice {
|
||||
message: ParsedChatCompletionMessage<ParsedT>;
|
||||
}
|
||||
|
||||
export interface ParsedChatCompletion<ParsedT> extends ChatCompletion {
|
||||
choices: Array<ParsedChoice<ParsedT>>;
|
||||
}
|
||||
|
||||
export type ChatCompletionParseParams = ChatCompletionCreateParamsNonStreaming;
|
||||
|
||||
export class Completions extends APIResource {
|
||||
parse<Params extends ChatCompletionParseParams, ParsedT = ExtractParsedContentFromParams<Params>>(
|
||||
body: Params,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<ParsedChatCompletion<ParsedT>> {
|
||||
validateInputTools(body.tools);
|
||||
|
||||
return this._client.chat.completions
|
||||
.create(body, {
|
||||
...options,
|
||||
headers: {
|
||||
...options?.headers,
|
||||
'X-Stainless-Helper-Method': 'beta.chat.completions.parse',
|
||||
},
|
||||
})
|
||||
._thenUnwrap((completion) => parseChatCompletion(completion, body));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - use `runTools` instead.
|
||||
*/
|
||||
runFunctions<FunctionsArgs extends BaseFunctionsArgs>(
|
||||
body: ChatCompletionFunctionRunnerParams<FunctionsArgs>,
|
||||
options?: Core.RequestOptions,
|
||||
): ChatCompletionRunner<null>;
|
||||
runFunctions<FunctionsArgs extends BaseFunctionsArgs>(
|
||||
body: ChatCompletionStreamingFunctionRunnerParams<FunctionsArgs>,
|
||||
options?: Core.RequestOptions,
|
||||
): ChatCompletionStreamingRunner<null>;
|
||||
runFunctions<FunctionsArgs extends BaseFunctionsArgs>(
|
||||
body:
|
||||
| ChatCompletionFunctionRunnerParams<FunctionsArgs>
|
||||
| ChatCompletionStreamingFunctionRunnerParams<FunctionsArgs>,
|
||||
options?: Core.RequestOptions,
|
||||
): ChatCompletionRunner<null> | ChatCompletionStreamingRunner<null> {
|
||||
if (body.stream) {
|
||||
return ChatCompletionStreamingRunner.runFunctions(
|
||||
this._client,
|
||||
body as ChatCompletionStreamingFunctionRunnerParams<FunctionsArgs>,
|
||||
options,
|
||||
);
|
||||
}
|
||||
return ChatCompletionRunner.runFunctions(
|
||||
this._client,
|
||||
body as ChatCompletionFunctionRunnerParams<FunctionsArgs>,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience helper for using tool calls with the /chat/completions endpoint
|
||||
* which automatically calls the JavaScript functions you provide and sends their
|
||||
* results back to the /chat/completions endpoint, looping as long as the model
|
||||
* requests function calls.
|
||||
*
|
||||
* For more details and examples, see
|
||||
* [the docs](https://github.com/openai/openai-node#automated-function-calls)
|
||||
*/
|
||||
runTools<
|
||||
Params extends ChatCompletionToolRunnerParams<any>,
|
||||
ParsedT = ExtractParsedContentFromParams<Params>,
|
||||
>(body: Params, options?: RunnerOptions): ChatCompletionRunner<ParsedT>;
|
||||
|
||||
runTools<
|
||||
Params extends ChatCompletionStreamingToolRunnerParams<any>,
|
||||
ParsedT = ExtractParsedContentFromParams<Params>,
|
||||
>(body: Params, options?: RunnerOptions): ChatCompletionStreamingRunner<ParsedT>;
|
||||
|
||||
runTools<
|
||||
Params extends ChatCompletionToolRunnerParams<any> | ChatCompletionStreamingToolRunnerParams<any>,
|
||||
ParsedT = ExtractParsedContentFromParams<Params>,
|
||||
>(
|
||||
body: Params,
|
||||
options?: RunnerOptions,
|
||||
): ChatCompletionRunner<ParsedT> | ChatCompletionStreamingRunner<ParsedT> {
|
||||
if (body.stream) {
|
||||
return ChatCompletionStreamingRunner.runTools(
|
||||
this._client,
|
||||
body as ChatCompletionStreamingToolRunnerParams<any>,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
return ChatCompletionRunner.runTools(this._client, body as ChatCompletionToolRunnerParams<any>, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a chat completion stream
|
||||
*/
|
||||
stream<Params extends ChatCompletionStreamParams, ParsedT = ExtractParsedContentFromParams<Params>>(
|
||||
body: Params,
|
||||
options?: Core.RequestOptions,
|
||||
): ChatCompletionStream<ParsedT> {
|
||||
return ChatCompletionStream.createChatCompletion(this._client, body, options);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Chat } from './chat';
|
||||
export { Completions } from './completions';
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
AssistantsPage,
|
||||
Assistants,
|
||||
type Assistant,
|
||||
type AssistantDeleted,
|
||||
type AssistantStreamEvent,
|
||||
type AssistantTool,
|
||||
type CodeInterpreterTool,
|
||||
type FileSearchTool,
|
||||
type FunctionTool,
|
||||
type MessageStreamEvent,
|
||||
type RunStepStreamEvent,
|
||||
type RunStreamEvent,
|
||||
type ThreadStreamEvent,
|
||||
type AssistantCreateParams,
|
||||
type AssistantUpdateParams,
|
||||
type AssistantListParams,
|
||||
} from './assistants';
|
||||
export { Beta } from './beta';
|
||||
export { Realtime } from './realtime/index';
|
||||
export { Chat } from './chat/index';
|
||||
export {
|
||||
Threads,
|
||||
type AssistantResponseFormatOption,
|
||||
type AssistantToolChoice,
|
||||
type AssistantToolChoiceFunction,
|
||||
type AssistantToolChoiceOption,
|
||||
type Thread,
|
||||
type ThreadDeleted,
|
||||
type ThreadCreateParams,
|
||||
type ThreadUpdateParams,
|
||||
type ThreadCreateAndRunParams,
|
||||
type ThreadCreateAndRunParamsNonStreaming,
|
||||
type ThreadCreateAndRunParamsStreaming,
|
||||
type ThreadCreateAndRunPollParams,
|
||||
type ThreadCreateAndRunStreamParams,
|
||||
} from './threads/index';
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Realtime } from './realtime';
|
||||
export { Sessions, type Session, type SessionCreateResponse, type SessionCreateParams } from './sessions';
|
||||
export {
|
||||
TranscriptionSessions,
|
||||
type TranscriptionSession,
|
||||
type TranscriptionSessionCreateParams,
|
||||
} from './transcription-sessions';
|
||||
+2721
File diff suppressed because it is too large
Load Diff
+786
@@ -0,0 +1,786 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import * as Core from '../../../core';
|
||||
|
||||
export class Sessions extends APIResource {
|
||||
/**
|
||||
* Create an ephemeral API token for use in client-side applications with the
|
||||
* Realtime API. Can be configured with the same session parameters as the
|
||||
* `session.update` client event.
|
||||
*
|
||||
* It responds with a session object, plus a `client_secret` key which contains a
|
||||
* usable ephemeral API token that can be used to authenticate browser clients for
|
||||
* the Realtime API.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const session =
|
||||
* await client.beta.realtime.sessions.create();
|
||||
* ```
|
||||
*/
|
||||
create(body: SessionCreateParams, options?: Core.RequestOptions): Core.APIPromise<SessionCreateResponse> {
|
||||
return this._client.post('/realtime/sessions', {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Realtime session object configuration.
|
||||
*/
|
||||
export interface Session {
|
||||
/**
|
||||
* Unique identifier for the session that looks like `sess_1234567890abcdef`.
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
|
||||
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
|
||||
* (mono), and little-endian byte order.
|
||||
*/
|
||||
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
|
||||
|
||||
/**
|
||||
* Configuration for input audio noise reduction. This can be set to `null` to turn
|
||||
* off. Noise reduction filters audio added to the input audio buffer before it is
|
||||
* sent to VAD and the model. Filtering the audio can improve VAD and turn
|
||||
* detection accuracy (reducing false positives) and model performance by improving
|
||||
* perception of the input audio.
|
||||
*/
|
||||
input_audio_noise_reduction?: Session.InputAudioNoiseReduction;
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription, defaults to off and can be set to
|
||||
* `null` to turn off once on. Input audio transcription is not native to the
|
||||
* model, since the model consumes audio directly. Transcription runs
|
||||
* asynchronously through
|
||||
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
|
||||
* and should be treated as guidance of input audio content rather than precisely
|
||||
* what the model heard. The client can optionally set the language and prompt for
|
||||
* transcription, these offer additional guidance to the transcription service.
|
||||
*/
|
||||
input_audio_transcription?: Session.InputAudioTranscription;
|
||||
|
||||
/**
|
||||
* The default system instructions (i.e. system message) prepended to model calls.
|
||||
* This field allows the client to guide the model on desired responses. The model
|
||||
* can be instructed on response content and format, (e.g. "be extremely succinct",
|
||||
* "act friendly", "here are examples of good responses") and on audio behavior
|
||||
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
||||
* instructions are not guaranteed to be followed by the model, but they provide
|
||||
* guidance to the model on the desired behavior.
|
||||
*
|
||||
* Note that the server sets default instructions which will be used if this field
|
||||
* is not set and are visible in the `session.created` event at the start of the
|
||||
* session.
|
||||
*/
|
||||
instructions?: string;
|
||||
|
||||
/**
|
||||
* Maximum number of output tokens for a single assistant response, inclusive of
|
||||
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
||||
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
||||
*/
|
||||
max_response_output_tokens?: number | 'inf';
|
||||
|
||||
/**
|
||||
* The set of modalities the model can respond with. To disable audio, set this to
|
||||
* ["text"].
|
||||
*/
|
||||
modalities?: Array<'text' | 'audio'>;
|
||||
|
||||
/**
|
||||
* The Realtime model used for this session.
|
||||
*/
|
||||
model?:
|
||||
| 'gpt-4o-realtime-preview'
|
||||
| 'gpt-4o-realtime-preview-2024-10-01'
|
||||
| 'gpt-4o-realtime-preview-2024-12-17'
|
||||
| 'gpt-4o-mini-realtime-preview'
|
||||
| 'gpt-4o-mini-realtime-preview-2024-12-17';
|
||||
|
||||
/**
|
||||
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
|
||||
* For `pcm16`, output audio is sampled at a rate of 24kHz.
|
||||
*/
|
||||
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
|
||||
|
||||
/**
|
||||
* Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
|
||||
* temperature of 0.8 is highly recommended for best performance.
|
||||
*/
|
||||
temperature?: number;
|
||||
|
||||
/**
|
||||
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
|
||||
* a function.
|
||||
*/
|
||||
tool_choice?: string;
|
||||
|
||||
/**
|
||||
* Tools (functions) available to the model.
|
||||
*/
|
||||
tools?: Array<Session.Tool>;
|
||||
|
||||
/**
|
||||
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
||||
* set to `null` to turn off, in which case the client must manually trigger model
|
||||
* response. Server VAD means that the model will detect the start and end of
|
||||
* speech based on audio volume and respond at the end of user speech. Semantic VAD
|
||||
* is more advanced and uses a turn detection model (in conjuction with VAD) to
|
||||
* semantically estimate whether the user has finished speaking, then dynamically
|
||||
* sets a timeout based on this probability. For example, if user audio trails off
|
||||
* with "uhhm", the model will score a low probability of turn end and wait longer
|
||||
* for the user to continue speaking. This can be useful for more natural
|
||||
* conversations, but may have a higher latency.
|
||||
*/
|
||||
turn_detection?: Session.TurnDetection;
|
||||
|
||||
/**
|
||||
* The voice the model uses to respond. Voice cannot be changed during the session
|
||||
* once the model has responded with audio at least once. Current voice options are
|
||||
* `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, `shimmer` and `verse`.
|
||||
*/
|
||||
voice?:
|
||||
| (string & {})
|
||||
| 'alloy'
|
||||
| 'ash'
|
||||
| 'ballad'
|
||||
| 'coral'
|
||||
| 'echo'
|
||||
| 'fable'
|
||||
| 'onyx'
|
||||
| 'nova'
|
||||
| 'sage'
|
||||
| 'shimmer'
|
||||
| 'verse';
|
||||
}
|
||||
|
||||
export namespace Session {
|
||||
/**
|
||||
* Configuration for input audio noise reduction. This can be set to `null` to turn
|
||||
* off. Noise reduction filters audio added to the input audio buffer before it is
|
||||
* sent to VAD and the model. Filtering the audio can improve VAD and turn
|
||||
* detection accuracy (reducing false positives) and model performance by improving
|
||||
* perception of the input audio.
|
||||
*/
|
||||
export interface InputAudioNoiseReduction {
|
||||
/**
|
||||
* Type of noise reduction. `near_field` is for close-talking microphones such as
|
||||
* headphones, `far_field` is for far-field microphones such as laptop or
|
||||
* conference room microphones.
|
||||
*/
|
||||
type?: 'near_field' | 'far_field';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription, defaults to off and can be set to
|
||||
* `null` to turn off once on. Input audio transcription is not native to the
|
||||
* model, since the model consumes audio directly. Transcription runs
|
||||
* asynchronously through
|
||||
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
|
||||
* and should be treated as guidance of input audio content rather than precisely
|
||||
* what the model heard. The client can optionally set the language and prompt for
|
||||
* transcription, these offer additional guidance to the transcription service.
|
||||
*/
|
||||
export interface InputAudioTranscription {
|
||||
/**
|
||||
* The language of the input audio. Supplying the input language in
|
||||
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
|
||||
* format will improve accuracy and latency.
|
||||
*/
|
||||
language?: string;
|
||||
|
||||
/**
|
||||
* The model to use for transcription, current options are `gpt-4o-transcribe`,
|
||||
* `gpt-4o-mini-transcribe`, and `whisper-1`.
|
||||
*/
|
||||
model?: string;
|
||||
|
||||
/**
|
||||
* An optional text to guide the model's style or continue a previous audio
|
||||
* segment. For `whisper-1`, the
|
||||
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
|
||||
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
|
||||
* "expect words related to technology".
|
||||
*/
|
||||
prompt?: string;
|
||||
}
|
||||
|
||||
export interface Tool {
|
||||
/**
|
||||
* The description of the function, including guidance on when and how to call it,
|
||||
* and guidance about what to tell the user when calling (if anything).
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* The name of the function.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Parameters of the function in JSON Schema.
|
||||
*/
|
||||
parameters?: unknown;
|
||||
|
||||
/**
|
||||
* The type of the tool, i.e. `function`.
|
||||
*/
|
||||
type?: 'function';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
||||
* set to `null` to turn off, in which case the client must manually trigger model
|
||||
* response. Server VAD means that the model will detect the start and end of
|
||||
* speech based on audio volume and respond at the end of user speech. Semantic VAD
|
||||
* is more advanced and uses a turn detection model (in conjuction with VAD) to
|
||||
* semantically estimate whether the user has finished speaking, then dynamically
|
||||
* sets a timeout based on this probability. For example, if user audio trails off
|
||||
* with "uhhm", the model will score a low probability of turn end and wait longer
|
||||
* for the user to continue speaking. This can be useful for more natural
|
||||
* conversations, but may have a higher latency.
|
||||
*/
|
||||
export interface TurnDetection {
|
||||
/**
|
||||
* Whether or not to automatically generate a response when a VAD stop event
|
||||
* occurs.
|
||||
*/
|
||||
create_response?: boolean;
|
||||
|
||||
/**
|
||||
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
|
||||
* will wait longer for the user to continue speaking, `high` will respond more
|
||||
* quickly. `auto` is the default and is equivalent to `medium`.
|
||||
*/
|
||||
eagerness?: 'low' | 'medium' | 'high' | 'auto';
|
||||
|
||||
/**
|
||||
* Whether or not to automatically interrupt any ongoing response with output to
|
||||
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
|
||||
* occurs.
|
||||
*/
|
||||
interrupt_response?: boolean;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Amount of audio to include before the VAD
|
||||
* detected speech (in milliseconds). Defaults to 300ms.
|
||||
*/
|
||||
prefix_padding_ms?: number;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
|
||||
* milliseconds). Defaults to 500ms. With shorter values the model will respond
|
||||
* more quickly, but may jump in on short pauses from the user.
|
||||
*/
|
||||
silence_duration_ms?: number;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
|
||||
* defaults to 0.5. A higher threshold will require louder audio to activate the
|
||||
* model, and thus might perform better in noisy environments.
|
||||
*/
|
||||
threshold?: number;
|
||||
|
||||
/**
|
||||
* Type of turn detection.
|
||||
*/
|
||||
type?: 'server_vad' | 'semantic_vad';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A new Realtime session configuration, with an ephermeral key. Default TTL for
|
||||
* keys is one minute.
|
||||
*/
|
||||
export interface SessionCreateResponse {
|
||||
/**
|
||||
* Ephemeral key returned by the API.
|
||||
*/
|
||||
client_secret: SessionCreateResponse.ClientSecret;
|
||||
|
||||
/**
|
||||
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
|
||||
*/
|
||||
input_audio_format?: string;
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription, defaults to off and can be set to
|
||||
* `null` to turn off once on. Input audio transcription is not native to the
|
||||
* model, since the model consumes audio directly. Transcription runs
|
||||
* asynchronously through Whisper and should be treated as rough guidance rather
|
||||
* than the representation understood by the model.
|
||||
*/
|
||||
input_audio_transcription?: SessionCreateResponse.InputAudioTranscription;
|
||||
|
||||
/**
|
||||
* The default system instructions (i.e. system message) prepended to model calls.
|
||||
* This field allows the client to guide the model on desired responses. The model
|
||||
* can be instructed on response content and format, (e.g. "be extremely succinct",
|
||||
* "act friendly", "here are examples of good responses") and on audio behavior
|
||||
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
||||
* instructions are not guaranteed to be followed by the model, but they provide
|
||||
* guidance to the model on the desired behavior.
|
||||
*
|
||||
* Note that the server sets default instructions which will be used if this field
|
||||
* is not set and are visible in the `session.created` event at the start of the
|
||||
* session.
|
||||
*/
|
||||
instructions?: string;
|
||||
|
||||
/**
|
||||
* Maximum number of output tokens for a single assistant response, inclusive of
|
||||
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
||||
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
||||
*/
|
||||
max_response_output_tokens?: number | 'inf';
|
||||
|
||||
/**
|
||||
* The set of modalities the model can respond with. To disable audio, set this to
|
||||
* ["text"].
|
||||
*/
|
||||
modalities?: Array<'text' | 'audio'>;
|
||||
|
||||
/**
|
||||
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
|
||||
*/
|
||||
output_audio_format?: string;
|
||||
|
||||
/**
|
||||
* Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
|
||||
*/
|
||||
temperature?: number;
|
||||
|
||||
/**
|
||||
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
|
||||
* a function.
|
||||
*/
|
||||
tool_choice?: string;
|
||||
|
||||
/**
|
||||
* Tools (functions) available to the model.
|
||||
*/
|
||||
tools?: Array<SessionCreateResponse.Tool>;
|
||||
|
||||
/**
|
||||
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
|
||||
* means that the model will detect the start and end of speech based on audio
|
||||
* volume and respond at the end of user speech.
|
||||
*/
|
||||
turn_detection?: SessionCreateResponse.TurnDetection;
|
||||
|
||||
/**
|
||||
* The voice the model uses to respond. Voice cannot be changed during the session
|
||||
* once the model has responded with audio at least once. Current voice options are
|
||||
* `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, `shimmer` and `verse`.
|
||||
*/
|
||||
voice?:
|
||||
| (string & {})
|
||||
| 'alloy'
|
||||
| 'ash'
|
||||
| 'ballad'
|
||||
| 'coral'
|
||||
| 'echo'
|
||||
| 'fable'
|
||||
| 'onyx'
|
||||
| 'nova'
|
||||
| 'sage'
|
||||
| 'shimmer'
|
||||
| 'verse';
|
||||
}
|
||||
|
||||
export namespace SessionCreateResponse {
|
||||
/**
|
||||
* Ephemeral key returned by the API.
|
||||
*/
|
||||
export interface ClientSecret {
|
||||
/**
|
||||
* Timestamp for when the token expires. Currently, all tokens expire after one
|
||||
* minute.
|
||||
*/
|
||||
expires_at: number;
|
||||
|
||||
/**
|
||||
* Ephemeral key usable in client environments to authenticate connections to the
|
||||
* Realtime API. Use this in client-side environments rather than a standard API
|
||||
* token, which should only be used server-side.
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription, defaults to off and can be set to
|
||||
* `null` to turn off once on. Input audio transcription is not native to the
|
||||
* model, since the model consumes audio directly. Transcription runs
|
||||
* asynchronously through Whisper and should be treated as rough guidance rather
|
||||
* than the representation understood by the model.
|
||||
*/
|
||||
export interface InputAudioTranscription {
|
||||
/**
|
||||
* The model to use for transcription, `whisper-1` is the only currently supported
|
||||
* model.
|
||||
*/
|
||||
model?: string;
|
||||
}
|
||||
|
||||
export interface Tool {
|
||||
/**
|
||||
* The description of the function, including guidance on when and how to call it,
|
||||
* and guidance about what to tell the user when calling (if anything).
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* The name of the function.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Parameters of the function in JSON Schema.
|
||||
*/
|
||||
parameters?: unknown;
|
||||
|
||||
/**
|
||||
* The type of the tool, i.e. `function`.
|
||||
*/
|
||||
type?: 'function';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
|
||||
* means that the model will detect the start and end of speech based on audio
|
||||
* volume and respond at the end of user speech.
|
||||
*/
|
||||
export interface TurnDetection {
|
||||
/**
|
||||
* Amount of audio to include before the VAD detected speech (in milliseconds).
|
||||
* Defaults to 300ms.
|
||||
*/
|
||||
prefix_padding_ms?: number;
|
||||
|
||||
/**
|
||||
* Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms.
|
||||
* With shorter values the model will respond more quickly, but may jump in on
|
||||
* short pauses from the user.
|
||||
*/
|
||||
silence_duration_ms?: number;
|
||||
|
||||
/**
|
||||
* Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher
|
||||
* threshold will require louder audio to activate the model, and thus might
|
||||
* perform better in noisy environments.
|
||||
*/
|
||||
threshold?: number;
|
||||
|
||||
/**
|
||||
* Type of turn detection, only `server_vad` is currently supported.
|
||||
*/
|
||||
type?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface SessionCreateParams {
|
||||
/**
|
||||
* Configuration options for the generated client secret.
|
||||
*/
|
||||
client_secret?: SessionCreateParams.ClientSecret;
|
||||
|
||||
/**
|
||||
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
|
||||
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
|
||||
* (mono), and little-endian byte order.
|
||||
*/
|
||||
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
|
||||
|
||||
/**
|
||||
* Configuration for input audio noise reduction. This can be set to `null` to turn
|
||||
* off. Noise reduction filters audio added to the input audio buffer before it is
|
||||
* sent to VAD and the model. Filtering the audio can improve VAD and turn
|
||||
* detection accuracy (reducing false positives) and model performance by improving
|
||||
* perception of the input audio.
|
||||
*/
|
||||
input_audio_noise_reduction?: SessionCreateParams.InputAudioNoiseReduction;
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription, defaults to off and can be set to
|
||||
* `null` to turn off once on. Input audio transcription is not native to the
|
||||
* model, since the model consumes audio directly. Transcription runs
|
||||
* asynchronously through
|
||||
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
|
||||
* and should be treated as guidance of input audio content rather than precisely
|
||||
* what the model heard. The client can optionally set the language and prompt for
|
||||
* transcription, these offer additional guidance to the transcription service.
|
||||
*/
|
||||
input_audio_transcription?: SessionCreateParams.InputAudioTranscription;
|
||||
|
||||
/**
|
||||
* The default system instructions (i.e. system message) prepended to model calls.
|
||||
* This field allows the client to guide the model on desired responses. The model
|
||||
* can be instructed on response content and format, (e.g. "be extremely succinct",
|
||||
* "act friendly", "here are examples of good responses") and on audio behavior
|
||||
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
||||
* instructions are not guaranteed to be followed by the model, but they provide
|
||||
* guidance to the model on the desired behavior.
|
||||
*
|
||||
* Note that the server sets default instructions which will be used if this field
|
||||
* is not set and are visible in the `session.created` event at the start of the
|
||||
* session.
|
||||
*/
|
||||
instructions?: string;
|
||||
|
||||
/**
|
||||
* Maximum number of output tokens for a single assistant response, inclusive of
|
||||
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
||||
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
||||
*/
|
||||
max_response_output_tokens?: number | 'inf';
|
||||
|
||||
/**
|
||||
* The set of modalities the model can respond with. To disable audio, set this to
|
||||
* ["text"].
|
||||
*/
|
||||
modalities?: Array<'text' | 'audio'>;
|
||||
|
||||
/**
|
||||
* The Realtime model used for this session.
|
||||
*/
|
||||
model?:
|
||||
| 'gpt-4o-realtime-preview'
|
||||
| 'gpt-4o-realtime-preview-2024-10-01'
|
||||
| 'gpt-4o-realtime-preview-2024-12-17'
|
||||
| 'gpt-4o-mini-realtime-preview'
|
||||
| 'gpt-4o-mini-realtime-preview-2024-12-17';
|
||||
|
||||
/**
|
||||
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
|
||||
* For `pcm16`, output audio is sampled at a rate of 24kHz.
|
||||
*/
|
||||
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
|
||||
|
||||
/**
|
||||
* Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
|
||||
* temperature of 0.8 is highly recommended for best performance.
|
||||
*/
|
||||
temperature?: number;
|
||||
|
||||
/**
|
||||
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
|
||||
* a function.
|
||||
*/
|
||||
tool_choice?: string;
|
||||
|
||||
/**
|
||||
* Tools (functions) available to the model.
|
||||
*/
|
||||
tools?: Array<SessionCreateParams.Tool>;
|
||||
|
||||
/**
|
||||
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
||||
* set to `null` to turn off, in which case the client must manually trigger model
|
||||
* response. Server VAD means that the model will detect the start and end of
|
||||
* speech based on audio volume and respond at the end of user speech. Semantic VAD
|
||||
* is more advanced and uses a turn detection model (in conjuction with VAD) to
|
||||
* semantically estimate whether the user has finished speaking, then dynamically
|
||||
* sets a timeout based on this probability. For example, if user audio trails off
|
||||
* with "uhhm", the model will score a low probability of turn end and wait longer
|
||||
* for the user to continue speaking. This can be useful for more natural
|
||||
* conversations, but may have a higher latency.
|
||||
*/
|
||||
turn_detection?: SessionCreateParams.TurnDetection;
|
||||
|
||||
/**
|
||||
* The voice the model uses to respond. Voice cannot be changed during the session
|
||||
* once the model has responded with audio at least once. Current voice options are
|
||||
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`,
|
||||
* `shimmer`, and `verse`.
|
||||
*/
|
||||
voice?:
|
||||
| (string & {})
|
||||
| 'alloy'
|
||||
| 'ash'
|
||||
| 'ballad'
|
||||
| 'coral'
|
||||
| 'echo'
|
||||
| 'fable'
|
||||
| 'onyx'
|
||||
| 'nova'
|
||||
| 'sage'
|
||||
| 'shimmer'
|
||||
| 'verse';
|
||||
}
|
||||
|
||||
export namespace SessionCreateParams {
|
||||
/**
|
||||
* Configuration options for the generated client secret.
|
||||
*/
|
||||
export interface ClientSecret {
|
||||
/**
|
||||
* Configuration for the ephemeral token expiration.
|
||||
*/
|
||||
expires_at?: ClientSecret.ExpiresAt;
|
||||
}
|
||||
|
||||
export namespace ClientSecret {
|
||||
/**
|
||||
* Configuration for the ephemeral token expiration.
|
||||
*/
|
||||
export interface ExpiresAt {
|
||||
/**
|
||||
* The anchor point for the ephemeral token expiration. Only `created_at` is
|
||||
* currently supported.
|
||||
*/
|
||||
anchor?: 'created_at';
|
||||
|
||||
/**
|
||||
* The number of seconds from the anchor point to the expiration. Select a value
|
||||
* between `10` and `7200`.
|
||||
*/
|
||||
seconds?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for input audio noise reduction. This can be set to `null` to turn
|
||||
* off. Noise reduction filters audio added to the input audio buffer before it is
|
||||
* sent to VAD and the model. Filtering the audio can improve VAD and turn
|
||||
* detection accuracy (reducing false positives) and model performance by improving
|
||||
* perception of the input audio.
|
||||
*/
|
||||
export interface InputAudioNoiseReduction {
|
||||
/**
|
||||
* Type of noise reduction. `near_field` is for close-talking microphones such as
|
||||
* headphones, `far_field` is for far-field microphones such as laptop or
|
||||
* conference room microphones.
|
||||
*/
|
||||
type?: 'near_field' | 'far_field';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription, defaults to off and can be set to
|
||||
* `null` to turn off once on. Input audio transcription is not native to the
|
||||
* model, since the model consumes audio directly. Transcription runs
|
||||
* asynchronously through
|
||||
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
|
||||
* and should be treated as guidance of input audio content rather than precisely
|
||||
* what the model heard. The client can optionally set the language and prompt for
|
||||
* transcription, these offer additional guidance to the transcription service.
|
||||
*/
|
||||
export interface InputAudioTranscription {
|
||||
/**
|
||||
* The language of the input audio. Supplying the input language in
|
||||
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
|
||||
* format will improve accuracy and latency.
|
||||
*/
|
||||
language?: string;
|
||||
|
||||
/**
|
||||
* The model to use for transcription, current options are `gpt-4o-transcribe`,
|
||||
* `gpt-4o-mini-transcribe`, and `whisper-1`.
|
||||
*/
|
||||
model?: string;
|
||||
|
||||
/**
|
||||
* An optional text to guide the model's style or continue a previous audio
|
||||
* segment. For `whisper-1`, the
|
||||
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
|
||||
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
|
||||
* "expect words related to technology".
|
||||
*/
|
||||
prompt?: string;
|
||||
}
|
||||
|
||||
export interface Tool {
|
||||
/**
|
||||
* The description of the function, including guidance on when and how to call it,
|
||||
* and guidance about what to tell the user when calling (if anything).
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* The name of the function.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Parameters of the function in JSON Schema.
|
||||
*/
|
||||
parameters?: unknown;
|
||||
|
||||
/**
|
||||
* The type of the tool, i.e. `function`.
|
||||
*/
|
||||
type?: 'function';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
||||
* set to `null` to turn off, in which case the client must manually trigger model
|
||||
* response. Server VAD means that the model will detect the start and end of
|
||||
* speech based on audio volume and respond at the end of user speech. Semantic VAD
|
||||
* is more advanced and uses a turn detection model (in conjuction with VAD) to
|
||||
* semantically estimate whether the user has finished speaking, then dynamically
|
||||
* sets a timeout based on this probability. For example, if user audio trails off
|
||||
* with "uhhm", the model will score a low probability of turn end and wait longer
|
||||
* for the user to continue speaking. This can be useful for more natural
|
||||
* conversations, but may have a higher latency.
|
||||
*/
|
||||
export interface TurnDetection {
|
||||
/**
|
||||
* Whether or not to automatically generate a response when a VAD stop event
|
||||
* occurs.
|
||||
*/
|
||||
create_response?: boolean;
|
||||
|
||||
/**
|
||||
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
|
||||
* will wait longer for the user to continue speaking, `high` will respond more
|
||||
* quickly. `auto` is the default and is equivalent to `medium`.
|
||||
*/
|
||||
eagerness?: 'low' | 'medium' | 'high' | 'auto';
|
||||
|
||||
/**
|
||||
* Whether or not to automatically interrupt any ongoing response with output to
|
||||
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
|
||||
* occurs.
|
||||
*/
|
||||
interrupt_response?: boolean;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Amount of audio to include before the VAD
|
||||
* detected speech (in milliseconds). Defaults to 300ms.
|
||||
*/
|
||||
prefix_padding_ms?: number;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
|
||||
* milliseconds). Defaults to 500ms. With shorter values the model will respond
|
||||
* more quickly, but may jump in on short pauses from the user.
|
||||
*/
|
||||
silence_duration_ms?: number;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
|
||||
* defaults to 0.5. A higher threshold will require louder audio to activate the
|
||||
* model, and thus might perform better in noisy environments.
|
||||
*/
|
||||
threshold?: number;
|
||||
|
||||
/**
|
||||
* Type of turn detection.
|
||||
*/
|
||||
type?: 'server_vad' | 'semantic_vad';
|
||||
}
|
||||
}
|
||||
|
||||
export declare namespace Sessions {
|
||||
export {
|
||||
type Session as Session,
|
||||
type SessionCreateResponse as SessionCreateResponse,
|
||||
type SessionCreateParams as SessionCreateParams,
|
||||
};
|
||||
}
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import * as Core from '../../../core';
|
||||
|
||||
export class TranscriptionSessions extends APIResource {
|
||||
/**
|
||||
* Create an ephemeral API token for use in client-side applications with the
|
||||
* Realtime API specifically for realtime transcriptions. Can be configured with
|
||||
* the same session parameters as the `transcription_session.update` client event.
|
||||
*
|
||||
* It responds with a session object, plus a `client_secret` key which contains a
|
||||
* usable ephemeral API token that can be used to authenticate browser clients for
|
||||
* the Realtime API.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const transcriptionSession =
|
||||
* await client.beta.realtime.transcriptionSessions.create();
|
||||
* ```
|
||||
*/
|
||||
create(
|
||||
body: TranscriptionSessionCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<TranscriptionSession> {
|
||||
return this._client.post('/realtime/transcription_sessions', {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A new Realtime transcription session configuration.
|
||||
*
|
||||
* When a session is created on the server via REST API, the session object also
|
||||
* contains an ephemeral key. Default TTL for keys is 10 minutes. This property is
|
||||
* not present when a session is updated via the WebSocket API.
|
||||
*/
|
||||
export interface TranscriptionSession {
|
||||
/**
|
||||
* Ephemeral key returned by the API. Only present when the session is created on
|
||||
* the server via REST API.
|
||||
*/
|
||||
client_secret: TranscriptionSession.ClientSecret;
|
||||
|
||||
/**
|
||||
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
|
||||
*/
|
||||
input_audio_format?: string;
|
||||
|
||||
/**
|
||||
* Configuration of the transcription model.
|
||||
*/
|
||||
input_audio_transcription?: TranscriptionSession.InputAudioTranscription;
|
||||
|
||||
/**
|
||||
* The set of modalities the model can respond with. To disable audio, set this to
|
||||
* ["text"].
|
||||
*/
|
||||
modalities?: Array<'text' | 'audio'>;
|
||||
|
||||
/**
|
||||
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
|
||||
* means that the model will detect the start and end of speech based on audio
|
||||
* volume and respond at the end of user speech.
|
||||
*/
|
||||
turn_detection?: TranscriptionSession.TurnDetection;
|
||||
}
|
||||
|
||||
export namespace TranscriptionSession {
|
||||
/**
|
||||
* Ephemeral key returned by the API. Only present when the session is created on
|
||||
* the server via REST API.
|
||||
*/
|
||||
export interface ClientSecret {
|
||||
/**
|
||||
* Timestamp for when the token expires. Currently, all tokens expire after one
|
||||
* minute.
|
||||
*/
|
||||
expires_at: number;
|
||||
|
||||
/**
|
||||
* Ephemeral key usable in client environments to authenticate connections to the
|
||||
* Realtime API. Use this in client-side environments rather than a standard API
|
||||
* token, which should only be used server-side.
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration of the transcription model.
|
||||
*/
|
||||
export interface InputAudioTranscription {
|
||||
/**
|
||||
* The language of the input audio. Supplying the input language in
|
||||
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
|
||||
* format will improve accuracy and latency.
|
||||
*/
|
||||
language?: string;
|
||||
|
||||
/**
|
||||
* The model to use for transcription. Can be `gpt-4o-transcribe`,
|
||||
* `gpt-4o-mini-transcribe`, or `whisper-1`.
|
||||
*/
|
||||
model?: 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'whisper-1';
|
||||
|
||||
/**
|
||||
* An optional text to guide the model's style or continue a previous audio
|
||||
* segment. The
|
||||
* [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
|
||||
* should match the audio language.
|
||||
*/
|
||||
prompt?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
|
||||
* means that the model will detect the start and end of speech based on audio
|
||||
* volume and respond at the end of user speech.
|
||||
*/
|
||||
export interface TurnDetection {
|
||||
/**
|
||||
* Amount of audio to include before the VAD detected speech (in milliseconds).
|
||||
* Defaults to 300ms.
|
||||
*/
|
||||
prefix_padding_ms?: number;
|
||||
|
||||
/**
|
||||
* Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms.
|
||||
* With shorter values the model will respond more quickly, but may jump in on
|
||||
* short pauses from the user.
|
||||
*/
|
||||
silence_duration_ms?: number;
|
||||
|
||||
/**
|
||||
* Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher
|
||||
* threshold will require louder audio to activate the model, and thus might
|
||||
* perform better in noisy environments.
|
||||
*/
|
||||
threshold?: number;
|
||||
|
||||
/**
|
||||
* Type of turn detection, only `server_vad` is currently supported.
|
||||
*/
|
||||
type?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface TranscriptionSessionCreateParams {
|
||||
/**
|
||||
* Configuration options for the generated client secret.
|
||||
*/
|
||||
client_secret?: TranscriptionSessionCreateParams.ClientSecret;
|
||||
|
||||
/**
|
||||
* The set of items to include in the transcription. Current available items are:
|
||||
*
|
||||
* - `item.input_audio_transcription.logprobs`
|
||||
*/
|
||||
include?: Array<string>;
|
||||
|
||||
/**
|
||||
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
|
||||
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
|
||||
* (mono), and little-endian byte order.
|
||||
*/
|
||||
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
|
||||
|
||||
/**
|
||||
* Configuration for input audio noise reduction. This can be set to `null` to turn
|
||||
* off. Noise reduction filters audio added to the input audio buffer before it is
|
||||
* sent to VAD and the model. Filtering the audio can improve VAD and turn
|
||||
* detection accuracy (reducing false positives) and model performance by improving
|
||||
* perception of the input audio.
|
||||
*/
|
||||
input_audio_noise_reduction?: TranscriptionSessionCreateParams.InputAudioNoiseReduction;
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription. The client can optionally set the
|
||||
* language and prompt for transcription, these offer additional guidance to the
|
||||
* transcription service.
|
||||
*/
|
||||
input_audio_transcription?: TranscriptionSessionCreateParams.InputAudioTranscription;
|
||||
|
||||
/**
|
||||
* The set of modalities the model can respond with. To disable audio, set this to
|
||||
* ["text"].
|
||||
*/
|
||||
modalities?: Array<'text' | 'audio'>;
|
||||
|
||||
/**
|
||||
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
||||
* set to `null` to turn off, in which case the client must manually trigger model
|
||||
* response. Server VAD means that the model will detect the start and end of
|
||||
* speech based on audio volume and respond at the end of user speech. Semantic VAD
|
||||
* is more advanced and uses a turn detection model (in conjuction with VAD) to
|
||||
* semantically estimate whether the user has finished speaking, then dynamically
|
||||
* sets a timeout based on this probability. For example, if user audio trails off
|
||||
* with "uhhm", the model will score a low probability of turn end and wait longer
|
||||
* for the user to continue speaking. This can be useful for more natural
|
||||
* conversations, but may have a higher latency.
|
||||
*/
|
||||
turn_detection?: TranscriptionSessionCreateParams.TurnDetection;
|
||||
}
|
||||
|
||||
export namespace TranscriptionSessionCreateParams {
|
||||
/**
|
||||
* Configuration options for the generated client secret.
|
||||
*/
|
||||
export interface ClientSecret {
|
||||
/**
|
||||
* Configuration for the ephemeral token expiration.
|
||||
*/
|
||||
expires_at?: ClientSecret.ExpiresAt;
|
||||
}
|
||||
|
||||
export namespace ClientSecret {
|
||||
/**
|
||||
* Configuration for the ephemeral token expiration.
|
||||
*/
|
||||
export interface ExpiresAt {
|
||||
/**
|
||||
* The anchor point for the ephemeral token expiration. Only `created_at` is
|
||||
* currently supported.
|
||||
*/
|
||||
anchor?: 'created_at';
|
||||
|
||||
/**
|
||||
* The number of seconds from the anchor point to the expiration. Select a value
|
||||
* between `10` and `7200`.
|
||||
*/
|
||||
seconds?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for input audio noise reduction. This can be set to `null` to turn
|
||||
* off. Noise reduction filters audio added to the input audio buffer before it is
|
||||
* sent to VAD and the model. Filtering the audio can improve VAD and turn
|
||||
* detection accuracy (reducing false positives) and model performance by improving
|
||||
* perception of the input audio.
|
||||
*/
|
||||
export interface InputAudioNoiseReduction {
|
||||
/**
|
||||
* Type of noise reduction. `near_field` is for close-talking microphones such as
|
||||
* headphones, `far_field` is for far-field microphones such as laptop or
|
||||
* conference room microphones.
|
||||
*/
|
||||
type?: 'near_field' | 'far_field';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription. The client can optionally set the
|
||||
* language and prompt for transcription, these offer additional guidance to the
|
||||
* transcription service.
|
||||
*/
|
||||
export interface InputAudioTranscription {
|
||||
/**
|
||||
* The language of the input audio. Supplying the input language in
|
||||
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
|
||||
* format will improve accuracy and latency.
|
||||
*/
|
||||
language?: string;
|
||||
|
||||
/**
|
||||
* The model to use for transcription, current options are `gpt-4o-transcribe`,
|
||||
* `gpt-4o-mini-transcribe`, and `whisper-1`.
|
||||
*/
|
||||
model?: 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'whisper-1';
|
||||
|
||||
/**
|
||||
* An optional text to guide the model's style or continue a previous audio
|
||||
* segment. For `whisper-1`, the
|
||||
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
|
||||
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
|
||||
* "expect words related to technology".
|
||||
*/
|
||||
prompt?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
||||
* set to `null` to turn off, in which case the client must manually trigger model
|
||||
* response. Server VAD means that the model will detect the start and end of
|
||||
* speech based on audio volume and respond at the end of user speech. Semantic VAD
|
||||
* is more advanced and uses a turn detection model (in conjuction with VAD) to
|
||||
* semantically estimate whether the user has finished speaking, then dynamically
|
||||
* sets a timeout based on this probability. For example, if user audio trails off
|
||||
* with "uhhm", the model will score a low probability of turn end and wait longer
|
||||
* for the user to continue speaking. This can be useful for more natural
|
||||
* conversations, but may have a higher latency.
|
||||
*/
|
||||
export interface TurnDetection {
|
||||
/**
|
||||
* Whether or not to automatically generate a response when a VAD stop event
|
||||
* occurs. Not available for transcription sessions.
|
||||
*/
|
||||
create_response?: boolean;
|
||||
|
||||
/**
|
||||
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
|
||||
* will wait longer for the user to continue speaking, `high` will respond more
|
||||
* quickly. `auto` is the default and is equivalent to `medium`.
|
||||
*/
|
||||
eagerness?: 'low' | 'medium' | 'high' | 'auto';
|
||||
|
||||
/**
|
||||
* Whether or not to automatically interrupt any ongoing response with output to
|
||||
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
|
||||
* occurs. Not available for transcription sessions.
|
||||
*/
|
||||
interrupt_response?: boolean;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Amount of audio to include before the VAD
|
||||
* detected speech (in milliseconds). Defaults to 300ms.
|
||||
*/
|
||||
prefix_padding_ms?: number;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
|
||||
* milliseconds). Defaults to 500ms. With shorter values the model will respond
|
||||
* more quickly, but may jump in on short pauses from the user.
|
||||
*/
|
||||
silence_duration_ms?: number;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
|
||||
* defaults to 0.5. A higher threshold will require louder audio to activate the
|
||||
* model, and thus might perform better in noisy environments.
|
||||
*/
|
||||
threshold?: number;
|
||||
|
||||
/**
|
||||
* Type of turn detection.
|
||||
*/
|
||||
type?: 'server_vad' | 'semantic_vad';
|
||||
}
|
||||
}
|
||||
|
||||
export declare namespace TranscriptionSessions {
|
||||
export {
|
||||
type TranscriptionSession as TranscriptionSession,
|
||||
type TranscriptionSessionCreateParams as TranscriptionSessionCreateParams,
|
||||
};
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
MessagesPage,
|
||||
Messages,
|
||||
type Annotation,
|
||||
type AnnotationDelta,
|
||||
type FileCitationAnnotation,
|
||||
type FileCitationDeltaAnnotation,
|
||||
type FilePathAnnotation,
|
||||
type FilePathDeltaAnnotation,
|
||||
type ImageFile,
|
||||
type ImageFileContentBlock,
|
||||
type ImageFileDelta,
|
||||
type ImageFileDeltaBlock,
|
||||
type ImageURL,
|
||||
type ImageURLContentBlock,
|
||||
type ImageURLDelta,
|
||||
type ImageURLDeltaBlock,
|
||||
type Message,
|
||||
type MessageContent,
|
||||
type MessageContentDelta,
|
||||
type MessageContentPartParam,
|
||||
type MessageDeleted,
|
||||
type MessageDelta,
|
||||
type MessageDeltaEvent,
|
||||
type RefusalContentBlock,
|
||||
type RefusalDeltaBlock,
|
||||
type Text,
|
||||
type TextContentBlock,
|
||||
type TextContentBlockParam,
|
||||
type TextDelta,
|
||||
type TextDeltaBlock,
|
||||
type MessageCreateParams,
|
||||
type MessageUpdateParams,
|
||||
type MessageListParams,
|
||||
} from './messages';
|
||||
export {
|
||||
RunsPage,
|
||||
Runs,
|
||||
type RequiredActionFunctionToolCall,
|
||||
type Run,
|
||||
type RunStatus,
|
||||
type RunCreateParams,
|
||||
type RunCreateParamsNonStreaming,
|
||||
type RunCreateParamsStreaming,
|
||||
type RunUpdateParams,
|
||||
type RunListParams,
|
||||
type RunSubmitToolOutputsParams,
|
||||
type RunSubmitToolOutputsParamsNonStreaming,
|
||||
type RunSubmitToolOutputsParamsStreaming,
|
||||
type RunCreateAndPollParams,
|
||||
type RunCreateAndStreamParams,
|
||||
type RunStreamParams,
|
||||
type RunSubmitToolOutputsAndPollParams,
|
||||
type RunSubmitToolOutputsStreamParams,
|
||||
} from './runs/index';
|
||||
export {
|
||||
Threads,
|
||||
type AssistantResponseFormatOption,
|
||||
type AssistantToolChoice,
|
||||
type AssistantToolChoiceFunction,
|
||||
type AssistantToolChoiceOption,
|
||||
type Thread,
|
||||
type ThreadDeleted,
|
||||
type ThreadCreateParams,
|
||||
type ThreadUpdateParams,
|
||||
type ThreadCreateAndRunParams,
|
||||
type ThreadCreateAndRunParamsNonStreaming,
|
||||
type ThreadCreateAndRunParamsStreaming,
|
||||
type ThreadCreateAndRunPollParams,
|
||||
type ThreadCreateAndRunStreamParams,
|
||||
} from './threads';
|
||||
+781
@@ -0,0 +1,781 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import { isRequestOptions } from '../../../core';
|
||||
import * as Core from '../../../core';
|
||||
import * as Shared from '../../shared';
|
||||
import * as AssistantsAPI from '../assistants';
|
||||
import { CursorPage, type CursorPageParams } from '../../../pagination';
|
||||
|
||||
/**
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
export class Messages extends APIResource {
|
||||
/**
|
||||
* Create a message.
|
||||
*
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
create(
|
||||
threadId: string,
|
||||
body: MessageCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<Message> {
|
||||
return this._client.post(`/threads/${threadId}/messages`, {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a message.
|
||||
*
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
retrieve(threadId: string, messageId: string, options?: Core.RequestOptions): Core.APIPromise<Message> {
|
||||
return this._client.get(`/threads/${threadId}/messages/${messageId}`, {
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies a message.
|
||||
*
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
update(
|
||||
threadId: string,
|
||||
messageId: string,
|
||||
body: MessageUpdateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<Message> {
|
||||
return this._client.post(`/threads/${threadId}/messages/${messageId}`, {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of messages for a given thread.
|
||||
*
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
list(
|
||||
threadId: string,
|
||||
query?: MessageListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<MessagesPage, Message>;
|
||||
list(threadId: string, options?: Core.RequestOptions): Core.PagePromise<MessagesPage, Message>;
|
||||
list(
|
||||
threadId: string,
|
||||
query: MessageListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<MessagesPage, Message> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(threadId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(`/threads/${threadId}/messages`, MessagesPage, {
|
||||
query,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a message.
|
||||
*
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
del(threadId: string, messageId: string, options?: Core.RequestOptions): Core.APIPromise<MessageDeleted> {
|
||||
return this._client.delete(`/threads/${threadId}/messages/${messageId}`, {
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class MessagesPage extends CursorPage<Message> {}
|
||||
|
||||
/**
|
||||
* A citation within the message that points to a specific quote from a specific
|
||||
* File associated with the assistant or the message. Generated when the assistant
|
||||
* uses the "file_search" tool to search files.
|
||||
*/
|
||||
export type Annotation = FileCitationAnnotation | FilePathAnnotation;
|
||||
|
||||
/**
|
||||
* A citation within the message that points to a specific quote from a specific
|
||||
* File associated with the assistant or the message. Generated when the assistant
|
||||
* uses the "file_search" tool to search files.
|
||||
*/
|
||||
export type AnnotationDelta = FileCitationDeltaAnnotation | FilePathDeltaAnnotation;
|
||||
|
||||
/**
|
||||
* A citation within the message that points to a specific quote from a specific
|
||||
* File associated with the assistant or the message. Generated when the assistant
|
||||
* uses the "file_search" tool to search files.
|
||||
*/
|
||||
export interface FileCitationAnnotation {
|
||||
end_index: number;
|
||||
|
||||
file_citation: FileCitationAnnotation.FileCitation;
|
||||
|
||||
start_index: number;
|
||||
|
||||
/**
|
||||
* The text in the message content that needs to be replaced.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Always `file_citation`.
|
||||
*/
|
||||
type: 'file_citation';
|
||||
}
|
||||
|
||||
export namespace FileCitationAnnotation {
|
||||
export interface FileCitation {
|
||||
/**
|
||||
* The ID of the specific File the citation is from.
|
||||
*/
|
||||
file_id: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A citation within the message that points to a specific quote from a specific
|
||||
* File associated with the assistant or the message. Generated when the assistant
|
||||
* uses the "file_search" tool to search files.
|
||||
*/
|
||||
export interface FileCitationDeltaAnnotation {
|
||||
/**
|
||||
* The index of the annotation in the text content part.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Always `file_citation`.
|
||||
*/
|
||||
type: 'file_citation';
|
||||
|
||||
end_index?: number;
|
||||
|
||||
file_citation?: FileCitationDeltaAnnotation.FileCitation;
|
||||
|
||||
start_index?: number;
|
||||
|
||||
/**
|
||||
* The text in the message content that needs to be replaced.
|
||||
*/
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export namespace FileCitationDeltaAnnotation {
|
||||
export interface FileCitation {
|
||||
/**
|
||||
* The ID of the specific File the citation is from.
|
||||
*/
|
||||
file_id?: string;
|
||||
|
||||
/**
|
||||
* The specific quote in the file.
|
||||
*/
|
||||
quote?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A URL for the file that's generated when the assistant used the
|
||||
* `code_interpreter` tool to generate a file.
|
||||
*/
|
||||
export interface FilePathAnnotation {
|
||||
end_index: number;
|
||||
|
||||
file_path: FilePathAnnotation.FilePath;
|
||||
|
||||
start_index: number;
|
||||
|
||||
/**
|
||||
* The text in the message content that needs to be replaced.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Always `file_path`.
|
||||
*/
|
||||
type: 'file_path';
|
||||
}
|
||||
|
||||
export namespace FilePathAnnotation {
|
||||
export interface FilePath {
|
||||
/**
|
||||
* The ID of the file that was generated.
|
||||
*/
|
||||
file_id: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A URL for the file that's generated when the assistant used the
|
||||
* `code_interpreter` tool to generate a file.
|
||||
*/
|
||||
export interface FilePathDeltaAnnotation {
|
||||
/**
|
||||
* The index of the annotation in the text content part.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Always `file_path`.
|
||||
*/
|
||||
type: 'file_path';
|
||||
|
||||
end_index?: number;
|
||||
|
||||
file_path?: FilePathDeltaAnnotation.FilePath;
|
||||
|
||||
start_index?: number;
|
||||
|
||||
/**
|
||||
* The text in the message content that needs to be replaced.
|
||||
*/
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export namespace FilePathDeltaAnnotation {
|
||||
export interface FilePath {
|
||||
/**
|
||||
* The ID of the file that was generated.
|
||||
*/
|
||||
file_id?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ImageFile {
|
||||
/**
|
||||
* The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
|
||||
* in the message content. Set `purpose="vision"` when uploading the File if you
|
||||
* need to later display the file content.
|
||||
*/
|
||||
file_id: string;
|
||||
|
||||
/**
|
||||
* Specifies the detail level of the image if specified by the user. `low` uses
|
||||
* fewer tokens, you can opt in to high resolution using `high`.
|
||||
*/
|
||||
detail?: 'auto' | 'low' | 'high';
|
||||
}
|
||||
|
||||
/**
|
||||
* References an image [File](https://platform.openai.com/docs/api-reference/files)
|
||||
* in the content of a message.
|
||||
*/
|
||||
export interface ImageFileContentBlock {
|
||||
image_file: ImageFile;
|
||||
|
||||
/**
|
||||
* Always `image_file`.
|
||||
*/
|
||||
type: 'image_file';
|
||||
}
|
||||
|
||||
export interface ImageFileDelta {
|
||||
/**
|
||||
* Specifies the detail level of the image if specified by the user. `low` uses
|
||||
* fewer tokens, you can opt in to high resolution using `high`.
|
||||
*/
|
||||
detail?: 'auto' | 'low' | 'high';
|
||||
|
||||
/**
|
||||
* The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
|
||||
* in the message content. Set `purpose="vision"` when uploading the File if you
|
||||
* need to later display the file content.
|
||||
*/
|
||||
file_id?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* References an image [File](https://platform.openai.com/docs/api-reference/files)
|
||||
* in the content of a message.
|
||||
*/
|
||||
export interface ImageFileDeltaBlock {
|
||||
/**
|
||||
* The index of the content part in the message.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Always `image_file`.
|
||||
*/
|
||||
type: 'image_file';
|
||||
|
||||
image_file?: ImageFileDelta;
|
||||
}
|
||||
|
||||
export interface ImageURL {
|
||||
/**
|
||||
* The external URL of the image, must be a supported image types: jpeg, jpg, png,
|
||||
* gif, webp.
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
|
||||
* to high resolution using `high`. Default value is `auto`
|
||||
*/
|
||||
detail?: 'auto' | 'low' | 'high';
|
||||
}
|
||||
|
||||
/**
|
||||
* References an image URL in the content of a message.
|
||||
*/
|
||||
export interface ImageURLContentBlock {
|
||||
image_url: ImageURL;
|
||||
|
||||
/**
|
||||
* The type of the content part.
|
||||
*/
|
||||
type: 'image_url';
|
||||
}
|
||||
|
||||
export interface ImageURLDelta {
|
||||
/**
|
||||
* Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
|
||||
* to high resolution using `high`.
|
||||
*/
|
||||
detail?: 'auto' | 'low' | 'high';
|
||||
|
||||
/**
|
||||
* The URL of the image, must be a supported image types: jpeg, jpg, png, gif,
|
||||
* webp.
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* References an image URL in the content of a message.
|
||||
*/
|
||||
export interface ImageURLDeltaBlock {
|
||||
/**
|
||||
* The index of the content part in the message.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Always `image_url`.
|
||||
*/
|
||||
type: 'image_url';
|
||||
|
||||
image_url?: ImageURLDelta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a message within a
|
||||
* [thread](https://platform.openai.com/docs/api-reference/threads).
|
||||
*/
|
||||
export interface Message {
|
||||
/**
|
||||
* The identifier, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* If applicable, the ID of the
|
||||
* [assistant](https://platform.openai.com/docs/api-reference/assistants) that
|
||||
* authored this message.
|
||||
*/
|
||||
assistant_id: string | null;
|
||||
|
||||
/**
|
||||
* A list of files attached to the message, and the tools they were added to.
|
||||
*/
|
||||
attachments: Array<Message.Attachment> | null;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the message was completed.
|
||||
*/
|
||||
completed_at: number | null;
|
||||
|
||||
/**
|
||||
* The content of the message in array of text and/or images.
|
||||
*/
|
||||
content: Array<MessageContent>;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the message was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the message was marked as incomplete.
|
||||
*/
|
||||
incomplete_at: number | null;
|
||||
|
||||
/**
|
||||
* On an incomplete message, details about why the message is incomplete.
|
||||
*/
|
||||
incomplete_details: Message.IncompleteDetails | null;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The object type, which is always `thread.message`.
|
||||
*/
|
||||
object: 'thread.message';
|
||||
|
||||
/**
|
||||
* The entity that produced the message. One of `user` or `assistant`.
|
||||
*/
|
||||
role: 'user' | 'assistant';
|
||||
|
||||
/**
|
||||
* The ID of the [run](https://platform.openai.com/docs/api-reference/runs)
|
||||
* associated with the creation of this message. Value is `null` when messages are
|
||||
* created manually using the create message or create thread endpoints.
|
||||
*/
|
||||
run_id: string | null;
|
||||
|
||||
/**
|
||||
* The status of the message, which can be either `in_progress`, `incomplete`, or
|
||||
* `completed`.
|
||||
*/
|
||||
status: 'in_progress' | 'incomplete' | 'completed';
|
||||
|
||||
/**
|
||||
* The [thread](https://platform.openai.com/docs/api-reference/threads) ID that
|
||||
* this message belongs to.
|
||||
*/
|
||||
thread_id: string;
|
||||
}
|
||||
|
||||
export namespace Message {
|
||||
export interface Attachment {
|
||||
/**
|
||||
* The ID of the file to attach to the message.
|
||||
*/
|
||||
file_id?: string;
|
||||
|
||||
/**
|
||||
* The tools to add this file to.
|
||||
*/
|
||||
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.AssistantToolsFileSearchTypeOnly>;
|
||||
}
|
||||
|
||||
export namespace Attachment {
|
||||
export interface AssistantToolsFileSearchTypeOnly {
|
||||
/**
|
||||
* The type of tool being defined: `file_search`
|
||||
*/
|
||||
type: 'file_search';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On an incomplete message, details about why the message is incomplete.
|
||||
*/
|
||||
export interface IncompleteDetails {
|
||||
/**
|
||||
* The reason the message is incomplete.
|
||||
*/
|
||||
reason: 'content_filter' | 'max_tokens' | 'run_cancelled' | 'run_expired' | 'run_failed';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* References an image [File](https://platform.openai.com/docs/api-reference/files)
|
||||
* in the content of a message.
|
||||
*/
|
||||
export type MessageContent =
|
||||
| ImageFileContentBlock
|
||||
| ImageURLContentBlock
|
||||
| TextContentBlock
|
||||
| RefusalContentBlock;
|
||||
|
||||
/**
|
||||
* References an image [File](https://platform.openai.com/docs/api-reference/files)
|
||||
* in the content of a message.
|
||||
*/
|
||||
export type MessageContentDelta =
|
||||
| ImageFileDeltaBlock
|
||||
| TextDeltaBlock
|
||||
| RefusalDeltaBlock
|
||||
| ImageURLDeltaBlock;
|
||||
|
||||
/**
|
||||
* References an image [File](https://platform.openai.com/docs/api-reference/files)
|
||||
* in the content of a message.
|
||||
*/
|
||||
export type MessageContentPartParam = ImageFileContentBlock | ImageURLContentBlock | TextContentBlockParam;
|
||||
|
||||
export interface MessageDeleted {
|
||||
id: string;
|
||||
|
||||
deleted: boolean;
|
||||
|
||||
object: 'thread.message.deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* The delta containing the fields that have changed on the Message.
|
||||
*/
|
||||
export interface MessageDelta {
|
||||
/**
|
||||
* The content of the message in array of text and/or images.
|
||||
*/
|
||||
content?: Array<MessageContentDelta>;
|
||||
|
||||
/**
|
||||
* The entity that produced the message. One of `user` or `assistant`.
|
||||
*/
|
||||
role?: 'user' | 'assistant';
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a message delta i.e. any changed fields on a message during
|
||||
* streaming.
|
||||
*/
|
||||
export interface MessageDeltaEvent {
|
||||
/**
|
||||
* The identifier of the message, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The delta containing the fields that have changed on the Message.
|
||||
*/
|
||||
delta: MessageDelta;
|
||||
|
||||
/**
|
||||
* The object type, which is always `thread.message.delta`.
|
||||
*/
|
||||
object: 'thread.message.delta';
|
||||
}
|
||||
|
||||
/**
|
||||
* The refusal content generated by the assistant.
|
||||
*/
|
||||
export interface RefusalContentBlock {
|
||||
refusal: string;
|
||||
|
||||
/**
|
||||
* Always `refusal`.
|
||||
*/
|
||||
type: 'refusal';
|
||||
}
|
||||
|
||||
/**
|
||||
* The refusal content that is part of a message.
|
||||
*/
|
||||
export interface RefusalDeltaBlock {
|
||||
/**
|
||||
* The index of the refusal part in the message.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Always `refusal`.
|
||||
*/
|
||||
type: 'refusal';
|
||||
|
||||
refusal?: string;
|
||||
}
|
||||
|
||||
export interface Text {
|
||||
annotations: Array<Annotation>;
|
||||
|
||||
/**
|
||||
* The data that makes up the text.
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The text content that is part of a message.
|
||||
*/
|
||||
export interface TextContentBlock {
|
||||
text: Text;
|
||||
|
||||
/**
|
||||
* Always `text`.
|
||||
*/
|
||||
type: 'text';
|
||||
}
|
||||
|
||||
/**
|
||||
* The text content that is part of a message.
|
||||
*/
|
||||
export interface TextContentBlockParam {
|
||||
/**
|
||||
* Text content to be sent to the model
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Always `text`.
|
||||
*/
|
||||
type: 'text';
|
||||
}
|
||||
|
||||
export interface TextDelta {
|
||||
annotations?: Array<AnnotationDelta>;
|
||||
|
||||
/**
|
||||
* The data that makes up the text.
|
||||
*/
|
||||
value?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The text content that is part of a message.
|
||||
*/
|
||||
export interface TextDeltaBlock {
|
||||
/**
|
||||
* The index of the content part in the message.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Always `text`.
|
||||
*/
|
||||
type: 'text';
|
||||
|
||||
text?: TextDelta;
|
||||
}
|
||||
|
||||
export interface MessageCreateParams {
|
||||
/**
|
||||
* The text contents of the message.
|
||||
*/
|
||||
content: string | Array<MessageContentPartParam>;
|
||||
|
||||
/**
|
||||
* The role of the entity that is creating the message. Allowed values include:
|
||||
*
|
||||
* - `user`: Indicates the message is sent by an actual user and should be used in
|
||||
* most cases to represent user-generated messages.
|
||||
* - `assistant`: Indicates the message is generated by the assistant. Use this
|
||||
* value to insert messages from the assistant into the conversation.
|
||||
*/
|
||||
role: 'user' | 'assistant';
|
||||
|
||||
/**
|
||||
* A list of files attached to the message, and the tools they should be added to.
|
||||
*/
|
||||
attachments?: Array<MessageCreateParams.Attachment> | null;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
export namespace MessageCreateParams {
|
||||
export interface Attachment {
|
||||
/**
|
||||
* The ID of the file to attach to the message.
|
||||
*/
|
||||
file_id?: string;
|
||||
|
||||
/**
|
||||
* The tools to add this file to.
|
||||
*/
|
||||
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
|
||||
}
|
||||
|
||||
export namespace Attachment {
|
||||
export interface FileSearch {
|
||||
/**
|
||||
* The type of tool being defined: `file_search`
|
||||
*/
|
||||
type: 'file_search';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface MessageUpdateParams {
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
export interface MessageListParams extends CursorPageParams {
|
||||
/**
|
||||
* A cursor for use in pagination. `before` is an object ID that defines your place
|
||||
* in the list. For instance, if you make a list request and receive 100 objects,
|
||||
* starting with obj_foo, your subsequent call can include before=obj_foo in order
|
||||
* to fetch the previous page of the list.
|
||||
*/
|
||||
before?: string;
|
||||
|
||||
/**
|
||||
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
||||
* order and `desc` for descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
|
||||
/**
|
||||
* Filter messages by the run ID that generated them.
|
||||
*/
|
||||
run_id?: string;
|
||||
}
|
||||
|
||||
Messages.MessagesPage = MessagesPage;
|
||||
|
||||
export declare namespace Messages {
|
||||
export {
|
||||
type Annotation as Annotation,
|
||||
type AnnotationDelta as AnnotationDelta,
|
||||
type FileCitationAnnotation as FileCitationAnnotation,
|
||||
type FileCitationDeltaAnnotation as FileCitationDeltaAnnotation,
|
||||
type FilePathAnnotation as FilePathAnnotation,
|
||||
type FilePathDeltaAnnotation as FilePathDeltaAnnotation,
|
||||
type ImageFile as ImageFile,
|
||||
type ImageFileContentBlock as ImageFileContentBlock,
|
||||
type ImageFileDelta as ImageFileDelta,
|
||||
type ImageFileDeltaBlock as ImageFileDeltaBlock,
|
||||
type ImageURL as ImageURL,
|
||||
type ImageURLContentBlock as ImageURLContentBlock,
|
||||
type ImageURLDelta as ImageURLDelta,
|
||||
type ImageURLDeltaBlock as ImageURLDeltaBlock,
|
||||
type Message as Message,
|
||||
type MessageContent as MessageContent,
|
||||
type MessageContentDelta as MessageContentDelta,
|
||||
type MessageContentPartParam as MessageContentPartParam,
|
||||
type MessageDeleted as MessageDeleted,
|
||||
type MessageDelta as MessageDelta,
|
||||
type MessageDeltaEvent as MessageDeltaEvent,
|
||||
type RefusalContentBlock as RefusalContentBlock,
|
||||
type RefusalDeltaBlock as RefusalDeltaBlock,
|
||||
type Text as Text,
|
||||
type TextContentBlock as TextContentBlock,
|
||||
type TextContentBlockParam as TextContentBlockParam,
|
||||
type TextDelta as TextDelta,
|
||||
type TextDeltaBlock as TextDeltaBlock,
|
||||
MessagesPage as MessagesPage,
|
||||
type MessageCreateParams as MessageCreateParams,
|
||||
type MessageUpdateParams as MessageUpdateParams,
|
||||
type MessageListParams as MessageListParams,
|
||||
};
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
RunStepsPage,
|
||||
Steps,
|
||||
type CodeInterpreterLogs,
|
||||
type CodeInterpreterOutputImage,
|
||||
type CodeInterpreterToolCall,
|
||||
type CodeInterpreterToolCallDelta,
|
||||
type FileSearchToolCall,
|
||||
type FileSearchToolCallDelta,
|
||||
type FunctionToolCall,
|
||||
type FunctionToolCallDelta,
|
||||
type MessageCreationStepDetails,
|
||||
type RunStep,
|
||||
type RunStepDelta,
|
||||
type RunStepDeltaEvent,
|
||||
type RunStepDeltaMessageDelta,
|
||||
type RunStepInclude,
|
||||
type ToolCall,
|
||||
type ToolCallDelta,
|
||||
type ToolCallDeltaObject,
|
||||
type ToolCallsStepDetails,
|
||||
type StepRetrieveParams,
|
||||
type StepListParams,
|
||||
} from './steps';
|
||||
export {
|
||||
RunsPage,
|
||||
Runs,
|
||||
type RequiredActionFunctionToolCall,
|
||||
type Run,
|
||||
type RunStatus,
|
||||
type RunCreateParams,
|
||||
type RunCreateParamsNonStreaming,
|
||||
type RunCreateParamsStreaming,
|
||||
type RunUpdateParams,
|
||||
type RunListParams,
|
||||
type RunCreateAndPollParams,
|
||||
type RunCreateAndStreamParams,
|
||||
type RunStreamParams,
|
||||
type RunSubmitToolOutputsParams,
|
||||
type RunSubmitToolOutputsParamsNonStreaming,
|
||||
type RunSubmitToolOutputsParamsStreaming,
|
||||
type RunSubmitToolOutputsAndPollParams,
|
||||
type RunSubmitToolOutputsStreamParams,
|
||||
} from './runs';
|
||||
+1728
File diff suppressed because it is too large
Load Diff
+777
@@ -0,0 +1,777 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../../resource';
|
||||
import { isRequestOptions } from '../../../../core';
|
||||
import * as Core from '../../../../core';
|
||||
import * as StepsAPI from './steps';
|
||||
import * as Shared from '../../../shared';
|
||||
import { CursorPage, type CursorPageParams } from '../../../../pagination';
|
||||
|
||||
/**
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
export class Steps extends APIResource {
|
||||
/**
|
||||
* Retrieves a run step.
|
||||
*
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
retrieve(
|
||||
threadId: string,
|
||||
runId: string,
|
||||
stepId: string,
|
||||
query?: StepRetrieveParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<RunStep>;
|
||||
retrieve(
|
||||
threadId: string,
|
||||
runId: string,
|
||||
stepId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<RunStep>;
|
||||
retrieve(
|
||||
threadId: string,
|
||||
runId: string,
|
||||
stepId: string,
|
||||
query: StepRetrieveParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<RunStep> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.retrieve(threadId, runId, stepId, {}, query);
|
||||
}
|
||||
return this._client.get(`/threads/${threadId}/runs/${runId}/steps/${stepId}`, {
|
||||
query,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of run steps belonging to a run.
|
||||
*
|
||||
* @deprecated The Assistants API is deprecated in favor of the Responses API
|
||||
*/
|
||||
list(
|
||||
threadId: string,
|
||||
runId: string,
|
||||
query?: StepListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<RunStepsPage, RunStep>;
|
||||
list(
|
||||
threadId: string,
|
||||
runId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<RunStepsPage, RunStep>;
|
||||
list(
|
||||
threadId: string,
|
||||
runId: string,
|
||||
query: StepListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<RunStepsPage, RunStep> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(threadId, runId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(`/threads/${threadId}/runs/${runId}/steps`, RunStepsPage, {
|
||||
query,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class RunStepsPage extends CursorPage<RunStep> {}
|
||||
|
||||
/**
|
||||
* Text output from the Code Interpreter tool call as part of a run step.
|
||||
*/
|
||||
export interface CodeInterpreterLogs {
|
||||
/**
|
||||
* The index of the output in the outputs array.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Always `logs`.
|
||||
*/
|
||||
type: 'logs';
|
||||
|
||||
/**
|
||||
* The text output from the Code Interpreter tool call.
|
||||
*/
|
||||
logs?: string;
|
||||
}
|
||||
|
||||
export interface CodeInterpreterOutputImage {
|
||||
/**
|
||||
* The index of the output in the outputs array.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Always `image`.
|
||||
*/
|
||||
type: 'image';
|
||||
|
||||
image?: CodeInterpreterOutputImage.Image;
|
||||
}
|
||||
|
||||
export namespace CodeInterpreterOutputImage {
|
||||
export interface Image {
|
||||
/**
|
||||
* The [file](https://platform.openai.com/docs/api-reference/files) ID of the
|
||||
* image.
|
||||
*/
|
||||
file_id?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the Code Interpreter tool call the run step was involved in.
|
||||
*/
|
||||
export interface CodeInterpreterToolCall {
|
||||
/**
|
||||
* The ID of the tool call.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Code Interpreter tool call definition.
|
||||
*/
|
||||
code_interpreter: CodeInterpreterToolCall.CodeInterpreter;
|
||||
|
||||
/**
|
||||
* The type of tool call. This is always going to be `code_interpreter` for this
|
||||
* type of tool call.
|
||||
*/
|
||||
type: 'code_interpreter';
|
||||
}
|
||||
|
||||
export namespace CodeInterpreterToolCall {
|
||||
/**
|
||||
* The Code Interpreter tool call definition.
|
||||
*/
|
||||
export interface CodeInterpreter {
|
||||
/**
|
||||
* The input to the Code Interpreter tool call.
|
||||
*/
|
||||
input: string;
|
||||
|
||||
/**
|
||||
* The outputs from the Code Interpreter tool call. Code Interpreter can output one
|
||||
* or more items, including text (`logs`) or images (`image`). Each of these are
|
||||
* represented by a different object type.
|
||||
*/
|
||||
outputs: Array<CodeInterpreter.Logs | CodeInterpreter.Image>;
|
||||
}
|
||||
|
||||
export namespace CodeInterpreter {
|
||||
/**
|
||||
* Text output from the Code Interpreter tool call as part of a run step.
|
||||
*/
|
||||
export interface Logs {
|
||||
/**
|
||||
* The text output from the Code Interpreter tool call.
|
||||
*/
|
||||
logs: string;
|
||||
|
||||
/**
|
||||
* Always `logs`.
|
||||
*/
|
||||
type: 'logs';
|
||||
}
|
||||
|
||||
export interface Image {
|
||||
image: Image.Image;
|
||||
|
||||
/**
|
||||
* Always `image`.
|
||||
*/
|
||||
type: 'image';
|
||||
}
|
||||
|
||||
export namespace Image {
|
||||
export interface Image {
|
||||
/**
|
||||
* The [file](https://platform.openai.com/docs/api-reference/files) ID of the
|
||||
* image.
|
||||
*/
|
||||
file_id: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the Code Interpreter tool call the run step was involved in.
|
||||
*/
|
||||
export interface CodeInterpreterToolCallDelta {
|
||||
/**
|
||||
* The index of the tool call in the tool calls array.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* The type of tool call. This is always going to be `code_interpreter` for this
|
||||
* type of tool call.
|
||||
*/
|
||||
type: 'code_interpreter';
|
||||
|
||||
/**
|
||||
* The ID of the tool call.
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* The Code Interpreter tool call definition.
|
||||
*/
|
||||
code_interpreter?: CodeInterpreterToolCallDelta.CodeInterpreter;
|
||||
}
|
||||
|
||||
export namespace CodeInterpreterToolCallDelta {
|
||||
/**
|
||||
* The Code Interpreter tool call definition.
|
||||
*/
|
||||
export interface CodeInterpreter {
|
||||
/**
|
||||
* The input to the Code Interpreter tool call.
|
||||
*/
|
||||
input?: string;
|
||||
|
||||
/**
|
||||
* The outputs from the Code Interpreter tool call. Code Interpreter can output one
|
||||
* or more items, including text (`logs`) or images (`image`). Each of these are
|
||||
* represented by a different object type.
|
||||
*/
|
||||
outputs?: Array<StepsAPI.CodeInterpreterLogs | StepsAPI.CodeInterpreterOutputImage>;
|
||||
}
|
||||
}
|
||||
|
||||
export interface FileSearchToolCall {
|
||||
/**
|
||||
* The ID of the tool call object.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* For now, this is always going to be an empty object.
|
||||
*/
|
||||
file_search: FileSearchToolCall.FileSearch;
|
||||
|
||||
/**
|
||||
* The type of tool call. This is always going to be `file_search` for this type of
|
||||
* tool call.
|
||||
*/
|
||||
type: 'file_search';
|
||||
}
|
||||
|
||||
export namespace FileSearchToolCall {
|
||||
/**
|
||||
* For now, this is always going to be an empty object.
|
||||
*/
|
||||
export interface FileSearch {
|
||||
/**
|
||||
* The ranking options for the file search.
|
||||
*/
|
||||
ranking_options?: FileSearch.RankingOptions;
|
||||
|
||||
/**
|
||||
* The results of the file search.
|
||||
*/
|
||||
results?: Array<FileSearch.Result>;
|
||||
}
|
||||
|
||||
export namespace FileSearch {
|
||||
/**
|
||||
* The ranking options for the file search.
|
||||
*/
|
||||
export interface RankingOptions {
|
||||
/**
|
||||
* The ranker used for the file search.
|
||||
*/
|
||||
ranker: 'default_2024_08_21';
|
||||
|
||||
/**
|
||||
* The score threshold for the file search. All values must be a floating point
|
||||
* number between 0 and 1.
|
||||
*/
|
||||
score_threshold: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A result instance of the file search.
|
||||
*/
|
||||
export interface Result {
|
||||
/**
|
||||
* The ID of the file that result was found in.
|
||||
*/
|
||||
file_id: string;
|
||||
|
||||
/**
|
||||
* The name of the file that result was found in.
|
||||
*/
|
||||
file_name: string;
|
||||
|
||||
/**
|
||||
* The score of the result. All values must be a floating point number between 0
|
||||
* and 1.
|
||||
*/
|
||||
score: number;
|
||||
|
||||
/**
|
||||
* The content of the result that was found. The content is only included if
|
||||
* requested via the include query parameter.
|
||||
*/
|
||||
content?: Array<Result.Content>;
|
||||
}
|
||||
|
||||
export namespace Result {
|
||||
export interface Content {
|
||||
/**
|
||||
* The text content of the file.
|
||||
*/
|
||||
text?: string;
|
||||
|
||||
/**
|
||||
* The type of the content.
|
||||
*/
|
||||
type?: 'text';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface FileSearchToolCallDelta {
|
||||
/**
|
||||
* For now, this is always going to be an empty object.
|
||||
*/
|
||||
file_search: unknown;
|
||||
|
||||
/**
|
||||
* The index of the tool call in the tool calls array.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* The type of tool call. This is always going to be `file_search` for this type of
|
||||
* tool call.
|
||||
*/
|
||||
type: 'file_search';
|
||||
|
||||
/**
|
||||
* The ID of the tool call object.
|
||||
*/
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface FunctionToolCall {
|
||||
/**
|
||||
* The ID of the tool call object.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The definition of the function that was called.
|
||||
*/
|
||||
function: FunctionToolCall.Function;
|
||||
|
||||
/**
|
||||
* The type of tool call. This is always going to be `function` for this type of
|
||||
* tool call.
|
||||
*/
|
||||
type: 'function';
|
||||
}
|
||||
|
||||
export namespace FunctionToolCall {
|
||||
/**
|
||||
* The definition of the function that was called.
|
||||
*/
|
||||
export interface Function {
|
||||
/**
|
||||
* The arguments passed to the function.
|
||||
*/
|
||||
arguments: string;
|
||||
|
||||
/**
|
||||
* The name of the function.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The output of the function. This will be `null` if the outputs have not been
|
||||
* [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
|
||||
* yet.
|
||||
*/
|
||||
output: string | null;
|
||||
}
|
||||
}
|
||||
|
||||
export interface FunctionToolCallDelta {
|
||||
/**
|
||||
* The index of the tool call in the tool calls array.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* The type of tool call. This is always going to be `function` for this type of
|
||||
* tool call.
|
||||
*/
|
||||
type: 'function';
|
||||
|
||||
/**
|
||||
* The ID of the tool call object.
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* The definition of the function that was called.
|
||||
*/
|
||||
function?: FunctionToolCallDelta.Function;
|
||||
}
|
||||
|
||||
export namespace FunctionToolCallDelta {
|
||||
/**
|
||||
* The definition of the function that was called.
|
||||
*/
|
||||
export interface Function {
|
||||
/**
|
||||
* The arguments passed to the function.
|
||||
*/
|
||||
arguments?: string;
|
||||
|
||||
/**
|
||||
* The name of the function.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* The output of the function. This will be `null` if the outputs have not been
|
||||
* [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
|
||||
* yet.
|
||||
*/
|
||||
output?: string | null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the message creation by the run step.
|
||||
*/
|
||||
export interface MessageCreationStepDetails {
|
||||
message_creation: MessageCreationStepDetails.MessageCreation;
|
||||
|
||||
/**
|
||||
* Always `message_creation`.
|
||||
*/
|
||||
type: 'message_creation';
|
||||
}
|
||||
|
||||
export namespace MessageCreationStepDetails {
|
||||
export interface MessageCreation {
|
||||
/**
|
||||
* The ID of the message that was created by this run step.
|
||||
*/
|
||||
message_id: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a step in execution of a run.
|
||||
*/
|
||||
export interface RunStep {
|
||||
/**
|
||||
* The identifier of the run step, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The ID of the
|
||||
* [assistant](https://platform.openai.com/docs/api-reference/assistants)
|
||||
* associated with the run step.
|
||||
*/
|
||||
assistant_id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the run step was cancelled.
|
||||
*/
|
||||
cancelled_at: number | null;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the run step completed.
|
||||
*/
|
||||
completed_at: number | null;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the run step was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the run step expired. A step is
|
||||
* considered expired if the parent run is expired.
|
||||
*/
|
||||
expired_at: number | null;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the run step failed.
|
||||
*/
|
||||
failed_at: number | null;
|
||||
|
||||
/**
|
||||
* The last error associated with this run step. Will be `null` if there are no
|
||||
* errors.
|
||||
*/
|
||||
last_error: RunStep.LastError | null;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The object type, which is always `thread.run.step`.
|
||||
*/
|
||||
object: 'thread.run.step';
|
||||
|
||||
/**
|
||||
* The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that
|
||||
* this run step is a part of.
|
||||
*/
|
||||
run_id: string;
|
||||
|
||||
/**
|
||||
* The status of the run step, which can be either `in_progress`, `cancelled`,
|
||||
* `failed`, `completed`, or `expired`.
|
||||
*/
|
||||
status: 'in_progress' | 'cancelled' | 'failed' | 'completed' | 'expired';
|
||||
|
||||
/**
|
||||
* The details of the run step.
|
||||
*/
|
||||
step_details: MessageCreationStepDetails | ToolCallsStepDetails;
|
||||
|
||||
/**
|
||||
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
|
||||
* that was run.
|
||||
*/
|
||||
thread_id: string;
|
||||
|
||||
/**
|
||||
* The type of run step, which can be either `message_creation` or `tool_calls`.
|
||||
*/
|
||||
type: 'message_creation' | 'tool_calls';
|
||||
|
||||
/**
|
||||
* Usage statistics related to the run step. This value will be `null` while the
|
||||
* run step's status is `in_progress`.
|
||||
*/
|
||||
usage: RunStep.Usage | null;
|
||||
}
|
||||
|
||||
export namespace RunStep {
|
||||
/**
|
||||
* The last error associated with this run step. Will be `null` if there are no
|
||||
* errors.
|
||||
*/
|
||||
export interface LastError {
|
||||
/**
|
||||
* One of `server_error` or `rate_limit_exceeded`.
|
||||
*/
|
||||
code: 'server_error' | 'rate_limit_exceeded';
|
||||
|
||||
/**
|
||||
* A human-readable description of the error.
|
||||
*/
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Usage statistics related to the run step. This value will be `null` while the
|
||||
* run step's status is `in_progress`.
|
||||
*/
|
||||
export interface Usage {
|
||||
/**
|
||||
* Number of completion tokens used over the course of the run step.
|
||||
*/
|
||||
completion_tokens: number;
|
||||
|
||||
/**
|
||||
* Number of prompt tokens used over the course of the run step.
|
||||
*/
|
||||
prompt_tokens: number;
|
||||
|
||||
/**
|
||||
* Total number of tokens used (prompt + completion).
|
||||
*/
|
||||
total_tokens: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The delta containing the fields that have changed on the run step.
|
||||
*/
|
||||
export interface RunStepDelta {
|
||||
/**
|
||||
* The details of the run step.
|
||||
*/
|
||||
step_details?: RunStepDeltaMessageDelta | ToolCallDeltaObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a run step delta i.e. any changed fields on a run step during
|
||||
* streaming.
|
||||
*/
|
||||
export interface RunStepDeltaEvent {
|
||||
/**
|
||||
* The identifier of the run step, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The delta containing the fields that have changed on the run step.
|
||||
*/
|
||||
delta: RunStepDelta;
|
||||
|
||||
/**
|
||||
* The object type, which is always `thread.run.step.delta`.
|
||||
*/
|
||||
object: 'thread.run.step.delta';
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the message creation by the run step.
|
||||
*/
|
||||
export interface RunStepDeltaMessageDelta {
|
||||
/**
|
||||
* Always `message_creation`.
|
||||
*/
|
||||
type: 'message_creation';
|
||||
|
||||
message_creation?: RunStepDeltaMessageDelta.MessageCreation;
|
||||
}
|
||||
|
||||
export namespace RunStepDeltaMessageDelta {
|
||||
export interface MessageCreation {
|
||||
/**
|
||||
* The ID of the message that was created by this run step.
|
||||
*/
|
||||
message_id?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export type RunStepInclude = 'step_details.tool_calls[*].file_search.results[*].content';
|
||||
|
||||
/**
|
||||
* Details of the Code Interpreter tool call the run step was involved in.
|
||||
*/
|
||||
export type ToolCall = CodeInterpreterToolCall | FileSearchToolCall | FunctionToolCall;
|
||||
|
||||
/**
|
||||
* Details of the Code Interpreter tool call the run step was involved in.
|
||||
*/
|
||||
export type ToolCallDelta = CodeInterpreterToolCallDelta | FileSearchToolCallDelta | FunctionToolCallDelta;
|
||||
|
||||
/**
|
||||
* Details of the tool call.
|
||||
*/
|
||||
export interface ToolCallDeltaObject {
|
||||
/**
|
||||
* Always `tool_calls`.
|
||||
*/
|
||||
type: 'tool_calls';
|
||||
|
||||
/**
|
||||
* An array of tool calls the run step was involved in. These can be associated
|
||||
* with one of three types of tools: `code_interpreter`, `file_search`, or
|
||||
* `function`.
|
||||
*/
|
||||
tool_calls?: Array<ToolCallDelta>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the tool call.
|
||||
*/
|
||||
export interface ToolCallsStepDetails {
|
||||
/**
|
||||
* An array of tool calls the run step was involved in. These can be associated
|
||||
* with one of three types of tools: `code_interpreter`, `file_search`, or
|
||||
* `function`.
|
||||
*/
|
||||
tool_calls: Array<ToolCall>;
|
||||
|
||||
/**
|
||||
* Always `tool_calls`.
|
||||
*/
|
||||
type: 'tool_calls';
|
||||
}
|
||||
|
||||
export interface StepRetrieveParams {
|
||||
/**
|
||||
* A list of additional fields to include in the response. Currently the only
|
||||
* supported value is `step_details.tool_calls[*].file_search.results[*].content`
|
||||
* to fetch the file search result content.
|
||||
*
|
||||
* See the
|
||||
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
|
||||
* for more information.
|
||||
*/
|
||||
include?: Array<RunStepInclude>;
|
||||
}
|
||||
|
||||
export interface StepListParams extends CursorPageParams {
|
||||
/**
|
||||
* A cursor for use in pagination. `before` is an object ID that defines your place
|
||||
* in the list. For instance, if you make a list request and receive 100 objects,
|
||||
* starting with obj_foo, your subsequent call can include before=obj_foo in order
|
||||
* to fetch the previous page of the list.
|
||||
*/
|
||||
before?: string;
|
||||
|
||||
/**
|
||||
* A list of additional fields to include in the response. Currently the only
|
||||
* supported value is `step_details.tool_calls[*].file_search.results[*].content`
|
||||
* to fetch the file search result content.
|
||||
*
|
||||
* See the
|
||||
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
|
||||
* for more information.
|
||||
*/
|
||||
include?: Array<RunStepInclude>;
|
||||
|
||||
/**
|
||||
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
||||
* order and `desc` for descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
Steps.RunStepsPage = RunStepsPage;
|
||||
|
||||
export declare namespace Steps {
|
||||
export {
|
||||
type CodeInterpreterLogs as CodeInterpreterLogs,
|
||||
type CodeInterpreterOutputImage as CodeInterpreterOutputImage,
|
||||
type CodeInterpreterToolCall as CodeInterpreterToolCall,
|
||||
type CodeInterpreterToolCallDelta as CodeInterpreterToolCallDelta,
|
||||
type FileSearchToolCall as FileSearchToolCall,
|
||||
type FileSearchToolCallDelta as FileSearchToolCallDelta,
|
||||
type FunctionToolCall as FunctionToolCall,
|
||||
type FunctionToolCallDelta as FunctionToolCallDelta,
|
||||
type MessageCreationStepDetails as MessageCreationStepDetails,
|
||||
type RunStep as RunStep,
|
||||
type RunStepDelta as RunStepDelta,
|
||||
type RunStepDeltaEvent as RunStepDeltaEvent,
|
||||
type RunStepDeltaMessageDelta as RunStepDeltaMessageDelta,
|
||||
type RunStepInclude as RunStepInclude,
|
||||
type ToolCall as ToolCall,
|
||||
type ToolCallDelta as ToolCallDelta,
|
||||
type ToolCallDeltaObject as ToolCallDeltaObject,
|
||||
type ToolCallsStepDetails as ToolCallsStepDetails,
|
||||
RunStepsPage as RunStepsPage,
|
||||
type StepRetrieveParams as StepRetrieveParams,
|
||||
type StepListParams as StepListParams,
|
||||
};
|
||||
}
|
||||
+1734
File diff suppressed because it is too large
Load Diff
+109
@@ -0,0 +1,109 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as Shared from '../shared';
|
||||
import * as CompletionsAPI from './completions/completions';
|
||||
import {
|
||||
ChatCompletion,
|
||||
ChatCompletionAssistantMessageParam,
|
||||
ChatCompletionAudio,
|
||||
ChatCompletionAudioParam,
|
||||
ChatCompletionChunk,
|
||||
ChatCompletionContentPart,
|
||||
ChatCompletionContentPartImage,
|
||||
ChatCompletionContentPartInputAudio,
|
||||
ChatCompletionContentPartRefusal,
|
||||
ChatCompletionContentPartText,
|
||||
ChatCompletionCreateParams,
|
||||
ChatCompletionCreateParamsNonStreaming,
|
||||
ChatCompletionCreateParamsStreaming,
|
||||
ChatCompletionDeleted,
|
||||
ChatCompletionDeveloperMessageParam,
|
||||
ChatCompletionFunctionCallOption,
|
||||
ChatCompletionFunctionMessageParam,
|
||||
ChatCompletionListParams,
|
||||
ChatCompletionMessage,
|
||||
ChatCompletionMessageParam,
|
||||
ChatCompletionMessageToolCall,
|
||||
ChatCompletionModality,
|
||||
ChatCompletionNamedToolChoice,
|
||||
ChatCompletionPredictionContent,
|
||||
ChatCompletionReasoningEffort,
|
||||
ChatCompletionRole,
|
||||
ChatCompletionStoreMessage,
|
||||
ChatCompletionStreamOptions,
|
||||
ChatCompletionSystemMessageParam,
|
||||
ChatCompletionTokenLogprob,
|
||||
ChatCompletionTool,
|
||||
ChatCompletionToolChoiceOption,
|
||||
ChatCompletionToolMessageParam,
|
||||
ChatCompletionUpdateParams,
|
||||
ChatCompletionUserMessageParam,
|
||||
ChatCompletionsPage,
|
||||
CompletionCreateParams,
|
||||
CompletionCreateParamsNonStreaming,
|
||||
CompletionCreateParamsStreaming,
|
||||
CompletionListParams,
|
||||
CompletionUpdateParams,
|
||||
Completions,
|
||||
CreateChatCompletionRequestMessage,
|
||||
} from './completions/completions';
|
||||
|
||||
export class Chat extends APIResource {
|
||||
completions: CompletionsAPI.Completions = new CompletionsAPI.Completions(this._client);
|
||||
}
|
||||
|
||||
export type ChatModel = Shared.ChatModel;
|
||||
|
||||
Chat.Completions = Completions;
|
||||
Chat.ChatCompletionsPage = ChatCompletionsPage;
|
||||
|
||||
export declare namespace Chat {
|
||||
export { type ChatModel as ChatModel };
|
||||
|
||||
export {
|
||||
Completions as Completions,
|
||||
type ChatCompletion as ChatCompletion,
|
||||
type ChatCompletionAssistantMessageParam as ChatCompletionAssistantMessageParam,
|
||||
type ChatCompletionAudio as ChatCompletionAudio,
|
||||
type ChatCompletionAudioParam as ChatCompletionAudioParam,
|
||||
type ChatCompletionChunk as ChatCompletionChunk,
|
||||
type ChatCompletionContentPart as ChatCompletionContentPart,
|
||||
type ChatCompletionContentPartImage as ChatCompletionContentPartImage,
|
||||
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
|
||||
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
|
||||
type ChatCompletionContentPartText as ChatCompletionContentPartText,
|
||||
type ChatCompletionDeleted as ChatCompletionDeleted,
|
||||
type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
|
||||
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
|
||||
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
|
||||
type ChatCompletionMessage as ChatCompletionMessage,
|
||||
type ChatCompletionMessageParam as ChatCompletionMessageParam,
|
||||
type ChatCompletionMessageToolCall as ChatCompletionMessageToolCall,
|
||||
type ChatCompletionModality as ChatCompletionModality,
|
||||
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
|
||||
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
|
||||
type ChatCompletionRole as ChatCompletionRole,
|
||||
type ChatCompletionStoreMessage as ChatCompletionStoreMessage,
|
||||
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
|
||||
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
|
||||
type ChatCompletionTokenLogprob as ChatCompletionTokenLogprob,
|
||||
type ChatCompletionTool as ChatCompletionTool,
|
||||
type ChatCompletionToolChoiceOption as ChatCompletionToolChoiceOption,
|
||||
type ChatCompletionToolMessageParam as ChatCompletionToolMessageParam,
|
||||
type ChatCompletionUserMessageParam as ChatCompletionUserMessageParam,
|
||||
type CreateChatCompletionRequestMessage as CreateChatCompletionRequestMessage,
|
||||
type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
|
||||
ChatCompletionsPage as ChatCompletionsPage,
|
||||
type ChatCompletionCreateParams as ChatCompletionCreateParams,
|
||||
type CompletionCreateParams as CompletionCreateParams,
|
||||
type ChatCompletionCreateParamsNonStreaming as ChatCompletionCreateParamsNonStreaming,
|
||||
type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
|
||||
type ChatCompletionCreateParamsStreaming as ChatCompletionCreateParamsStreaming,
|
||||
type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
|
||||
type ChatCompletionUpdateParams as ChatCompletionUpdateParams,
|
||||
type CompletionUpdateParams as CompletionUpdateParams,
|
||||
type ChatCompletionListParams as ChatCompletionListParams,
|
||||
type CompletionListParams as CompletionListParams,
|
||||
};
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './completions/completions';
|
||||
+1704
File diff suppressed because it is too large
Load Diff
+48
@@ -0,0 +1,48 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
ChatCompletionStoreMessagesPage,
|
||||
ChatCompletionsPage,
|
||||
Completions,
|
||||
type ChatCompletion,
|
||||
type ChatCompletionAssistantMessageParam,
|
||||
type ChatCompletionAudio,
|
||||
type ChatCompletionAudioParam,
|
||||
type ChatCompletionChunk,
|
||||
type ChatCompletionContentPart,
|
||||
type ChatCompletionContentPartImage,
|
||||
type ChatCompletionContentPartInputAudio,
|
||||
type ChatCompletionContentPartRefusal,
|
||||
type ChatCompletionContentPartText,
|
||||
type ChatCompletionDeleted,
|
||||
type ChatCompletionDeveloperMessageParam,
|
||||
type ChatCompletionFunctionCallOption,
|
||||
type ChatCompletionFunctionMessageParam,
|
||||
type ChatCompletionMessage,
|
||||
type ChatCompletionMessageParam,
|
||||
type ChatCompletionMessageToolCall,
|
||||
type ChatCompletionModality,
|
||||
type ChatCompletionNamedToolChoice,
|
||||
type ChatCompletionPredictionContent,
|
||||
type ChatCompletionRole,
|
||||
type ChatCompletionStoreMessage,
|
||||
type ChatCompletionStreamOptions,
|
||||
type ChatCompletionSystemMessageParam,
|
||||
type ChatCompletionTokenLogprob,
|
||||
type ChatCompletionTool,
|
||||
type ChatCompletionToolChoiceOption,
|
||||
type ChatCompletionToolMessageParam,
|
||||
type ChatCompletionUserMessageParam,
|
||||
type CreateChatCompletionRequestMessage,
|
||||
type ChatCompletionCreateParams,
|
||||
type CompletionCreateParams,
|
||||
type ChatCompletionCreateParamsNonStreaming,
|
||||
type CompletionCreateParamsNonStreaming,
|
||||
type ChatCompletionCreateParamsStreaming,
|
||||
type CompletionCreateParamsStreaming,
|
||||
type ChatCompletionUpdateParams,
|
||||
type CompletionUpdateParams,
|
||||
type ChatCompletionListParams,
|
||||
type CompletionListParams,
|
||||
} from './completions';
|
||||
export { Messages, type MessageListParams } from './messages';
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import { isRequestOptions } from '../../../core';
|
||||
import * as Core from '../../../core';
|
||||
import * as CompletionsAPI from './completions';
|
||||
import { ChatCompletionStoreMessagesPage } from './completions';
|
||||
import { type CursorPageParams } from '../../../pagination';
|
||||
|
||||
export class Messages extends APIResource {
|
||||
/**
|
||||
* Get the messages in a stored chat completion. Only Chat Completions that have
|
||||
* been created with the `store` parameter set to `true` will be returned.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Automatically fetches more pages as needed.
|
||||
* for await (const chatCompletionStoreMessage of client.chat.completions.messages.list(
|
||||
* 'completion_id',
|
||||
* )) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
list(
|
||||
completionId: string,
|
||||
query?: MessageListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ChatCompletionStoreMessagesPage, CompletionsAPI.ChatCompletionStoreMessage>;
|
||||
list(
|
||||
completionId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ChatCompletionStoreMessagesPage, CompletionsAPI.ChatCompletionStoreMessage>;
|
||||
list(
|
||||
completionId: string,
|
||||
query: MessageListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ChatCompletionStoreMessagesPage, CompletionsAPI.ChatCompletionStoreMessage> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(completionId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(
|
||||
`/chat/completions/${completionId}/messages`,
|
||||
ChatCompletionStoreMessagesPage,
|
||||
{ query, ...options },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export interface MessageListParams extends CursorPageParams {
|
||||
/**
|
||||
* Sort order for messages by timestamp. Use `asc` for ascending order or `desc`
|
||||
* for descending order. Defaults to `asc`.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export declare namespace Messages {
|
||||
export { type MessageListParams as MessageListParams };
|
||||
}
|
||||
|
||||
export { ChatCompletionStoreMessagesPage };
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Chat } from './chat';
|
||||
export {
|
||||
ChatCompletionStoreMessagesPage,
|
||||
ChatCompletionsPage,
|
||||
Completions,
|
||||
type ChatCompletion,
|
||||
type ChatCompletionAssistantMessageParam,
|
||||
type ChatCompletionAudio,
|
||||
type ChatCompletionAudioParam,
|
||||
type ChatCompletionChunk,
|
||||
type ChatCompletionContentPart,
|
||||
type ChatCompletionContentPartImage,
|
||||
type ChatCompletionContentPartInputAudio,
|
||||
type ChatCompletionContentPartRefusal,
|
||||
type ChatCompletionContentPartText,
|
||||
type ChatCompletionDeleted,
|
||||
type ChatCompletionDeveloperMessageParam,
|
||||
type ChatCompletionFunctionCallOption,
|
||||
type ChatCompletionFunctionMessageParam,
|
||||
type ChatCompletionMessage,
|
||||
type ChatCompletionMessageParam,
|
||||
type ChatCompletionMessageToolCall,
|
||||
type ChatCompletionModality,
|
||||
type ChatCompletionNamedToolChoice,
|
||||
type ChatCompletionPredictionContent,
|
||||
type ChatCompletionRole,
|
||||
type ChatCompletionStoreMessage,
|
||||
type ChatCompletionStreamOptions,
|
||||
type ChatCompletionSystemMessageParam,
|
||||
type ChatCompletionTokenLogprob,
|
||||
type ChatCompletionTool,
|
||||
type ChatCompletionToolChoiceOption,
|
||||
type ChatCompletionToolMessageParam,
|
||||
type ChatCompletionUserMessageParam,
|
||||
type CreateChatCompletionRequestMessage,
|
||||
type ChatCompletionCreateParams,
|
||||
type CompletionCreateParams,
|
||||
type ChatCompletionCreateParamsNonStreaming,
|
||||
type CompletionCreateParamsNonStreaming,
|
||||
type ChatCompletionCreateParamsStreaming,
|
||||
type CompletionCreateParamsStreaming,
|
||||
type ChatCompletionUpdateParams,
|
||||
type CompletionUpdateParams,
|
||||
type ChatCompletionListParams,
|
||||
type CompletionListParams,
|
||||
} from './completions/index';
|
||||
+397
@@ -0,0 +1,397 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../resource';
|
||||
import { APIPromise } from '../core';
|
||||
import * as Core from '../core';
|
||||
import * as CompletionsAPI from './completions';
|
||||
import * as CompletionsCompletionsAPI from './chat/completions/completions';
|
||||
import { Stream } from '../streaming';
|
||||
|
||||
export class Completions extends APIResource {
|
||||
/**
|
||||
* Creates a completion for the provided prompt and parameters.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const completion = await client.completions.create({
|
||||
* model: 'string',
|
||||
* prompt: 'This is a test.',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
create(body: CompletionCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Completion>;
|
||||
create(
|
||||
body: CompletionCreateParamsStreaming,
|
||||
options?: Core.RequestOptions,
|
||||
): APIPromise<Stream<Completion>>;
|
||||
create(
|
||||
body: CompletionCreateParamsBase,
|
||||
options?: Core.RequestOptions,
|
||||
): APIPromise<Stream<Completion> | Completion>;
|
||||
create(
|
||||
body: CompletionCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): APIPromise<Completion> | APIPromise<Stream<Completion>> {
|
||||
return this._client.post('/completions', { body, ...options, stream: body.stream ?? false }) as
|
||||
| APIPromise<Completion>
|
||||
| APIPromise<Stream<Completion>>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a completion response from the API. Note: both the streamed and
|
||||
* non-streamed response objects share the same shape (unlike the chat endpoint).
|
||||
*/
|
||||
export interface Completion {
|
||||
/**
|
||||
* A unique identifier for the completion.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The list of completion choices the model generated for the input prompt.
|
||||
*/
|
||||
choices: Array<CompletionChoice>;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) of when the completion was created.
|
||||
*/
|
||||
created: number;
|
||||
|
||||
/**
|
||||
* The model used for completion.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always "text_completion"
|
||||
*/
|
||||
object: 'text_completion';
|
||||
|
||||
/**
|
||||
* This fingerprint represents the backend configuration that the model runs with.
|
||||
*
|
||||
* Can be used in conjunction with the `seed` request parameter to understand when
|
||||
* backend changes have been made that might impact determinism.
|
||||
*/
|
||||
system_fingerprint?: string;
|
||||
|
||||
/**
|
||||
* Usage statistics for the completion request.
|
||||
*/
|
||||
usage?: CompletionUsage;
|
||||
}
|
||||
|
||||
export interface CompletionChoice {
|
||||
/**
|
||||
* The reason the model stopped generating tokens. This will be `stop` if the model
|
||||
* hit a natural stop point or a provided stop sequence, `length` if the maximum
|
||||
* number of tokens specified in the request was reached, or `content_filter` if
|
||||
* content was omitted due to a flag from our content filters.
|
||||
*/
|
||||
finish_reason: 'stop' | 'length' | 'content_filter';
|
||||
|
||||
index: number;
|
||||
|
||||
logprobs: CompletionChoice.Logprobs | null;
|
||||
|
||||
text: string;
|
||||
}
|
||||
|
||||
export namespace CompletionChoice {
|
||||
export interface Logprobs {
|
||||
text_offset?: Array<number>;
|
||||
|
||||
token_logprobs?: Array<number>;
|
||||
|
||||
tokens?: Array<string>;
|
||||
|
||||
top_logprobs?: Array<Record<string, number>>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Usage statistics for the completion request.
|
||||
*/
|
||||
export interface CompletionUsage {
|
||||
/**
|
||||
* Number of tokens in the generated completion.
|
||||
*/
|
||||
completion_tokens: number;
|
||||
|
||||
/**
|
||||
* Number of tokens in the prompt.
|
||||
*/
|
||||
prompt_tokens: number;
|
||||
|
||||
/**
|
||||
* Total number of tokens used in the request (prompt + completion).
|
||||
*/
|
||||
total_tokens: number;
|
||||
|
||||
/**
|
||||
* Breakdown of tokens used in a completion.
|
||||
*/
|
||||
completion_tokens_details?: CompletionUsage.CompletionTokensDetails;
|
||||
|
||||
/**
|
||||
* Breakdown of tokens used in the prompt.
|
||||
*/
|
||||
prompt_tokens_details?: CompletionUsage.PromptTokensDetails;
|
||||
}
|
||||
|
||||
export namespace CompletionUsage {
|
||||
/**
|
||||
* Breakdown of tokens used in a completion.
|
||||
*/
|
||||
export interface CompletionTokensDetails {
|
||||
/**
|
||||
* When using Predicted Outputs, the number of tokens in the prediction that
|
||||
* appeared in the completion.
|
||||
*/
|
||||
accepted_prediction_tokens?: number;
|
||||
|
||||
/**
|
||||
* Audio input tokens generated by the model.
|
||||
*/
|
||||
audio_tokens?: number;
|
||||
|
||||
/**
|
||||
* Tokens generated by the model for reasoning.
|
||||
*/
|
||||
reasoning_tokens?: number;
|
||||
|
||||
/**
|
||||
* When using Predicted Outputs, the number of tokens in the prediction that did
|
||||
* not appear in the completion. However, like reasoning tokens, these tokens are
|
||||
* still counted in the total completion tokens for purposes of billing, output,
|
||||
* and context window limits.
|
||||
*/
|
||||
rejected_prediction_tokens?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Breakdown of tokens used in the prompt.
|
||||
*/
|
||||
export interface PromptTokensDetails {
|
||||
/**
|
||||
* Audio input tokens present in the prompt.
|
||||
*/
|
||||
audio_tokens?: number;
|
||||
|
||||
/**
|
||||
* Cached tokens present in the prompt.
|
||||
*/
|
||||
cached_tokens?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export type CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming;
|
||||
|
||||
export interface CompletionCreateParamsBase {
|
||||
/**
|
||||
* ID of the model to use. You can use the
|
||||
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
|
||||
* see all of your available models, or see our
|
||||
* [Model overview](https://platform.openai.com/docs/models) for descriptions of
|
||||
* them.
|
||||
*/
|
||||
model: (string & {}) | 'gpt-3.5-turbo-instruct' | 'davinci-002' | 'babbage-002';
|
||||
|
||||
/**
|
||||
* The prompt(s) to generate completions for, encoded as a string, array of
|
||||
* strings, array of tokens, or array of token arrays.
|
||||
*
|
||||
* Note that <|endoftext|> is the document separator that the model sees during
|
||||
* training, so if a prompt is not specified the model will generate as if from the
|
||||
* beginning of a new document.
|
||||
*/
|
||||
prompt: string | Array<string> | Array<number> | Array<Array<number>> | null;
|
||||
|
||||
/**
|
||||
* Generates `best_of` completions server-side and returns the "best" (the one with
|
||||
* the highest log probability per token). Results cannot be streamed.
|
||||
*
|
||||
* When used with `n`, `best_of` controls the number of candidate completions and
|
||||
* `n` specifies how many to return – `best_of` must be greater than `n`.
|
||||
*
|
||||
* **Note:** Because this parameter generates many completions, it can quickly
|
||||
* consume your token quota. Use carefully and ensure that you have reasonable
|
||||
* settings for `max_tokens` and `stop`.
|
||||
*/
|
||||
best_of?: number | null;
|
||||
|
||||
/**
|
||||
* Echo back the prompt in addition to the completion
|
||||
*/
|
||||
echo?: boolean | null;
|
||||
|
||||
/**
|
||||
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their
|
||||
* existing frequency in the text so far, decreasing the model's likelihood to
|
||||
* repeat the same line verbatim.
|
||||
*
|
||||
* [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
|
||||
*/
|
||||
frequency_penalty?: number | null;
|
||||
|
||||
/**
|
||||
* Modify the likelihood of specified tokens appearing in the completion.
|
||||
*
|
||||
* Accepts a JSON object that maps tokens (specified by their token ID in the GPT
|
||||
* tokenizer) to an associated bias value from -100 to 100. You can use this
|
||||
* [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs.
|
||||
* Mathematically, the bias is added to the logits generated by the model prior to
|
||||
* sampling. The exact effect will vary per model, but values between -1 and 1
|
||||
* should decrease or increase likelihood of selection; values like -100 or 100
|
||||
* should result in a ban or exclusive selection of the relevant token.
|
||||
*
|
||||
* As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token
|
||||
* from being generated.
|
||||
*/
|
||||
logit_bias?: Record<string, number> | null;
|
||||
|
||||
/**
|
||||
* Include the log probabilities on the `logprobs` most likely output tokens, as
|
||||
* well the chosen tokens. For example, if `logprobs` is 5, the API will return a
|
||||
* list of the 5 most likely tokens. The API will always return the `logprob` of
|
||||
* the sampled token, so there may be up to `logprobs+1` elements in the response.
|
||||
*
|
||||
* The maximum value for `logprobs` is 5.
|
||||
*/
|
||||
logprobs?: number | null;
|
||||
|
||||
/**
|
||||
* The maximum number of [tokens](/tokenizer) that can be generated in the
|
||||
* completion.
|
||||
*
|
||||
* The token count of your prompt plus `max_tokens` cannot exceed the model's
|
||||
* context length.
|
||||
* [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
|
||||
* for counting tokens.
|
||||
*/
|
||||
max_tokens?: number | null;
|
||||
|
||||
/**
|
||||
* How many completions to generate for each prompt.
|
||||
*
|
||||
* **Note:** Because this parameter generates many completions, it can quickly
|
||||
* consume your token quota. Use carefully and ensure that you have reasonable
|
||||
* settings for `max_tokens` and `stop`.
|
||||
*/
|
||||
n?: number | null;
|
||||
|
||||
/**
|
||||
* Number between -2.0 and 2.0. Positive values penalize new tokens based on
|
||||
* whether they appear in the text so far, increasing the model's likelihood to
|
||||
* talk about new topics.
|
||||
*
|
||||
* [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
|
||||
*/
|
||||
presence_penalty?: number | null;
|
||||
|
||||
/**
|
||||
* If specified, our system will make a best effort to sample deterministically,
|
||||
* such that repeated requests with the same `seed` and parameters should return
|
||||
* the same result.
|
||||
*
|
||||
* Determinism is not guaranteed, and you should refer to the `system_fingerprint`
|
||||
* response parameter to monitor changes in the backend.
|
||||
*/
|
||||
seed?: number | null;
|
||||
|
||||
/**
|
||||
* Not supported with latest reasoning models `o3` and `o4-mini`.
|
||||
*
|
||||
* Up to 4 sequences where the API will stop generating further tokens. The
|
||||
* returned text will not contain the stop sequence.
|
||||
*/
|
||||
stop?: string | null | Array<string>;
|
||||
|
||||
/**
|
||||
* Whether to stream back partial progress. If set, tokens will be sent as
|
||||
* data-only
|
||||
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
|
||||
* as they become available, with the stream terminated by a `data: [DONE]`
|
||||
* message.
|
||||
* [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).
|
||||
*/
|
||||
stream?: boolean | null;
|
||||
|
||||
/**
|
||||
* Options for streaming response. Only set this when you set `stream: true`.
|
||||
*/
|
||||
stream_options?: CompletionsCompletionsAPI.ChatCompletionStreamOptions | null;
|
||||
|
||||
/**
|
||||
* The suffix that comes after a completion of inserted text.
|
||||
*
|
||||
* This parameter is only supported for `gpt-3.5-turbo-instruct`.
|
||||
*/
|
||||
suffix?: string | null;
|
||||
|
||||
/**
|
||||
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
|
||||
* make the output more random, while lower values like 0.2 will make it more
|
||||
* focused and deterministic.
|
||||
*
|
||||
* We generally recommend altering this or `top_p` but not both.
|
||||
*/
|
||||
temperature?: number | null;
|
||||
|
||||
/**
|
||||
* An alternative to sampling with temperature, called nucleus sampling, where the
|
||||
* model considers the results of the tokens with top_p probability mass. So 0.1
|
||||
* means only the tokens comprising the top 10% probability mass are considered.
|
||||
*
|
||||
* We generally recommend altering this or `temperature` but not both.
|
||||
*/
|
||||
top_p?: number | null;
|
||||
|
||||
/**
|
||||
* A unique identifier representing your end-user, which can help OpenAI to monitor
|
||||
* and detect abuse.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
|
||||
*/
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export namespace CompletionCreateParams {
|
||||
export type CompletionCreateParamsNonStreaming = CompletionsAPI.CompletionCreateParamsNonStreaming;
|
||||
export type CompletionCreateParamsStreaming = CompletionsAPI.CompletionCreateParamsStreaming;
|
||||
}
|
||||
|
||||
export interface CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase {
|
||||
/**
|
||||
* Whether to stream back partial progress. If set, tokens will be sent as
|
||||
* data-only
|
||||
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
|
||||
* as they become available, with the stream terminated by a `data: [DONE]`
|
||||
* message.
|
||||
* [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).
|
||||
*/
|
||||
stream?: false | null;
|
||||
}
|
||||
|
||||
export interface CompletionCreateParamsStreaming extends CompletionCreateParamsBase {
|
||||
/**
|
||||
* Whether to stream back partial progress. If set, tokens will be sent as
|
||||
* data-only
|
||||
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
|
||||
* as they become available, with the stream terminated by a `data: [DONE]`
|
||||
* message.
|
||||
* [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).
|
||||
*/
|
||||
stream: true;
|
||||
}
|
||||
|
||||
export declare namespace Completions {
|
||||
export {
|
||||
type Completion as Completion,
|
||||
type CompletionChoice as CompletionChoice,
|
||||
type CompletionUsage as CompletionUsage,
|
||||
type CompletionCreateParams as CompletionCreateParams,
|
||||
type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
|
||||
type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
|
||||
};
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './containers/index';
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import { isRequestOptions } from '../../core';
|
||||
import * as Core from '../../core';
|
||||
import * as FilesAPI from './files/files';
|
||||
import {
|
||||
FileCreateParams,
|
||||
FileCreateResponse,
|
||||
FileListParams,
|
||||
FileListResponse,
|
||||
FileListResponsesPage,
|
||||
FileRetrieveResponse,
|
||||
Files,
|
||||
} from './files/files';
|
||||
import { CursorPage, type CursorPageParams } from '../../pagination';
|
||||
|
||||
export class Containers extends APIResource {
|
||||
files: FilesAPI.Files = new FilesAPI.Files(this._client);
|
||||
|
||||
/**
|
||||
* Create Container
|
||||
*/
|
||||
create(
|
||||
body: ContainerCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<ContainerCreateResponse> {
|
||||
return this._client.post('/containers', { body, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Container
|
||||
*/
|
||||
retrieve(containerId: string, options?: Core.RequestOptions): Core.APIPromise<ContainerRetrieveResponse> {
|
||||
return this._client.get(`/containers/${containerId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* List Containers
|
||||
*/
|
||||
list(
|
||||
query?: ContainerListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ContainerListResponsesPage, ContainerListResponse>;
|
||||
list(options?: Core.RequestOptions): Core.PagePromise<ContainerListResponsesPage, ContainerListResponse>;
|
||||
list(
|
||||
query: ContainerListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ContainerListResponsesPage, ContainerListResponse> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list({}, query);
|
||||
}
|
||||
return this._client.getAPIList('/containers', ContainerListResponsesPage, { query, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Container
|
||||
*/
|
||||
del(containerId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
|
||||
return this._client.delete(`/containers/${containerId}`, {
|
||||
...options,
|
||||
headers: { Accept: '*/*', ...options?.headers },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class ContainerListResponsesPage extends CursorPage<ContainerListResponse> {}
|
||||
|
||||
export interface ContainerCreateResponse {
|
||||
/**
|
||||
* Unique identifier for the container.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (in seconds) when the container was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Name of the container.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The type of this object.
|
||||
*/
|
||||
object: string;
|
||||
|
||||
/**
|
||||
* Status of the container (e.g., active, deleted).
|
||||
*/
|
||||
status: string;
|
||||
|
||||
/**
|
||||
* The container will expire after this time period. The anchor is the reference
|
||||
* point for the expiration. The minutes is the number of minutes after the anchor
|
||||
* before the container expires.
|
||||
*/
|
||||
expires_after?: ContainerCreateResponse.ExpiresAfter;
|
||||
}
|
||||
|
||||
export namespace ContainerCreateResponse {
|
||||
/**
|
||||
* The container will expire after this time period. The anchor is the reference
|
||||
* point for the expiration. The minutes is the number of minutes after the anchor
|
||||
* before the container expires.
|
||||
*/
|
||||
export interface ExpiresAfter {
|
||||
/**
|
||||
* The reference point for the expiration.
|
||||
*/
|
||||
anchor?: 'last_active_at';
|
||||
|
||||
/**
|
||||
* The number of minutes after the anchor before the container expires.
|
||||
*/
|
||||
minutes?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ContainerRetrieveResponse {
|
||||
/**
|
||||
* Unique identifier for the container.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (in seconds) when the container was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Name of the container.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The type of this object.
|
||||
*/
|
||||
object: string;
|
||||
|
||||
/**
|
||||
* Status of the container (e.g., active, deleted).
|
||||
*/
|
||||
status: string;
|
||||
|
||||
/**
|
||||
* The container will expire after this time period. The anchor is the reference
|
||||
* point for the expiration. The minutes is the number of minutes after the anchor
|
||||
* before the container expires.
|
||||
*/
|
||||
expires_after?: ContainerRetrieveResponse.ExpiresAfter;
|
||||
}
|
||||
|
||||
export namespace ContainerRetrieveResponse {
|
||||
/**
|
||||
* The container will expire after this time period. The anchor is the reference
|
||||
* point for the expiration. The minutes is the number of minutes after the anchor
|
||||
* before the container expires.
|
||||
*/
|
||||
export interface ExpiresAfter {
|
||||
/**
|
||||
* The reference point for the expiration.
|
||||
*/
|
||||
anchor?: 'last_active_at';
|
||||
|
||||
/**
|
||||
* The number of minutes after the anchor before the container expires.
|
||||
*/
|
||||
minutes?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ContainerListResponse {
|
||||
/**
|
||||
* Unique identifier for the container.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (in seconds) when the container was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Name of the container.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The type of this object.
|
||||
*/
|
||||
object: string;
|
||||
|
||||
/**
|
||||
* Status of the container (e.g., active, deleted).
|
||||
*/
|
||||
status: string;
|
||||
|
||||
/**
|
||||
* The container will expire after this time period. The anchor is the reference
|
||||
* point for the expiration. The minutes is the number of minutes after the anchor
|
||||
* before the container expires.
|
||||
*/
|
||||
expires_after?: ContainerListResponse.ExpiresAfter;
|
||||
}
|
||||
|
||||
export namespace ContainerListResponse {
|
||||
/**
|
||||
* The container will expire after this time period. The anchor is the reference
|
||||
* point for the expiration. The minutes is the number of minutes after the anchor
|
||||
* before the container expires.
|
||||
*/
|
||||
export interface ExpiresAfter {
|
||||
/**
|
||||
* The reference point for the expiration.
|
||||
*/
|
||||
anchor?: 'last_active_at';
|
||||
|
||||
/**
|
||||
* The number of minutes after the anchor before the container expires.
|
||||
*/
|
||||
minutes?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ContainerCreateParams {
|
||||
/**
|
||||
* Name of the container to create.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Container expiration time in seconds relative to the 'anchor' time.
|
||||
*/
|
||||
expires_after?: ContainerCreateParams.ExpiresAfter;
|
||||
|
||||
/**
|
||||
* IDs of files to copy to the container.
|
||||
*/
|
||||
file_ids?: Array<string>;
|
||||
}
|
||||
|
||||
export namespace ContainerCreateParams {
|
||||
/**
|
||||
* Container expiration time in seconds relative to the 'anchor' time.
|
||||
*/
|
||||
export interface ExpiresAfter {
|
||||
/**
|
||||
* Time anchor for the expiration time. Currently only 'last_active_at' is
|
||||
* supported.
|
||||
*/
|
||||
anchor: 'last_active_at';
|
||||
|
||||
minutes: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ContainerListParams extends CursorPageParams {
|
||||
/**
|
||||
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
||||
* order and `desc` for descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
Containers.ContainerListResponsesPage = ContainerListResponsesPage;
|
||||
Containers.Files = Files;
|
||||
Containers.FileListResponsesPage = FileListResponsesPage;
|
||||
|
||||
export declare namespace Containers {
|
||||
export {
|
||||
type ContainerCreateResponse as ContainerCreateResponse,
|
||||
type ContainerRetrieveResponse as ContainerRetrieveResponse,
|
||||
type ContainerListResponse as ContainerListResponse,
|
||||
ContainerListResponsesPage as ContainerListResponsesPage,
|
||||
type ContainerCreateParams as ContainerCreateParams,
|
||||
type ContainerListParams as ContainerListParams,
|
||||
};
|
||||
|
||||
export {
|
||||
Files as Files,
|
||||
type FileCreateResponse as FileCreateResponse,
|
||||
type FileRetrieveResponse as FileRetrieveResponse,
|
||||
type FileListResponse as FileListResponse,
|
||||
FileListResponsesPage as FileListResponsesPage,
|
||||
type FileCreateParams as FileCreateParams,
|
||||
type FileListParams as FileListParams,
|
||||
};
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './files/index';
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import * as Core from '../../../core';
|
||||
import { type Response } from '../../../_shims/index';
|
||||
|
||||
export class Content extends APIResource {
|
||||
/**
|
||||
* Retrieve Container File Content
|
||||
*/
|
||||
retrieve(containerId: string, fileId: string, options?: Core.RequestOptions): Core.APIPromise<Response> {
|
||||
return this._client.get(`/containers/${containerId}/files/${fileId}/content`, {
|
||||
...options,
|
||||
headers: { Accept: 'application/binary', ...options?.headers },
|
||||
__binaryResponse: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import { isRequestOptions } from '../../../core';
|
||||
import * as Core from '../../../core';
|
||||
import * as ContentAPI from './content';
|
||||
import { Content } from './content';
|
||||
import { CursorPage, type CursorPageParams } from '../../../pagination';
|
||||
|
||||
export class Files extends APIResource {
|
||||
content: ContentAPI.Content = new ContentAPI.Content(this._client);
|
||||
|
||||
/**
|
||||
* Create a Container File
|
||||
*
|
||||
* You can send either a multipart/form-data request with the raw file content, or
|
||||
* a JSON request with a file ID.
|
||||
*/
|
||||
create(
|
||||
containerId: string,
|
||||
body: FileCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<FileCreateResponse> {
|
||||
return this._client.post(
|
||||
`/containers/${containerId}/files`,
|
||||
Core.multipartFormRequestOptions({ body, ...options }),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Container File
|
||||
*/
|
||||
retrieve(
|
||||
containerId: string,
|
||||
fileId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<FileRetrieveResponse> {
|
||||
return this._client.get(`/containers/${containerId}/files/${fileId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* List Container files
|
||||
*/
|
||||
list(
|
||||
containerId: string,
|
||||
query?: FileListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FileListResponsesPage, FileListResponse>;
|
||||
list(
|
||||
containerId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FileListResponsesPage, FileListResponse>;
|
||||
list(
|
||||
containerId: string,
|
||||
query: FileListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FileListResponsesPage, FileListResponse> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(containerId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(`/containers/${containerId}/files`, FileListResponsesPage, {
|
||||
query,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Container File
|
||||
*/
|
||||
del(containerId: string, fileId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
|
||||
return this._client.delete(`/containers/${containerId}/files/${fileId}`, {
|
||||
...options,
|
||||
headers: { Accept: '*/*', ...options?.headers },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class FileListResponsesPage extends CursorPage<FileListResponse> {}
|
||||
|
||||
export interface FileCreateResponse {
|
||||
/**
|
||||
* Unique identifier for the file.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Size of the file in bytes.
|
||||
*/
|
||||
bytes: number;
|
||||
|
||||
/**
|
||||
* The container this file belongs to.
|
||||
*/
|
||||
container_id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (in seconds) when the file was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The type of this object (`container.file`).
|
||||
*/
|
||||
object: 'container.file';
|
||||
|
||||
/**
|
||||
* Path of the file in the container.
|
||||
*/
|
||||
path: string;
|
||||
|
||||
/**
|
||||
* Source of the file (e.g., `user`, `assistant`).
|
||||
*/
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface FileRetrieveResponse {
|
||||
/**
|
||||
* Unique identifier for the file.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Size of the file in bytes.
|
||||
*/
|
||||
bytes: number;
|
||||
|
||||
/**
|
||||
* The container this file belongs to.
|
||||
*/
|
||||
container_id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (in seconds) when the file was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The type of this object (`container.file`).
|
||||
*/
|
||||
object: 'container.file';
|
||||
|
||||
/**
|
||||
* Path of the file in the container.
|
||||
*/
|
||||
path: string;
|
||||
|
||||
/**
|
||||
* Source of the file (e.g., `user`, `assistant`).
|
||||
*/
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface FileListResponse {
|
||||
/**
|
||||
* Unique identifier for the file.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Size of the file in bytes.
|
||||
*/
|
||||
bytes: number;
|
||||
|
||||
/**
|
||||
* The container this file belongs to.
|
||||
*/
|
||||
container_id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (in seconds) when the file was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The type of this object (`container.file`).
|
||||
*/
|
||||
object: 'container.file';
|
||||
|
||||
/**
|
||||
* Path of the file in the container.
|
||||
*/
|
||||
path: string;
|
||||
|
||||
/**
|
||||
* Source of the file (e.g., `user`, `assistant`).
|
||||
*/
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface FileCreateParams {
|
||||
/**
|
||||
* The File object (not file name) to be uploaded.
|
||||
*/
|
||||
file?: Core.Uploadable;
|
||||
|
||||
/**
|
||||
* Name of the file to create.
|
||||
*/
|
||||
file_id?: string;
|
||||
}
|
||||
|
||||
export interface FileListParams extends CursorPageParams {
|
||||
/**
|
||||
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
||||
* order and `desc` for descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
Files.FileListResponsesPage = FileListResponsesPage;
|
||||
Files.Content = Content;
|
||||
|
||||
export declare namespace Files {
|
||||
export {
|
||||
type FileCreateResponse as FileCreateResponse,
|
||||
type FileRetrieveResponse as FileRetrieveResponse,
|
||||
type FileListResponse as FileListResponse,
|
||||
FileListResponsesPage as FileListResponsesPage,
|
||||
type FileCreateParams as FileCreateParams,
|
||||
type FileListParams as FileListParams,
|
||||
};
|
||||
|
||||
export { Content as Content };
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Content } from './content';
|
||||
export {
|
||||
FileListResponsesPage,
|
||||
Files,
|
||||
type FileCreateResponse,
|
||||
type FileRetrieveResponse,
|
||||
type FileListResponse,
|
||||
type FileCreateParams,
|
||||
type FileListParams,
|
||||
} from './files';
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
ContainerListResponsesPage,
|
||||
Containers,
|
||||
type ContainerCreateResponse,
|
||||
type ContainerRetrieveResponse,
|
||||
type ContainerListResponse,
|
||||
type ContainerCreateParams,
|
||||
type ContainerListParams,
|
||||
} from './containers';
|
||||
export {
|
||||
FileListResponsesPage,
|
||||
Files,
|
||||
type FileCreateResponse,
|
||||
type FileRetrieveResponse,
|
||||
type FileListResponse,
|
||||
type FileCreateParams,
|
||||
type FileListParams,
|
||||
} from './files/index';
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../resource';
|
||||
import * as Core from '../core';
|
||||
|
||||
export class Embeddings extends APIResource {
|
||||
/**
|
||||
* Creates an embedding vector representing the input text.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const createEmbeddingResponse =
|
||||
* await client.embeddings.create({
|
||||
* input: 'The quick brown fox jumped over the lazy dog',
|
||||
* model: 'text-embedding-3-small',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
create(
|
||||
body: EmbeddingCreateParams,
|
||||
options?: Core.RequestOptions<EmbeddingCreateParams>,
|
||||
): Core.APIPromise<CreateEmbeddingResponse> {
|
||||
const hasUserProvidedEncodingFormat = !!body.encoding_format;
|
||||
// No encoding_format specified, defaulting to base64 for performance reasons
|
||||
// See https://github.com/openai/openai-node/pull/1312
|
||||
let encoding_format: EmbeddingCreateParams['encoding_format'] =
|
||||
hasUserProvidedEncodingFormat ? body.encoding_format : 'base64';
|
||||
|
||||
if (hasUserProvidedEncodingFormat) {
|
||||
Core.debug('Request', 'User defined encoding_format:', body.encoding_format);
|
||||
}
|
||||
|
||||
const response: Core.APIPromise<CreateEmbeddingResponse> = this._client.post('/embeddings', {
|
||||
body: {
|
||||
...body,
|
||||
encoding_format: encoding_format as EmbeddingCreateParams['encoding_format'],
|
||||
},
|
||||
...options,
|
||||
});
|
||||
|
||||
// if the user specified an encoding_format, return the response as-is
|
||||
if (hasUserProvidedEncodingFormat) {
|
||||
return response;
|
||||
}
|
||||
|
||||
// in this stage, we are sure the user did not specify an encoding_format
|
||||
// and we defaulted to base64 for performance reasons
|
||||
// we are sure then that the response is base64 encoded, let's decode it
|
||||
// the returned result will be a float32 array since this is OpenAI API's default encoding
|
||||
Core.debug('response', 'Decoding base64 embeddings to float32 array');
|
||||
|
||||
return (response as Core.APIPromise<CreateEmbeddingResponse>)._thenUnwrap((response) => {
|
||||
if (response && response.data) {
|
||||
response.data.forEach((embeddingBase64Obj) => {
|
||||
const embeddingBase64Str = embeddingBase64Obj.embedding as unknown as string;
|
||||
embeddingBase64Obj.embedding = Core.toFloat32Array(embeddingBase64Str);
|
||||
});
|
||||
}
|
||||
|
||||
return response;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface CreateEmbeddingResponse {
|
||||
/**
|
||||
* The list of embeddings generated by the model.
|
||||
*/
|
||||
data: Array<Embedding>;
|
||||
|
||||
/**
|
||||
* The name of the model used to generate the embedding.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always "list".
|
||||
*/
|
||||
object: 'list';
|
||||
|
||||
/**
|
||||
* The usage information for the request.
|
||||
*/
|
||||
usage: CreateEmbeddingResponse.Usage;
|
||||
}
|
||||
|
||||
export namespace CreateEmbeddingResponse {
|
||||
/**
|
||||
* The usage information for the request.
|
||||
*/
|
||||
export interface Usage {
|
||||
/**
|
||||
* The number of tokens used by the prompt.
|
||||
*/
|
||||
prompt_tokens: number;
|
||||
|
||||
/**
|
||||
* The total number of tokens used by the request.
|
||||
*/
|
||||
total_tokens: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an embedding vector returned by embedding endpoint.
|
||||
*/
|
||||
export interface Embedding {
|
||||
/**
|
||||
* The embedding vector, which is a list of floats. The length of vector depends on
|
||||
* the model as listed in the
|
||||
* [embedding guide](https://platform.openai.com/docs/guides/embeddings).
|
||||
*/
|
||||
embedding: Array<number>;
|
||||
|
||||
/**
|
||||
* The index of the embedding in the list of embeddings.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* The object type, which is always "embedding".
|
||||
*/
|
||||
object: 'embedding';
|
||||
}
|
||||
|
||||
export type EmbeddingModel = 'text-embedding-ada-002' | 'text-embedding-3-small' | 'text-embedding-3-large';
|
||||
|
||||
export interface EmbeddingCreateParams {
|
||||
/**
|
||||
* Input text to embed, encoded as a string or array of tokens. To embed multiple
|
||||
* inputs in a single request, pass an array of strings or array of token arrays.
|
||||
* The input must not exceed the max input tokens for the model (8192 tokens for
|
||||
* all embedding models), cannot be an empty string, and any array must be 2048
|
||||
* dimensions or less.
|
||||
* [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
|
||||
* for counting tokens. In addition to the per-input token limit, all embedding
|
||||
* models enforce a maximum of 300,000 tokens summed across all inputs in a single
|
||||
* request.
|
||||
*/
|
||||
input: string | Array<string> | Array<number> | Array<Array<number>>;
|
||||
|
||||
/**
|
||||
* ID of the model to use. You can use the
|
||||
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
|
||||
* see all of your available models, or see our
|
||||
* [Model overview](https://platform.openai.com/docs/models) for descriptions of
|
||||
* them.
|
||||
*/
|
||||
model: (string & {}) | EmbeddingModel;
|
||||
|
||||
/**
|
||||
* The number of dimensions the resulting output embeddings should have. Only
|
||||
* supported in `text-embedding-3` and later models.
|
||||
*/
|
||||
dimensions?: number;
|
||||
|
||||
/**
|
||||
* The format to return the embeddings in. Can be either `float` or
|
||||
* [`base64`](https://pypi.org/project/pybase64/).
|
||||
*/
|
||||
encoding_format?: 'float' | 'base64';
|
||||
|
||||
/**
|
||||
* A unique identifier representing your end-user, which can help OpenAI to monitor
|
||||
* and detect abuse.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
|
||||
*/
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export declare namespace Embeddings {
|
||||
export {
|
||||
type CreateEmbeddingResponse as CreateEmbeddingResponse,
|
||||
type Embedding as Embedding,
|
||||
type EmbeddingModel as EmbeddingModel,
|
||||
type EmbeddingCreateParams as EmbeddingCreateParams,
|
||||
};
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './evals/index';
|
||||
+909
@@ -0,0 +1,909 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import { isRequestOptions } from '../../core';
|
||||
import * as Core from '../../core';
|
||||
import * as Shared from '../shared';
|
||||
import * as GraderModelsAPI from '../graders/grader-models';
|
||||
import * as ResponsesAPI from '../responses/responses';
|
||||
import * as RunsAPI from './runs/runs';
|
||||
import {
|
||||
CreateEvalCompletionsRunDataSource,
|
||||
CreateEvalJSONLRunDataSource,
|
||||
EvalAPIError,
|
||||
RunCancelResponse,
|
||||
RunCreateParams,
|
||||
RunCreateResponse,
|
||||
RunDeleteResponse,
|
||||
RunListParams,
|
||||
RunListResponse,
|
||||
RunListResponsesPage,
|
||||
RunRetrieveResponse,
|
||||
Runs,
|
||||
} from './runs/runs';
|
||||
import { CursorPage, type CursorPageParams } from '../../pagination';
|
||||
|
||||
export class Evals extends APIResource {
|
||||
runs: RunsAPI.Runs = new RunsAPI.Runs(this._client);
|
||||
|
||||
/**
|
||||
* Create the structure of an evaluation that can be used to test a model's
|
||||
* performance. An evaluation is a set of testing criteria and the config for a
|
||||
* data source, which dictates the schema of the data used in the evaluation. After
|
||||
* creating an evaluation, you can run it on different models and model parameters.
|
||||
* We support several types of graders and datasources. For more information, see
|
||||
* the [Evals guide](https://platform.openai.com/docs/guides/evals).
|
||||
*/
|
||||
create(body: EvalCreateParams, options?: Core.RequestOptions): Core.APIPromise<EvalCreateResponse> {
|
||||
return this._client.post('/evals', { body, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an evaluation by ID.
|
||||
*/
|
||||
retrieve(evalId: string, options?: Core.RequestOptions): Core.APIPromise<EvalRetrieveResponse> {
|
||||
return this._client.get(`/evals/${evalId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update certain properties of an evaluation.
|
||||
*/
|
||||
update(
|
||||
evalId: string,
|
||||
body: EvalUpdateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<EvalUpdateResponse> {
|
||||
return this._client.post(`/evals/${evalId}`, { body, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* List evaluations for a project.
|
||||
*/
|
||||
list(
|
||||
query?: EvalListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<EvalListResponsesPage, EvalListResponse>;
|
||||
list(options?: Core.RequestOptions): Core.PagePromise<EvalListResponsesPage, EvalListResponse>;
|
||||
list(
|
||||
query: EvalListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<EvalListResponsesPage, EvalListResponse> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list({}, query);
|
||||
}
|
||||
return this._client.getAPIList('/evals', EvalListResponsesPage, { query, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an evaluation.
|
||||
*/
|
||||
del(evalId: string, options?: Core.RequestOptions): Core.APIPromise<EvalDeleteResponse> {
|
||||
return this._client.delete(`/evals/${evalId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class EvalListResponsesPage extends CursorPage<EvalListResponse> {}
|
||||
|
||||
/**
|
||||
* A CustomDataSourceConfig which specifies the schema of your `item` and
|
||||
* optionally `sample` namespaces. The response schema defines the shape of the
|
||||
* data that will be:
|
||||
*
|
||||
* - Used to define your testing criteria and
|
||||
* - What data is required when creating a run
|
||||
*/
|
||||
export interface EvalCustomDataSourceConfig {
|
||||
/**
|
||||
* The json schema for the run data source items. Learn how to build JSON schemas
|
||||
* [here](https://json-schema.org/).
|
||||
*/
|
||||
schema: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The type of data source. Always `custom`.
|
||||
*/
|
||||
type: 'custom';
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated in favor of LogsDataSourceConfig.
|
||||
*/
|
||||
export interface EvalStoredCompletionsDataSourceConfig {
|
||||
/**
|
||||
* The json schema for the run data source items. Learn how to build JSON schemas
|
||||
* [here](https://json-schema.org/).
|
||||
*/
|
||||
schema: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The type of data source. Always `stored_completions`.
|
||||
*/
|
||||
type: 'stored_completions';
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* An Eval object with a data source config and testing criteria. An Eval
|
||||
* represents a task to be done for your LLM integration. Like:
|
||||
*
|
||||
* - Improve the quality of my chatbot
|
||||
* - See how well my chatbot handles customer support
|
||||
* - Check if o4-mini is better at my usecase than gpt-4o
|
||||
*/
|
||||
export interface EvalCreateResponse {
|
||||
/**
|
||||
* Unique identifier for the evaluation.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the eval was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Configuration of data sources used in runs of the evaluation.
|
||||
*/
|
||||
data_source_config:
|
||||
| EvalCustomDataSourceConfig
|
||||
| EvalCreateResponse.Logs
|
||||
| EvalStoredCompletionsDataSourceConfig;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The name of the evaluation.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The object type.
|
||||
*/
|
||||
object: 'eval';
|
||||
|
||||
/**
|
||||
* A list of testing criteria.
|
||||
*/
|
||||
testing_criteria: Array<
|
||||
| GraderModelsAPI.LabelModelGrader
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| EvalCreateResponse.EvalGraderTextSimilarity
|
||||
| EvalCreateResponse.EvalGraderPython
|
||||
| EvalCreateResponse.EvalGraderScoreModel
|
||||
>;
|
||||
}
|
||||
|
||||
export namespace EvalCreateResponse {
|
||||
/**
|
||||
* A LogsDataSourceConfig which specifies the metadata property of your logs query.
|
||||
* This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc. The
|
||||
* schema returned by this data source config is used to defined what variables are
|
||||
* available in your evals. `item` and `sample` are both defined when using this
|
||||
* data source config.
|
||||
*/
|
||||
export interface Logs {
|
||||
/**
|
||||
* The json schema for the run data source items. Learn how to build JSON schemas
|
||||
* [here](https://json-schema.org/).
|
||||
*/
|
||||
schema: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The type of data source. Always `logs`.
|
||||
*/
|
||||
type: 'logs';
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A TextSimilarityGrader object which grades text based on similarity metrics.
|
||||
*/
|
||||
export interface EvalGraderTextSimilarity extends GraderModelsAPI.TextSimilarityGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A PythonGrader object that runs a python script on the input.
|
||||
*/
|
||||
export interface EvalGraderPython extends GraderModelsAPI.PythonGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ScoreModelGrader object that uses a model to assign a score to the input.
|
||||
*/
|
||||
export interface EvalGraderScoreModel extends GraderModelsAPI.ScoreModelGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An Eval object with a data source config and testing criteria. An Eval
|
||||
* represents a task to be done for your LLM integration. Like:
|
||||
*
|
||||
* - Improve the quality of my chatbot
|
||||
* - See how well my chatbot handles customer support
|
||||
* - Check if o4-mini is better at my usecase than gpt-4o
|
||||
*/
|
||||
export interface EvalRetrieveResponse {
|
||||
/**
|
||||
* Unique identifier for the evaluation.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the eval was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Configuration of data sources used in runs of the evaluation.
|
||||
*/
|
||||
data_source_config:
|
||||
| EvalCustomDataSourceConfig
|
||||
| EvalRetrieveResponse.Logs
|
||||
| EvalStoredCompletionsDataSourceConfig;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The name of the evaluation.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The object type.
|
||||
*/
|
||||
object: 'eval';
|
||||
|
||||
/**
|
||||
* A list of testing criteria.
|
||||
*/
|
||||
testing_criteria: Array<
|
||||
| GraderModelsAPI.LabelModelGrader
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| EvalRetrieveResponse.EvalGraderTextSimilarity
|
||||
| EvalRetrieveResponse.EvalGraderPython
|
||||
| EvalRetrieveResponse.EvalGraderScoreModel
|
||||
>;
|
||||
}
|
||||
|
||||
export namespace EvalRetrieveResponse {
|
||||
/**
|
||||
* A LogsDataSourceConfig which specifies the metadata property of your logs query.
|
||||
* This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc. The
|
||||
* schema returned by this data source config is used to defined what variables are
|
||||
* available in your evals. `item` and `sample` are both defined when using this
|
||||
* data source config.
|
||||
*/
|
||||
export interface Logs {
|
||||
/**
|
||||
* The json schema for the run data source items. Learn how to build JSON schemas
|
||||
* [here](https://json-schema.org/).
|
||||
*/
|
||||
schema: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The type of data source. Always `logs`.
|
||||
*/
|
||||
type: 'logs';
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A TextSimilarityGrader object which grades text based on similarity metrics.
|
||||
*/
|
||||
export interface EvalGraderTextSimilarity extends GraderModelsAPI.TextSimilarityGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A PythonGrader object that runs a python script on the input.
|
||||
*/
|
||||
export interface EvalGraderPython extends GraderModelsAPI.PythonGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ScoreModelGrader object that uses a model to assign a score to the input.
|
||||
*/
|
||||
export interface EvalGraderScoreModel extends GraderModelsAPI.ScoreModelGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An Eval object with a data source config and testing criteria. An Eval
|
||||
* represents a task to be done for your LLM integration. Like:
|
||||
*
|
||||
* - Improve the quality of my chatbot
|
||||
* - See how well my chatbot handles customer support
|
||||
* - Check if o4-mini is better at my usecase than gpt-4o
|
||||
*/
|
||||
export interface EvalUpdateResponse {
|
||||
/**
|
||||
* Unique identifier for the evaluation.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the eval was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Configuration of data sources used in runs of the evaluation.
|
||||
*/
|
||||
data_source_config:
|
||||
| EvalCustomDataSourceConfig
|
||||
| EvalUpdateResponse.Logs
|
||||
| EvalStoredCompletionsDataSourceConfig;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The name of the evaluation.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The object type.
|
||||
*/
|
||||
object: 'eval';
|
||||
|
||||
/**
|
||||
* A list of testing criteria.
|
||||
*/
|
||||
testing_criteria: Array<
|
||||
| GraderModelsAPI.LabelModelGrader
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| EvalUpdateResponse.EvalGraderTextSimilarity
|
||||
| EvalUpdateResponse.EvalGraderPython
|
||||
| EvalUpdateResponse.EvalGraderScoreModel
|
||||
>;
|
||||
}
|
||||
|
||||
export namespace EvalUpdateResponse {
|
||||
/**
|
||||
* A LogsDataSourceConfig which specifies the metadata property of your logs query.
|
||||
* This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc. The
|
||||
* schema returned by this data source config is used to defined what variables are
|
||||
* available in your evals. `item` and `sample` are both defined when using this
|
||||
* data source config.
|
||||
*/
|
||||
export interface Logs {
|
||||
/**
|
||||
* The json schema for the run data source items. Learn how to build JSON schemas
|
||||
* [here](https://json-schema.org/).
|
||||
*/
|
||||
schema: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The type of data source. Always `logs`.
|
||||
*/
|
||||
type: 'logs';
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A TextSimilarityGrader object which grades text based on similarity metrics.
|
||||
*/
|
||||
export interface EvalGraderTextSimilarity extends GraderModelsAPI.TextSimilarityGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A PythonGrader object that runs a python script on the input.
|
||||
*/
|
||||
export interface EvalGraderPython extends GraderModelsAPI.PythonGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ScoreModelGrader object that uses a model to assign a score to the input.
|
||||
*/
|
||||
export interface EvalGraderScoreModel extends GraderModelsAPI.ScoreModelGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An Eval object with a data source config and testing criteria. An Eval
|
||||
* represents a task to be done for your LLM integration. Like:
|
||||
*
|
||||
* - Improve the quality of my chatbot
|
||||
* - See how well my chatbot handles customer support
|
||||
* - Check if o4-mini is better at my usecase than gpt-4o
|
||||
*/
|
||||
export interface EvalListResponse {
|
||||
/**
|
||||
* Unique identifier for the evaluation.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the eval was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Configuration of data sources used in runs of the evaluation.
|
||||
*/
|
||||
data_source_config:
|
||||
| EvalCustomDataSourceConfig
|
||||
| EvalListResponse.Logs
|
||||
| EvalStoredCompletionsDataSourceConfig;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The name of the evaluation.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The object type.
|
||||
*/
|
||||
object: 'eval';
|
||||
|
||||
/**
|
||||
* A list of testing criteria.
|
||||
*/
|
||||
testing_criteria: Array<
|
||||
| GraderModelsAPI.LabelModelGrader
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| EvalListResponse.EvalGraderTextSimilarity
|
||||
| EvalListResponse.EvalGraderPython
|
||||
| EvalListResponse.EvalGraderScoreModel
|
||||
>;
|
||||
}
|
||||
|
||||
export namespace EvalListResponse {
|
||||
/**
|
||||
* A LogsDataSourceConfig which specifies the metadata property of your logs query.
|
||||
* This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc. The
|
||||
* schema returned by this data source config is used to defined what variables are
|
||||
* available in your evals. `item` and `sample` are both defined when using this
|
||||
* data source config.
|
||||
*/
|
||||
export interface Logs {
|
||||
/**
|
||||
* The json schema for the run data source items. Learn how to build JSON schemas
|
||||
* [here](https://json-schema.org/).
|
||||
*/
|
||||
schema: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The type of data source. Always `logs`.
|
||||
*/
|
||||
type: 'logs';
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A TextSimilarityGrader object which grades text based on similarity metrics.
|
||||
*/
|
||||
export interface EvalGraderTextSimilarity extends GraderModelsAPI.TextSimilarityGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A PythonGrader object that runs a python script on the input.
|
||||
*/
|
||||
export interface EvalGraderPython extends GraderModelsAPI.PythonGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ScoreModelGrader object that uses a model to assign a score to the input.
|
||||
*/
|
||||
export interface EvalGraderScoreModel extends GraderModelsAPI.ScoreModelGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface EvalDeleteResponse {
|
||||
deleted: boolean;
|
||||
|
||||
eval_id: string;
|
||||
|
||||
object: string;
|
||||
}
|
||||
|
||||
export interface EvalCreateParams {
|
||||
/**
|
||||
* The configuration for the data source used for the evaluation runs. Dictates the
|
||||
* schema of the data used in the evaluation.
|
||||
*/
|
||||
data_source_config: EvalCreateParams.Custom | EvalCreateParams.Logs | EvalCreateParams.StoredCompletions;
|
||||
|
||||
/**
|
||||
* A list of graders for all eval runs in this group. Graders can reference
|
||||
* variables in the data source using double curly braces notation, like
|
||||
* `{{item.variable_name}}`. To reference the model's output, use the `sample`
|
||||
* namespace (ie, `{{sample.output_text}}`).
|
||||
*/
|
||||
testing_criteria: Array<
|
||||
| EvalCreateParams.LabelModel
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| EvalCreateParams.TextSimilarity
|
||||
| EvalCreateParams.Python
|
||||
| EvalCreateParams.ScoreModel
|
||||
>;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The name of the evaluation.
|
||||
*/
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export namespace EvalCreateParams {
|
||||
/**
|
||||
* A CustomDataSourceConfig object that defines the schema for the data source used
|
||||
* for the evaluation runs. This schema is used to define the shape of the data
|
||||
* that will be:
|
||||
*
|
||||
* - Used to define your testing criteria and
|
||||
* - What data is required when creating a run
|
||||
*/
|
||||
export interface Custom {
|
||||
/**
|
||||
* The json schema for each row in the data source.
|
||||
*/
|
||||
item_schema: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The type of data source. Always `custom`.
|
||||
*/
|
||||
type: 'custom';
|
||||
|
||||
/**
|
||||
* Whether the eval should expect you to populate the sample namespace (ie, by
|
||||
* generating responses off of your data source)
|
||||
*/
|
||||
include_sample_schema?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A data source config which specifies the metadata property of your logs query.
|
||||
* This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.
|
||||
*/
|
||||
export interface Logs {
|
||||
/**
|
||||
* The type of data source. Always `logs`.
|
||||
*/
|
||||
type: 'logs';
|
||||
|
||||
/**
|
||||
* Metadata filters for the logs data source.
|
||||
*/
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated in favor of LogsDataSourceConfig.
|
||||
*/
|
||||
export interface StoredCompletions {
|
||||
/**
|
||||
* The type of data source. Always `stored_completions`.
|
||||
*/
|
||||
type: 'stored_completions';
|
||||
|
||||
/**
|
||||
* Metadata filters for the stored completions data source.
|
||||
*/
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A LabelModelGrader object which uses a model to assign labels to each item in
|
||||
* the evaluation.
|
||||
*/
|
||||
export interface LabelModel {
|
||||
/**
|
||||
* A list of chat messages forming the prompt or context. May include variable
|
||||
* references to the `item` namespace, ie {{item.name}}.
|
||||
*/
|
||||
input: Array<LabelModel.SimpleInputMessage | LabelModel.EvalItem>;
|
||||
|
||||
/**
|
||||
* The labels to classify to each item in the evaluation.
|
||||
*/
|
||||
labels: Array<string>;
|
||||
|
||||
/**
|
||||
* The model to use for the evaluation. Must support structured outputs.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The labels that indicate a passing result. Must be a subset of labels.
|
||||
*/
|
||||
passing_labels: Array<string>;
|
||||
|
||||
/**
|
||||
* The object type, which is always `label_model`.
|
||||
*/
|
||||
type: 'label_model';
|
||||
}
|
||||
|
||||
export namespace LabelModel {
|
||||
export interface SimpleInputMessage {
|
||||
/**
|
||||
* The content of the message.
|
||||
*/
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* The role of the message (e.g. "system", "assistant", "user").
|
||||
*/
|
||||
role: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A message input to the model with a role indicating instruction following
|
||||
* hierarchy. Instructions given with the `developer` or `system` role take
|
||||
* precedence over instructions given with the `user` role. Messages with the
|
||||
* `assistant` role are presumed to have been generated by the model in previous
|
||||
* interactions.
|
||||
*/
|
||||
export interface EvalItem {
|
||||
/**
|
||||
* Text inputs to the model - can contain template strings.
|
||||
*/
|
||||
content: string | ResponsesAPI.ResponseInputText | EvalItem.OutputText;
|
||||
|
||||
/**
|
||||
* The role of the message input. One of `user`, `assistant`, `system`, or
|
||||
* `developer`.
|
||||
*/
|
||||
role: 'user' | 'assistant' | 'system' | 'developer';
|
||||
|
||||
/**
|
||||
* The type of the message input. Always `message`.
|
||||
*/
|
||||
type?: 'message';
|
||||
}
|
||||
|
||||
export namespace EvalItem {
|
||||
/**
|
||||
* A text output from the model.
|
||||
*/
|
||||
export interface OutputText {
|
||||
/**
|
||||
* The text output from the model.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the output text. Always `output_text`.
|
||||
*/
|
||||
type: 'output_text';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A TextSimilarityGrader object which grades text based on similarity metrics.
|
||||
*/
|
||||
export interface TextSimilarity extends GraderModelsAPI.TextSimilarityGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A PythonGrader object that runs a python script on the input.
|
||||
*/
|
||||
export interface Python extends GraderModelsAPI.PythonGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ScoreModelGrader object that uses a model to assign a score to the input.
|
||||
*/
|
||||
export interface ScoreModel extends GraderModelsAPI.ScoreModelGrader {
|
||||
/**
|
||||
* The threshold for the score.
|
||||
*/
|
||||
pass_threshold?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface EvalUpdateParams {
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* Rename the evaluation.
|
||||
*/
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface EvalListParams extends CursorPageParams {
|
||||
/**
|
||||
* Sort order for evals by timestamp. Use `asc` for ascending order or `desc` for
|
||||
* descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
|
||||
/**
|
||||
* Evals can be ordered by creation time or last updated time. Use `created_at` for
|
||||
* creation time or `updated_at` for last updated time.
|
||||
*/
|
||||
order_by?: 'created_at' | 'updated_at';
|
||||
}
|
||||
|
||||
Evals.EvalListResponsesPage = EvalListResponsesPage;
|
||||
Evals.Runs = Runs;
|
||||
Evals.RunListResponsesPage = RunListResponsesPage;
|
||||
|
||||
export declare namespace Evals {
|
||||
export {
|
||||
type EvalCustomDataSourceConfig as EvalCustomDataSourceConfig,
|
||||
type EvalStoredCompletionsDataSourceConfig as EvalStoredCompletionsDataSourceConfig,
|
||||
type EvalCreateResponse as EvalCreateResponse,
|
||||
type EvalRetrieveResponse as EvalRetrieveResponse,
|
||||
type EvalUpdateResponse as EvalUpdateResponse,
|
||||
type EvalListResponse as EvalListResponse,
|
||||
type EvalDeleteResponse as EvalDeleteResponse,
|
||||
EvalListResponsesPage as EvalListResponsesPage,
|
||||
type EvalCreateParams as EvalCreateParams,
|
||||
type EvalUpdateParams as EvalUpdateParams,
|
||||
type EvalListParams as EvalListParams,
|
||||
};
|
||||
|
||||
export {
|
||||
Runs as Runs,
|
||||
type CreateEvalCompletionsRunDataSource as CreateEvalCompletionsRunDataSource,
|
||||
type CreateEvalJSONLRunDataSource as CreateEvalJSONLRunDataSource,
|
||||
type EvalAPIError as EvalAPIError,
|
||||
type RunCreateResponse as RunCreateResponse,
|
||||
type RunRetrieveResponse as RunRetrieveResponse,
|
||||
type RunListResponse as RunListResponse,
|
||||
type RunDeleteResponse as RunDeleteResponse,
|
||||
type RunCancelResponse as RunCancelResponse,
|
||||
RunListResponsesPage as RunListResponsesPage,
|
||||
type RunCreateParams as RunCreateParams,
|
||||
type RunListParams as RunListParams,
|
||||
};
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
EvalListResponsesPage,
|
||||
Evals,
|
||||
type EvalCustomDataSourceConfig,
|
||||
type EvalStoredCompletionsDataSourceConfig,
|
||||
type EvalCreateResponse,
|
||||
type EvalRetrieveResponse,
|
||||
type EvalUpdateResponse,
|
||||
type EvalListResponse,
|
||||
type EvalDeleteResponse,
|
||||
type EvalCreateParams,
|
||||
type EvalUpdateParams,
|
||||
type EvalListParams,
|
||||
} from './evals';
|
||||
export {
|
||||
RunListResponsesPage,
|
||||
Runs,
|
||||
type CreateEvalCompletionsRunDataSource,
|
||||
type CreateEvalJSONLRunDataSource,
|
||||
type EvalAPIError,
|
||||
type RunCreateResponse,
|
||||
type RunRetrieveResponse,
|
||||
type RunListResponse,
|
||||
type RunDeleteResponse,
|
||||
type RunCancelResponse,
|
||||
type RunCreateParams,
|
||||
type RunListParams,
|
||||
} from './runs/index';
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './runs/index';
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
OutputItemListResponsesPage,
|
||||
OutputItems,
|
||||
type OutputItemRetrieveResponse,
|
||||
type OutputItemListResponse,
|
||||
type OutputItemListParams,
|
||||
} from './output-items';
|
||||
export {
|
||||
RunListResponsesPage,
|
||||
Runs,
|
||||
type CreateEvalCompletionsRunDataSource,
|
||||
type CreateEvalJSONLRunDataSource,
|
||||
type EvalAPIError,
|
||||
type RunCreateResponse,
|
||||
type RunRetrieveResponse,
|
||||
type RunListResponse,
|
||||
type RunDeleteResponse,
|
||||
type RunCancelResponse,
|
||||
type RunCreateParams,
|
||||
type RunListParams,
|
||||
} from './runs';
|
||||
+410
@@ -0,0 +1,410 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import { isRequestOptions } from '../../../core';
|
||||
import * as Core from '../../../core';
|
||||
import * as RunsAPI from './runs';
|
||||
import { CursorPage, type CursorPageParams } from '../../../pagination';
|
||||
|
||||
export class OutputItems extends APIResource {
|
||||
/**
|
||||
* Get an evaluation run output item by ID.
|
||||
*/
|
||||
retrieve(
|
||||
evalId: string,
|
||||
runId: string,
|
||||
outputItemId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<OutputItemRetrieveResponse> {
|
||||
return this._client.get(`/evals/${evalId}/runs/${runId}/output_items/${outputItemId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of output items for an evaluation run.
|
||||
*/
|
||||
list(
|
||||
evalId: string,
|
||||
runId: string,
|
||||
query?: OutputItemListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<OutputItemListResponsesPage, OutputItemListResponse>;
|
||||
list(
|
||||
evalId: string,
|
||||
runId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<OutputItemListResponsesPage, OutputItemListResponse>;
|
||||
list(
|
||||
evalId: string,
|
||||
runId: string,
|
||||
query: OutputItemListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<OutputItemListResponsesPage, OutputItemListResponse> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(evalId, runId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(
|
||||
`/evals/${evalId}/runs/${runId}/output_items`,
|
||||
OutputItemListResponsesPage,
|
||||
{ query, ...options },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class OutputItemListResponsesPage extends CursorPage<OutputItemListResponse> {}
|
||||
|
||||
/**
|
||||
* A schema representing an evaluation run output item.
|
||||
*/
|
||||
export interface OutputItemRetrieveResponse {
|
||||
/**
|
||||
* Unique identifier for the evaluation run output item.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (in seconds) when the evaluation run was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Details of the input data source item.
|
||||
*/
|
||||
datasource_item: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The identifier for the data source item.
|
||||
*/
|
||||
datasource_item_id: number;
|
||||
|
||||
/**
|
||||
* The identifier of the evaluation group.
|
||||
*/
|
||||
eval_id: string;
|
||||
|
||||
/**
|
||||
* The type of the object. Always "eval.run.output_item".
|
||||
*/
|
||||
object: 'eval.run.output_item';
|
||||
|
||||
/**
|
||||
* A list of results from the evaluation run.
|
||||
*/
|
||||
results: Array<Record<string, unknown>>;
|
||||
|
||||
/**
|
||||
* The identifier of the evaluation run associated with this output item.
|
||||
*/
|
||||
run_id: string;
|
||||
|
||||
/**
|
||||
* A sample containing the input and output of the evaluation run.
|
||||
*/
|
||||
sample: OutputItemRetrieveResponse.Sample;
|
||||
|
||||
/**
|
||||
* The status of the evaluation run.
|
||||
*/
|
||||
status: string;
|
||||
}
|
||||
|
||||
export namespace OutputItemRetrieveResponse {
|
||||
/**
|
||||
* A sample containing the input and output of the evaluation run.
|
||||
*/
|
||||
export interface Sample {
|
||||
/**
|
||||
* An object representing an error response from the Eval API.
|
||||
*/
|
||||
error: RunsAPI.EvalAPIError;
|
||||
|
||||
/**
|
||||
* The reason why the sample generation was finished.
|
||||
*/
|
||||
finish_reason: string;
|
||||
|
||||
/**
|
||||
* An array of input messages.
|
||||
*/
|
||||
input: Array<Sample.Input>;
|
||||
|
||||
/**
|
||||
* The maximum number of tokens allowed for completion.
|
||||
*/
|
||||
max_completion_tokens: number;
|
||||
|
||||
/**
|
||||
* The model used for generating the sample.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* An array of output messages.
|
||||
*/
|
||||
output: Array<Sample.Output>;
|
||||
|
||||
/**
|
||||
* The seed used for generating the sample.
|
||||
*/
|
||||
seed: number;
|
||||
|
||||
/**
|
||||
* The sampling temperature used.
|
||||
*/
|
||||
temperature: number;
|
||||
|
||||
/**
|
||||
* The top_p value used for sampling.
|
||||
*/
|
||||
top_p: number;
|
||||
|
||||
/**
|
||||
* Token usage details for the sample.
|
||||
*/
|
||||
usage: Sample.Usage;
|
||||
}
|
||||
|
||||
export namespace Sample {
|
||||
/**
|
||||
* An input message.
|
||||
*/
|
||||
export interface Input {
|
||||
/**
|
||||
* The content of the message.
|
||||
*/
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* The role of the message sender (e.g., system, user, developer).
|
||||
*/
|
||||
role: string;
|
||||
}
|
||||
|
||||
export interface Output {
|
||||
/**
|
||||
* The content of the message.
|
||||
*/
|
||||
content?: string;
|
||||
|
||||
/**
|
||||
* The role of the message (e.g. "system", "assistant", "user").
|
||||
*/
|
||||
role?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Token usage details for the sample.
|
||||
*/
|
||||
export interface Usage {
|
||||
/**
|
||||
* The number of tokens retrieved from cache.
|
||||
*/
|
||||
cached_tokens: number;
|
||||
|
||||
/**
|
||||
* The number of completion tokens generated.
|
||||
*/
|
||||
completion_tokens: number;
|
||||
|
||||
/**
|
||||
* The number of prompt tokens used.
|
||||
*/
|
||||
prompt_tokens: number;
|
||||
|
||||
/**
|
||||
* The total number of tokens used.
|
||||
*/
|
||||
total_tokens: number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A schema representing an evaluation run output item.
|
||||
*/
|
||||
export interface OutputItemListResponse {
|
||||
/**
|
||||
* Unique identifier for the evaluation run output item.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (in seconds) when the evaluation run was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Details of the input data source item.
|
||||
*/
|
||||
datasource_item: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The identifier for the data source item.
|
||||
*/
|
||||
datasource_item_id: number;
|
||||
|
||||
/**
|
||||
* The identifier of the evaluation group.
|
||||
*/
|
||||
eval_id: string;
|
||||
|
||||
/**
|
||||
* The type of the object. Always "eval.run.output_item".
|
||||
*/
|
||||
object: 'eval.run.output_item';
|
||||
|
||||
/**
|
||||
* A list of results from the evaluation run.
|
||||
*/
|
||||
results: Array<Record<string, unknown>>;
|
||||
|
||||
/**
|
||||
* The identifier of the evaluation run associated with this output item.
|
||||
*/
|
||||
run_id: string;
|
||||
|
||||
/**
|
||||
* A sample containing the input and output of the evaluation run.
|
||||
*/
|
||||
sample: OutputItemListResponse.Sample;
|
||||
|
||||
/**
|
||||
* The status of the evaluation run.
|
||||
*/
|
||||
status: string;
|
||||
}
|
||||
|
||||
export namespace OutputItemListResponse {
|
||||
/**
|
||||
* A sample containing the input and output of the evaluation run.
|
||||
*/
|
||||
export interface Sample {
|
||||
/**
|
||||
* An object representing an error response from the Eval API.
|
||||
*/
|
||||
error: RunsAPI.EvalAPIError;
|
||||
|
||||
/**
|
||||
* The reason why the sample generation was finished.
|
||||
*/
|
||||
finish_reason: string;
|
||||
|
||||
/**
|
||||
* An array of input messages.
|
||||
*/
|
||||
input: Array<Sample.Input>;
|
||||
|
||||
/**
|
||||
* The maximum number of tokens allowed for completion.
|
||||
*/
|
||||
max_completion_tokens: number;
|
||||
|
||||
/**
|
||||
* The model used for generating the sample.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* An array of output messages.
|
||||
*/
|
||||
output: Array<Sample.Output>;
|
||||
|
||||
/**
|
||||
* The seed used for generating the sample.
|
||||
*/
|
||||
seed: number;
|
||||
|
||||
/**
|
||||
* The sampling temperature used.
|
||||
*/
|
||||
temperature: number;
|
||||
|
||||
/**
|
||||
* The top_p value used for sampling.
|
||||
*/
|
||||
top_p: number;
|
||||
|
||||
/**
|
||||
* Token usage details for the sample.
|
||||
*/
|
||||
usage: Sample.Usage;
|
||||
}
|
||||
|
||||
export namespace Sample {
|
||||
/**
|
||||
* An input message.
|
||||
*/
|
||||
export interface Input {
|
||||
/**
|
||||
* The content of the message.
|
||||
*/
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* The role of the message sender (e.g., system, user, developer).
|
||||
*/
|
||||
role: string;
|
||||
}
|
||||
|
||||
export interface Output {
|
||||
/**
|
||||
* The content of the message.
|
||||
*/
|
||||
content?: string;
|
||||
|
||||
/**
|
||||
* The role of the message (e.g. "system", "assistant", "user").
|
||||
*/
|
||||
role?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Token usage details for the sample.
|
||||
*/
|
||||
export interface Usage {
|
||||
/**
|
||||
* The number of tokens retrieved from cache.
|
||||
*/
|
||||
cached_tokens: number;
|
||||
|
||||
/**
|
||||
* The number of completion tokens generated.
|
||||
*/
|
||||
completion_tokens: number;
|
||||
|
||||
/**
|
||||
* The number of prompt tokens used.
|
||||
*/
|
||||
prompt_tokens: number;
|
||||
|
||||
/**
|
||||
* The total number of tokens used.
|
||||
*/
|
||||
total_tokens: number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface OutputItemListParams extends CursorPageParams {
|
||||
/**
|
||||
* Sort order for output items by timestamp. Use `asc` for ascending order or
|
||||
* `desc` for descending order. Defaults to `asc`.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
|
||||
/**
|
||||
* Filter output items by status. Use `failed` to filter by failed output items or
|
||||
* `pass` to filter by passed output items.
|
||||
*/
|
||||
status?: 'fail' | 'pass';
|
||||
}
|
||||
|
||||
OutputItems.OutputItemListResponsesPage = OutputItemListResponsesPage;
|
||||
|
||||
export declare namespace OutputItems {
|
||||
export {
|
||||
type OutputItemRetrieveResponse as OutputItemRetrieveResponse,
|
||||
type OutputItemListResponse as OutputItemListResponse,
|
||||
OutputItemListResponsesPage as OutputItemListResponsesPage,
|
||||
type OutputItemListParams as OutputItemListParams,
|
||||
};
|
||||
}
|
||||
+2228
File diff suppressed because it is too large
Load Diff
+236
@@ -0,0 +1,236 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../resource';
|
||||
import { isRequestOptions } from '../core';
|
||||
import { sleep } from '../core';
|
||||
import { APIConnectionTimeoutError } from '../error';
|
||||
import * as Core from '../core';
|
||||
import { CursorPage, type CursorPageParams } from '../pagination';
|
||||
import { type Response } from '../_shims/index';
|
||||
|
||||
export class Files extends APIResource {
|
||||
/**
|
||||
* Upload a file that can be used across various endpoints. Individual files can be
|
||||
* up to 512 MB, and the size of all files uploaded by one organization can be up
|
||||
* to 100 GB.
|
||||
*
|
||||
* The Assistants API supports files up to 2 million tokens and of specific file
|
||||
* types. See the
|
||||
* [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
|
||||
* details.
|
||||
*
|
||||
* The Fine-tuning API only supports `.jsonl` files. The input also has certain
|
||||
* required formats for fine-tuning
|
||||
* [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
|
||||
* [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
|
||||
* models.
|
||||
*
|
||||
* The Batch API only supports `.jsonl` files up to 200 MB in size. The input also
|
||||
* has a specific required
|
||||
* [format](https://platform.openai.com/docs/api-reference/batch/request-input).
|
||||
*
|
||||
* Please [contact us](https://help.openai.com/) if you need to increase these
|
||||
* storage limits.
|
||||
*/
|
||||
create(body: FileCreateParams, options?: Core.RequestOptions): Core.APIPromise<FileObject> {
|
||||
return this._client.post('/files', Core.multipartFormRequestOptions({ body, ...options }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about a specific file.
|
||||
*/
|
||||
retrieve(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileObject> {
|
||||
return this._client.get(`/files/${fileId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of files.
|
||||
*/
|
||||
list(query?: FileListParams, options?: Core.RequestOptions): Core.PagePromise<FileObjectsPage, FileObject>;
|
||||
list(options?: Core.RequestOptions): Core.PagePromise<FileObjectsPage, FileObject>;
|
||||
list(
|
||||
query: FileListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FileObjectsPage, FileObject> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list({}, query);
|
||||
}
|
||||
return this._client.getAPIList('/files', FileObjectsPage, { query, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file.
|
||||
*/
|
||||
del(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileDeleted> {
|
||||
return this._client.delete(`/files/${fileId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of the specified file.
|
||||
*/
|
||||
content(fileId: string, options?: Core.RequestOptions): Core.APIPromise<Response> {
|
||||
return this._client.get(`/files/${fileId}/content`, {
|
||||
...options,
|
||||
headers: { Accept: 'application/binary', ...options?.headers },
|
||||
__binaryResponse: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of the specified file.
|
||||
*
|
||||
* @deprecated The `.content()` method should be used instead
|
||||
*/
|
||||
retrieveContent(fileId: string, options?: Core.RequestOptions): Core.APIPromise<string> {
|
||||
return this._client.get(`/files/${fileId}/content`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the given file to be processed, default timeout is 30 mins.
|
||||
*/
|
||||
async waitForProcessing(
|
||||
id: string,
|
||||
{ pollInterval = 5000, maxWait = 30 * 60 * 1000 }: { pollInterval?: number; maxWait?: number } = {},
|
||||
): Promise<FileObject> {
|
||||
const TERMINAL_STATES = new Set(['processed', 'error', 'deleted']);
|
||||
|
||||
const start = Date.now();
|
||||
let file = await this.retrieve(id);
|
||||
|
||||
while (!file.status || !TERMINAL_STATES.has(file.status)) {
|
||||
await sleep(pollInterval);
|
||||
|
||||
file = await this.retrieve(id);
|
||||
if (Date.now() - start > maxWait) {
|
||||
throw new APIConnectionTimeoutError({
|
||||
message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
export class FileObjectsPage extends CursorPage<FileObject> {}
|
||||
|
||||
export type FileContent = string;
|
||||
|
||||
export interface FileDeleted {
|
||||
id: string;
|
||||
|
||||
deleted: boolean;
|
||||
|
||||
object: 'file';
|
||||
}
|
||||
|
||||
/**
|
||||
* The `File` object represents a document that has been uploaded to OpenAI.
|
||||
*/
|
||||
export interface FileObject {
|
||||
/**
|
||||
* The file identifier, which can be referenced in the API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The size of the file, in bytes.
|
||||
*/
|
||||
bytes: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the file was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The name of the file.
|
||||
*/
|
||||
filename: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always `file`.
|
||||
*/
|
||||
object: 'file';
|
||||
|
||||
/**
|
||||
* The intended purpose of the file. Supported values are `assistants`,
|
||||
* `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`
|
||||
* and `vision`.
|
||||
*/
|
||||
purpose:
|
||||
| 'assistants'
|
||||
| 'assistants_output'
|
||||
| 'batch'
|
||||
| 'batch_output'
|
||||
| 'fine-tune'
|
||||
| 'fine-tune-results'
|
||||
| 'vision';
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated. The current status of the file, which can be either
|
||||
* `uploaded`, `processed`, or `error`.
|
||||
*/
|
||||
status: 'uploaded' | 'processed' | 'error';
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the file will expire.
|
||||
*/
|
||||
expires_at?: number;
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated. For details on why a fine-tuning training file failed
|
||||
* validation, see the `error` field on `fine_tuning.job`.
|
||||
*/
|
||||
status_details?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The intended purpose of the uploaded file. One of: - `assistants`: Used in the
|
||||
* Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
|
||||
* fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
|
||||
* Flexible file type for any purpose - `evals`: Used for eval data sets
|
||||
*/
|
||||
export type FilePurpose = 'assistants' | 'batch' | 'fine-tune' | 'vision' | 'user_data' | 'evals';
|
||||
|
||||
export interface FileCreateParams {
|
||||
/**
|
||||
* The File object (not file name) to be uploaded.
|
||||
*/
|
||||
file: Core.Uploadable;
|
||||
|
||||
/**
|
||||
* The intended purpose of the uploaded file. One of: - `assistants`: Used in the
|
||||
* Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
|
||||
* fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
|
||||
* Flexible file type for any purpose - `evals`: Used for eval data sets
|
||||
*/
|
||||
purpose: FilePurpose;
|
||||
}
|
||||
|
||||
export interface FileListParams extends CursorPageParams {
|
||||
/**
|
||||
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
||||
* order and `desc` for descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
|
||||
/**
|
||||
* Only return files with the given purpose.
|
||||
*/
|
||||
purpose?: string;
|
||||
}
|
||||
|
||||
Files.FileObjectsPage = FileObjectsPage;
|
||||
|
||||
export declare namespace Files {
|
||||
export {
|
||||
type FileContent as FileContent,
|
||||
type FileDeleted as FileDeleted,
|
||||
type FileObject as FileObject,
|
||||
type FilePurpose as FilePurpose,
|
||||
FileObjectsPage as FileObjectsPage,
|
||||
type FileCreateParams as FileCreateParams,
|
||||
type FileListParams as FileListParams,
|
||||
};
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './alpha/index';
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import * as GradersAPI from './graders';
|
||||
import {
|
||||
GraderRunParams,
|
||||
GraderRunResponse,
|
||||
GraderValidateParams,
|
||||
GraderValidateResponse,
|
||||
Graders,
|
||||
} from './graders';
|
||||
|
||||
export class Alpha extends APIResource {
|
||||
graders: GradersAPI.Graders = new GradersAPI.Graders(this._client);
|
||||
}
|
||||
|
||||
Alpha.Graders = Graders;
|
||||
|
||||
export declare namespace Alpha {
|
||||
export {
|
||||
Graders as Graders,
|
||||
type GraderRunResponse as GraderRunResponse,
|
||||
type GraderValidateResponse as GraderValidateResponse,
|
||||
type GraderRunParams as GraderRunParams,
|
||||
type GraderValidateParams as GraderValidateParams,
|
||||
};
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import * as Core from '../../../core';
|
||||
import * as GraderModelsAPI from '../../graders/grader-models';
|
||||
|
||||
export class Graders extends APIResource {
|
||||
/**
|
||||
* Run a grader.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const response = await client.fineTuning.alpha.graders.run({
|
||||
* grader: {
|
||||
* input: 'input',
|
||||
* name: 'name',
|
||||
* operation: 'eq',
|
||||
* reference: 'reference',
|
||||
* type: 'string_check',
|
||||
* },
|
||||
* model_sample: 'model_sample',
|
||||
* reference_answer: 'string',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
run(body: GraderRunParams, options?: Core.RequestOptions): Core.APIPromise<GraderRunResponse> {
|
||||
return this._client.post('/fine_tuning/alpha/graders/run', { body, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a grader.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const response =
|
||||
* await client.fineTuning.alpha.graders.validate({
|
||||
* grader: {
|
||||
* input: 'input',
|
||||
* name: 'name',
|
||||
* operation: 'eq',
|
||||
* reference: 'reference',
|
||||
* type: 'string_check',
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
validate(
|
||||
body: GraderValidateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<GraderValidateResponse> {
|
||||
return this._client.post('/fine_tuning/alpha/graders/validate', { body, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
export interface GraderRunResponse {
|
||||
metadata: GraderRunResponse.Metadata;
|
||||
|
||||
model_grader_token_usage_per_model: Record<string, unknown>;
|
||||
|
||||
reward: number;
|
||||
|
||||
sub_rewards: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export namespace GraderRunResponse {
|
||||
export interface Metadata {
|
||||
errors: Metadata.Errors;
|
||||
|
||||
execution_time: number;
|
||||
|
||||
name: string;
|
||||
|
||||
sampled_model_name: string | null;
|
||||
|
||||
scores: Record<string, unknown>;
|
||||
|
||||
token_usage: number | null;
|
||||
|
||||
type: string;
|
||||
}
|
||||
|
||||
export namespace Metadata {
|
||||
export interface Errors {
|
||||
formula_parse_error: boolean;
|
||||
|
||||
invalid_variable_error: boolean;
|
||||
|
||||
model_grader_parse_error: boolean;
|
||||
|
||||
model_grader_refusal_error: boolean;
|
||||
|
||||
model_grader_server_error: boolean;
|
||||
|
||||
model_grader_server_error_details: string | null;
|
||||
|
||||
other_error: boolean;
|
||||
|
||||
python_grader_runtime_error: boolean;
|
||||
|
||||
python_grader_runtime_error_details: string | null;
|
||||
|
||||
python_grader_server_error: boolean;
|
||||
|
||||
python_grader_server_error_type: string | null;
|
||||
|
||||
sample_parse_error: boolean;
|
||||
|
||||
truncated_observation_error: boolean;
|
||||
|
||||
unresponsive_reward_error: boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface GraderValidateResponse {
|
||||
/**
|
||||
* The grader used for the fine-tuning job.
|
||||
*/
|
||||
grader?:
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| GraderModelsAPI.TextSimilarityGrader
|
||||
| GraderModelsAPI.PythonGrader
|
||||
| GraderModelsAPI.ScoreModelGrader
|
||||
| GraderModelsAPI.MultiGrader;
|
||||
}
|
||||
|
||||
export interface GraderRunParams {
|
||||
/**
|
||||
* The grader used for the fine-tuning job.
|
||||
*/
|
||||
grader:
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| GraderModelsAPI.TextSimilarityGrader
|
||||
| GraderModelsAPI.PythonGrader
|
||||
| GraderModelsAPI.ScoreModelGrader
|
||||
| GraderModelsAPI.MultiGrader;
|
||||
|
||||
/**
|
||||
* The model sample to be evaluated.
|
||||
*/
|
||||
model_sample: string;
|
||||
|
||||
/**
|
||||
* The reference answer for the evaluation.
|
||||
*/
|
||||
reference_answer: string | unknown | Array<unknown> | number;
|
||||
}
|
||||
|
||||
export interface GraderValidateParams {
|
||||
/**
|
||||
* The grader used for the fine-tuning job.
|
||||
*/
|
||||
grader:
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| GraderModelsAPI.TextSimilarityGrader
|
||||
| GraderModelsAPI.PythonGrader
|
||||
| GraderModelsAPI.ScoreModelGrader
|
||||
| GraderModelsAPI.MultiGrader;
|
||||
}
|
||||
|
||||
export declare namespace Graders {
|
||||
export {
|
||||
type GraderRunResponse as GraderRunResponse,
|
||||
type GraderValidateResponse as GraderValidateResponse,
|
||||
type GraderRunParams as GraderRunParams,
|
||||
type GraderValidateParams as GraderValidateParams,
|
||||
};
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Alpha } from './alpha';
|
||||
export {
|
||||
Graders,
|
||||
type GraderRunResponse,
|
||||
type GraderValidateResponse,
|
||||
type GraderRunParams,
|
||||
type GraderValidateParams,
|
||||
} from './graders';
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './checkpoints/index';
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import * as PermissionsAPI from './permissions';
|
||||
import {
|
||||
PermissionCreateParams,
|
||||
PermissionCreateResponse,
|
||||
PermissionCreateResponsesPage,
|
||||
PermissionDeleteResponse,
|
||||
PermissionRetrieveParams,
|
||||
PermissionRetrieveResponse,
|
||||
Permissions,
|
||||
} from './permissions';
|
||||
|
||||
export class Checkpoints extends APIResource {
|
||||
permissions: PermissionsAPI.Permissions = new PermissionsAPI.Permissions(this._client);
|
||||
}
|
||||
|
||||
Checkpoints.Permissions = Permissions;
|
||||
Checkpoints.PermissionCreateResponsesPage = PermissionCreateResponsesPage;
|
||||
|
||||
export declare namespace Checkpoints {
|
||||
export {
|
||||
Permissions as Permissions,
|
||||
type PermissionCreateResponse as PermissionCreateResponse,
|
||||
type PermissionRetrieveResponse as PermissionRetrieveResponse,
|
||||
type PermissionDeleteResponse as PermissionDeleteResponse,
|
||||
PermissionCreateResponsesPage as PermissionCreateResponsesPage,
|
||||
type PermissionCreateParams as PermissionCreateParams,
|
||||
type PermissionRetrieveParams as PermissionRetrieveParams,
|
||||
};
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Checkpoints } from './checkpoints';
|
||||
export {
|
||||
PermissionCreateResponsesPage,
|
||||
Permissions,
|
||||
type PermissionCreateResponse,
|
||||
type PermissionRetrieveResponse,
|
||||
type PermissionDeleteResponse,
|
||||
type PermissionCreateParams,
|
||||
type PermissionRetrieveParams,
|
||||
} from './permissions';
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import { isRequestOptions } from '../../../core';
|
||||
import * as Core from '../../../core';
|
||||
import { Page } from '../../../pagination';
|
||||
|
||||
export class Permissions extends APIResource {
|
||||
/**
|
||||
* **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
|
||||
*
|
||||
* This enables organization owners to share fine-tuned models with other projects
|
||||
* in their organization.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Automatically fetches more pages as needed.
|
||||
* for await (const permissionCreateResponse of client.fineTuning.checkpoints.permissions.create(
|
||||
* 'ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd',
|
||||
* { project_ids: ['string'] },
|
||||
* )) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
create(
|
||||
fineTunedModelCheckpoint: string,
|
||||
body: PermissionCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<PermissionCreateResponsesPage, PermissionCreateResponse> {
|
||||
return this._client.getAPIList(
|
||||
`/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`,
|
||||
PermissionCreateResponsesPage,
|
||||
{ body, method: 'post', ...options },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
|
||||
*
|
||||
* Organization owners can use this endpoint to view all permissions for a
|
||||
* fine-tuned model checkpoint.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const permission =
|
||||
* await client.fineTuning.checkpoints.permissions.retrieve(
|
||||
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
retrieve(
|
||||
fineTunedModelCheckpoint: string,
|
||||
query?: PermissionRetrieveParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<PermissionRetrieveResponse>;
|
||||
retrieve(
|
||||
fineTunedModelCheckpoint: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<PermissionRetrieveResponse>;
|
||||
retrieve(
|
||||
fineTunedModelCheckpoint: string,
|
||||
query: PermissionRetrieveParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<PermissionRetrieveResponse> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.retrieve(fineTunedModelCheckpoint, {}, query);
|
||||
}
|
||||
return this._client.get(`/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, {
|
||||
query,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
|
||||
*
|
||||
* Organization owners can use this endpoint to delete a permission for a
|
||||
* fine-tuned model checkpoint.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const permission =
|
||||
* await client.fineTuning.checkpoints.permissions.del(
|
||||
* 'ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd',
|
||||
* 'cp_zc4Q7MP6XxulcVzj4MZdwsAB',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
del(
|
||||
fineTunedModelCheckpoint: string,
|
||||
permissionId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<PermissionDeleteResponse> {
|
||||
return this._client.delete(
|
||||
`/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions/${permissionId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: no pagination actually occurs yet, this is for forwards-compatibility.
|
||||
*/
|
||||
export class PermissionCreateResponsesPage extends Page<PermissionCreateResponse> {}
|
||||
|
||||
/**
|
||||
* The `checkpoint.permission` object represents a permission for a fine-tuned
|
||||
* model checkpoint.
|
||||
*/
|
||||
export interface PermissionCreateResponse {
|
||||
/**
|
||||
* The permission identifier, which can be referenced in the API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the permission was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The object type, which is always "checkpoint.permission".
|
||||
*/
|
||||
object: 'checkpoint.permission';
|
||||
|
||||
/**
|
||||
* The project identifier that the permission is for.
|
||||
*/
|
||||
project_id: string;
|
||||
}
|
||||
|
||||
export interface PermissionRetrieveResponse {
|
||||
data: Array<PermissionRetrieveResponse.Data>;
|
||||
|
||||
has_more: boolean;
|
||||
|
||||
object: 'list';
|
||||
|
||||
first_id?: string | null;
|
||||
|
||||
last_id?: string | null;
|
||||
}
|
||||
|
||||
export namespace PermissionRetrieveResponse {
|
||||
/**
|
||||
* The `checkpoint.permission` object represents a permission for a fine-tuned
|
||||
* model checkpoint.
|
||||
*/
|
||||
export interface Data {
|
||||
/**
|
||||
* The permission identifier, which can be referenced in the API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the permission was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The object type, which is always "checkpoint.permission".
|
||||
*/
|
||||
object: 'checkpoint.permission';
|
||||
|
||||
/**
|
||||
* The project identifier that the permission is for.
|
||||
*/
|
||||
project_id: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface PermissionDeleteResponse {
|
||||
/**
|
||||
* The ID of the fine-tuned model checkpoint permission that was deleted.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Whether the fine-tuned model checkpoint permission was successfully deleted.
|
||||
*/
|
||||
deleted: boolean;
|
||||
|
||||
/**
|
||||
* The object type, which is always "checkpoint.permission".
|
||||
*/
|
||||
object: 'checkpoint.permission';
|
||||
}
|
||||
|
||||
export interface PermissionCreateParams {
|
||||
/**
|
||||
* The project identifiers to grant access to.
|
||||
*/
|
||||
project_ids: Array<string>;
|
||||
}
|
||||
|
||||
export interface PermissionRetrieveParams {
|
||||
/**
|
||||
* Identifier for the last permission ID from the previous pagination request.
|
||||
*/
|
||||
after?: string;
|
||||
|
||||
/**
|
||||
* Number of permissions to retrieve.
|
||||
*/
|
||||
limit?: number;
|
||||
|
||||
/**
|
||||
* The order in which to retrieve permissions.
|
||||
*/
|
||||
order?: 'ascending' | 'descending';
|
||||
|
||||
/**
|
||||
* The ID of the project to get permissions for.
|
||||
*/
|
||||
project_id?: string;
|
||||
}
|
||||
|
||||
Permissions.PermissionCreateResponsesPage = PermissionCreateResponsesPage;
|
||||
|
||||
export declare namespace Permissions {
|
||||
export {
|
||||
type PermissionCreateResponse as PermissionCreateResponse,
|
||||
type PermissionRetrieveResponse as PermissionRetrieveResponse,
|
||||
type PermissionDeleteResponse as PermissionDeleteResponse,
|
||||
PermissionCreateResponsesPage as PermissionCreateResponsesPage,
|
||||
type PermissionCreateParams as PermissionCreateParams,
|
||||
type PermissionRetrieveParams as PermissionRetrieveParams,
|
||||
};
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as MethodsAPI from './methods';
|
||||
import {
|
||||
DpoHyperparameters,
|
||||
DpoMethod,
|
||||
Methods,
|
||||
ReinforcementHyperparameters,
|
||||
ReinforcementMethod,
|
||||
SupervisedHyperparameters,
|
||||
SupervisedMethod,
|
||||
} from './methods';
|
||||
import * as AlphaAPI from './alpha/alpha';
|
||||
import { Alpha } from './alpha/alpha';
|
||||
import * as CheckpointsAPI from './checkpoints/checkpoints';
|
||||
import { Checkpoints } from './checkpoints/checkpoints';
|
||||
import * as JobsAPI from './jobs/jobs';
|
||||
import {
|
||||
FineTuningJob,
|
||||
FineTuningJobEvent,
|
||||
FineTuningJobEventsPage,
|
||||
FineTuningJobIntegration,
|
||||
FineTuningJobWandbIntegration,
|
||||
FineTuningJobWandbIntegrationObject,
|
||||
FineTuningJobsPage,
|
||||
JobCreateParams,
|
||||
JobListEventsParams,
|
||||
JobListParams,
|
||||
Jobs,
|
||||
} from './jobs/jobs';
|
||||
|
||||
export class FineTuning extends APIResource {
|
||||
methods: MethodsAPI.Methods = new MethodsAPI.Methods(this._client);
|
||||
jobs: JobsAPI.Jobs = new JobsAPI.Jobs(this._client);
|
||||
checkpoints: CheckpointsAPI.Checkpoints = new CheckpointsAPI.Checkpoints(this._client);
|
||||
alpha: AlphaAPI.Alpha = new AlphaAPI.Alpha(this._client);
|
||||
}
|
||||
|
||||
FineTuning.Methods = Methods;
|
||||
FineTuning.Jobs = Jobs;
|
||||
FineTuning.FineTuningJobsPage = FineTuningJobsPage;
|
||||
FineTuning.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
||||
FineTuning.Checkpoints = Checkpoints;
|
||||
FineTuning.Alpha = Alpha;
|
||||
|
||||
export declare namespace FineTuning {
|
||||
export {
|
||||
Methods as Methods,
|
||||
type DpoHyperparameters as DpoHyperparameters,
|
||||
type DpoMethod as DpoMethod,
|
||||
type ReinforcementHyperparameters as ReinforcementHyperparameters,
|
||||
type ReinforcementMethod as ReinforcementMethod,
|
||||
type SupervisedHyperparameters as SupervisedHyperparameters,
|
||||
type SupervisedMethod as SupervisedMethod,
|
||||
};
|
||||
|
||||
export {
|
||||
Jobs as Jobs,
|
||||
type FineTuningJob as FineTuningJob,
|
||||
type FineTuningJobEvent as FineTuningJobEvent,
|
||||
type FineTuningJobIntegration as FineTuningJobIntegration,
|
||||
type FineTuningJobWandbIntegration as FineTuningJobWandbIntegration,
|
||||
type FineTuningJobWandbIntegrationObject as FineTuningJobWandbIntegrationObject,
|
||||
FineTuningJobsPage as FineTuningJobsPage,
|
||||
FineTuningJobEventsPage as FineTuningJobEventsPage,
|
||||
type JobCreateParams as JobCreateParams,
|
||||
type JobListParams as JobListParams,
|
||||
type JobListEventsParams as JobListEventsParams,
|
||||
};
|
||||
|
||||
export { Checkpoints as Checkpoints };
|
||||
|
||||
export { Alpha as Alpha };
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Alpha } from './alpha/index';
|
||||
export { Checkpoints } from './checkpoints/index';
|
||||
export { FineTuning } from './fine-tuning';
|
||||
export {
|
||||
FineTuningJobsPage,
|
||||
FineTuningJobEventsPage,
|
||||
Jobs,
|
||||
type FineTuningJob,
|
||||
type FineTuningJobEvent,
|
||||
type FineTuningJobIntegration,
|
||||
type FineTuningJobWandbIntegration,
|
||||
type FineTuningJobWandbIntegrationObject,
|
||||
type JobCreateParams,
|
||||
type JobListParams,
|
||||
type JobListEventsParams,
|
||||
} from './jobs/index';
|
||||
export {
|
||||
Methods,
|
||||
type DpoHyperparameters,
|
||||
type DpoMethod,
|
||||
type ReinforcementHyperparameters,
|
||||
type ReinforcementMethod,
|
||||
type SupervisedHyperparameters,
|
||||
type SupervisedMethod,
|
||||
} from './methods';
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import { isRequestOptions } from '../../../core';
|
||||
import * as Core from '../../../core';
|
||||
import { CursorPage, type CursorPageParams } from '../../../pagination';
|
||||
|
||||
export class Checkpoints extends APIResource {
|
||||
/**
|
||||
* List checkpoints for a fine-tuning job.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Automatically fetches more pages as needed.
|
||||
* for await (const fineTuningJobCheckpoint of client.fineTuning.jobs.checkpoints.list(
|
||||
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
||||
* )) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
list(
|
||||
fineTuningJobId: string,
|
||||
query?: CheckpointListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FineTuningJobCheckpointsPage, FineTuningJobCheckpoint>;
|
||||
list(
|
||||
fineTuningJobId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FineTuningJobCheckpointsPage, FineTuningJobCheckpoint>;
|
||||
list(
|
||||
fineTuningJobId: string,
|
||||
query: CheckpointListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FineTuningJobCheckpointsPage, FineTuningJobCheckpoint> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(fineTuningJobId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(
|
||||
`/fine_tuning/jobs/${fineTuningJobId}/checkpoints`,
|
||||
FineTuningJobCheckpointsPage,
|
||||
{ query, ...options },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class FineTuningJobCheckpointsPage extends CursorPage<FineTuningJobCheckpoint> {}
|
||||
|
||||
/**
|
||||
* The `fine_tuning.job.checkpoint` object represents a model checkpoint for a
|
||||
* fine-tuning job that is ready to use.
|
||||
*/
|
||||
export interface FineTuningJobCheckpoint {
|
||||
/**
|
||||
* The checkpoint identifier, which can be referenced in the API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the checkpoint was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The name of the fine-tuned checkpoint model that is created.
|
||||
*/
|
||||
fine_tuned_model_checkpoint: string;
|
||||
|
||||
/**
|
||||
* The name of the fine-tuning job that this checkpoint was created from.
|
||||
*/
|
||||
fine_tuning_job_id: string;
|
||||
|
||||
/**
|
||||
* Metrics at the step number during the fine-tuning job.
|
||||
*/
|
||||
metrics: FineTuningJobCheckpoint.Metrics;
|
||||
|
||||
/**
|
||||
* The object type, which is always "fine_tuning.job.checkpoint".
|
||||
*/
|
||||
object: 'fine_tuning.job.checkpoint';
|
||||
|
||||
/**
|
||||
* The step number that the checkpoint was created at.
|
||||
*/
|
||||
step_number: number;
|
||||
}
|
||||
|
||||
export namespace FineTuningJobCheckpoint {
|
||||
/**
|
||||
* Metrics at the step number during the fine-tuning job.
|
||||
*/
|
||||
export interface Metrics {
|
||||
full_valid_loss?: number;
|
||||
|
||||
full_valid_mean_token_accuracy?: number;
|
||||
|
||||
step?: number;
|
||||
|
||||
train_loss?: number;
|
||||
|
||||
train_mean_token_accuracy?: number;
|
||||
|
||||
valid_loss?: number;
|
||||
|
||||
valid_mean_token_accuracy?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface CheckpointListParams extends CursorPageParams {}
|
||||
|
||||
Checkpoints.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
|
||||
|
||||
export declare namespace Checkpoints {
|
||||
export {
|
||||
type FineTuningJobCheckpoint as FineTuningJobCheckpoint,
|
||||
FineTuningJobCheckpointsPage as FineTuningJobCheckpointsPage,
|
||||
type CheckpointListParams as CheckpointListParams,
|
||||
};
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
FineTuningJobCheckpointsPage,
|
||||
Checkpoints,
|
||||
type FineTuningJobCheckpoint,
|
||||
type CheckpointListParams,
|
||||
} from './checkpoints';
|
||||
export {
|
||||
FineTuningJobsPage,
|
||||
FineTuningJobEventsPage,
|
||||
Jobs,
|
||||
type FineTuningJob,
|
||||
type FineTuningJobEvent,
|
||||
type FineTuningJobIntegration,
|
||||
type FineTuningJobWandbIntegration,
|
||||
type FineTuningJobWandbIntegrationObject,
|
||||
type JobCreateParams,
|
||||
type JobListParams,
|
||||
type JobListEventsParams,
|
||||
} from './jobs';
|
||||
+646
@@ -0,0 +1,646 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../resource';
|
||||
import { isRequestOptions } from '../../../core';
|
||||
import * as Core from '../../../core';
|
||||
import * as MethodsAPI from '../methods';
|
||||
import * as CheckpointsAPI from './checkpoints';
|
||||
import {
|
||||
CheckpointListParams,
|
||||
Checkpoints,
|
||||
FineTuningJobCheckpoint,
|
||||
FineTuningJobCheckpointsPage,
|
||||
} from './checkpoints';
|
||||
import { CursorPage, type CursorPageParams } from '../../../pagination';
|
||||
|
||||
export class Jobs extends APIResource {
|
||||
checkpoints: CheckpointsAPI.Checkpoints = new CheckpointsAPI.Checkpoints(this._client);
|
||||
|
||||
/**
|
||||
* Creates a fine-tuning job which begins the process of creating a new model from
|
||||
* a given dataset.
|
||||
*
|
||||
* Response includes details of the enqueued job including job status and the name
|
||||
* of the fine-tuned models once complete.
|
||||
*
|
||||
* [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const fineTuningJob = await client.fineTuning.jobs.create({
|
||||
* model: 'gpt-4o-mini',
|
||||
* training_file: 'file-abc123',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
create(body: JobCreateParams, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
|
||||
return this._client.post('/fine_tuning/jobs', { body, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info about a fine-tuning job.
|
||||
*
|
||||
* [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const fineTuningJob = await client.fineTuning.jobs.retrieve(
|
||||
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
retrieve(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
|
||||
return this._client.get(`/fine_tuning/jobs/${fineTuningJobId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* List your organization's fine-tuning jobs
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Automatically fetches more pages as needed.
|
||||
* for await (const fineTuningJob of client.fineTuning.jobs.list()) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
list(
|
||||
query?: JobListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FineTuningJobsPage, FineTuningJob>;
|
||||
list(options?: Core.RequestOptions): Core.PagePromise<FineTuningJobsPage, FineTuningJob>;
|
||||
list(
|
||||
query: JobListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FineTuningJobsPage, FineTuningJob> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list({}, query);
|
||||
}
|
||||
return this._client.getAPIList('/fine_tuning/jobs', FineTuningJobsPage, { query, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately cancel a fine-tune job.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const fineTuningJob = await client.fineTuning.jobs.cancel(
|
||||
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
cancel(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
|
||||
return this._client.post(`/fine_tuning/jobs/${fineTuningJobId}/cancel`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status updates for a fine-tuning job.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Automatically fetches more pages as needed.
|
||||
* for await (const fineTuningJobEvent of client.fineTuning.jobs.listEvents(
|
||||
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
||||
* )) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
listEvents(
|
||||
fineTuningJobId: string,
|
||||
query?: JobListEventsParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FineTuningJobEventsPage, FineTuningJobEvent>;
|
||||
listEvents(
|
||||
fineTuningJobId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FineTuningJobEventsPage, FineTuningJobEvent>;
|
||||
listEvents(
|
||||
fineTuningJobId: string,
|
||||
query: JobListEventsParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FineTuningJobEventsPage, FineTuningJobEvent> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.listEvents(fineTuningJobId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/events`, FineTuningJobEventsPage, {
|
||||
query,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause a fine-tune job.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const fineTuningJob = await client.fineTuning.jobs.pause(
|
||||
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
pause(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
|
||||
return this._client.post(`/fine_tuning/jobs/${fineTuningJobId}/pause`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume a fine-tune job.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const fineTuningJob = await client.fineTuning.jobs.resume(
|
||||
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
resume(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
|
||||
return this._client.post(`/fine_tuning/jobs/${fineTuningJobId}/resume`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class FineTuningJobsPage extends CursorPage<FineTuningJob> {}
|
||||
|
||||
export class FineTuningJobEventsPage extends CursorPage<FineTuningJobEvent> {}
|
||||
|
||||
/**
|
||||
* The `fine_tuning.job` object represents a fine-tuning job that has been created
|
||||
* through the API.
|
||||
*/
|
||||
export interface FineTuningJob {
|
||||
/**
|
||||
* The object identifier, which can be referenced in the API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the fine-tuning job was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* For fine-tuning jobs that have `failed`, this will contain more information on
|
||||
* the cause of the failure.
|
||||
*/
|
||||
error: FineTuningJob.Error | null;
|
||||
|
||||
/**
|
||||
* The name of the fine-tuned model that is being created. The value will be null
|
||||
* if the fine-tuning job is still running.
|
||||
*/
|
||||
fine_tuned_model: string | null;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the fine-tuning job was finished. The
|
||||
* value will be null if the fine-tuning job is still running.
|
||||
*/
|
||||
finished_at: number | null;
|
||||
|
||||
/**
|
||||
* The hyperparameters used for the fine-tuning job. This value will only be
|
||||
* returned when running `supervised` jobs.
|
||||
*/
|
||||
hyperparameters: FineTuningJob.Hyperparameters;
|
||||
|
||||
/**
|
||||
* The base model that is being fine-tuned.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always "fine_tuning.job".
|
||||
*/
|
||||
object: 'fine_tuning.job';
|
||||
|
||||
/**
|
||||
* The organization that owns the fine-tuning job.
|
||||
*/
|
||||
organization_id: string;
|
||||
|
||||
/**
|
||||
* The compiled results file ID(s) for the fine-tuning job. You can retrieve the
|
||||
* results with the
|
||||
* [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
|
||||
*/
|
||||
result_files: Array<string>;
|
||||
|
||||
/**
|
||||
* The seed used for the fine-tuning job.
|
||||
*/
|
||||
seed: number;
|
||||
|
||||
/**
|
||||
* The current status of the fine-tuning job, which can be either
|
||||
* `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
|
||||
*/
|
||||
status: 'validating_files' | 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
||||
|
||||
/**
|
||||
* The total number of billable tokens processed by this fine-tuning job. The value
|
||||
* will be null if the fine-tuning job is still running.
|
||||
*/
|
||||
trained_tokens: number | null;
|
||||
|
||||
/**
|
||||
* The file ID used for training. You can retrieve the training data with the
|
||||
* [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
|
||||
*/
|
||||
training_file: string;
|
||||
|
||||
/**
|
||||
* The file ID used for validation. You can retrieve the validation results with
|
||||
* the
|
||||
* [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
|
||||
*/
|
||||
validation_file: string | null;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the fine-tuning job is estimated to
|
||||
* finish. The value will be null if the fine-tuning job is not running.
|
||||
*/
|
||||
estimated_finish?: number | null;
|
||||
|
||||
/**
|
||||
* A list of integrations to enable for this fine-tuning job.
|
||||
*/
|
||||
integrations?: Array<FineTuningJobWandbIntegrationObject> | null;
|
||||
|
||||
/**
|
||||
* The method used for fine-tuning.
|
||||
*/
|
||||
method?: FineTuningJob.Method;
|
||||
}
|
||||
|
||||
export namespace FineTuningJob {
|
||||
/**
|
||||
* For fine-tuning jobs that have `failed`, this will contain more information on
|
||||
* the cause of the failure.
|
||||
*/
|
||||
export interface Error {
|
||||
/**
|
||||
* A machine-readable error code.
|
||||
*/
|
||||
code: string;
|
||||
|
||||
/**
|
||||
* A human-readable error message.
|
||||
*/
|
||||
message: string;
|
||||
|
||||
/**
|
||||
* The parameter that was invalid, usually `training_file` or `validation_file`.
|
||||
* This field will be null if the failure was not parameter-specific.
|
||||
*/
|
||||
param: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hyperparameters used for the fine-tuning job. This value will only be
|
||||
* returned when running `supervised` jobs.
|
||||
*/
|
||||
export interface Hyperparameters {
|
||||
/**
|
||||
* Number of examples in each batch. A larger batch size means that model
|
||||
* parameters are updated less frequently, but with lower variance.
|
||||
*/
|
||||
batch_size?: unknown | 'auto' | number | null;
|
||||
|
||||
/**
|
||||
* Scaling factor for the learning rate. A smaller learning rate may be useful to
|
||||
* avoid overfitting.
|
||||
*/
|
||||
learning_rate_multiplier?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* The number of epochs to train the model for. An epoch refers to one full cycle
|
||||
* through the training dataset.
|
||||
*/
|
||||
n_epochs?: 'auto' | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method used for fine-tuning.
|
||||
*/
|
||||
export interface Method {
|
||||
/**
|
||||
* The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
|
||||
*/
|
||||
type: 'supervised' | 'dpo' | 'reinforcement';
|
||||
|
||||
/**
|
||||
* Configuration for the DPO fine-tuning method.
|
||||
*/
|
||||
dpo?: MethodsAPI.DpoMethod;
|
||||
|
||||
/**
|
||||
* Configuration for the reinforcement fine-tuning method.
|
||||
*/
|
||||
reinforcement?: MethodsAPI.ReinforcementMethod;
|
||||
|
||||
/**
|
||||
* Configuration for the supervised fine-tuning method.
|
||||
*/
|
||||
supervised?: MethodsAPI.SupervisedMethod;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fine-tuning job event object
|
||||
*/
|
||||
export interface FineTuningJobEvent {
|
||||
/**
|
||||
* The object identifier.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the fine-tuning job was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The log level of the event.
|
||||
*/
|
||||
level: 'info' | 'warn' | 'error';
|
||||
|
||||
/**
|
||||
* The message of the event.
|
||||
*/
|
||||
message: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always "fine_tuning.job.event".
|
||||
*/
|
||||
object: 'fine_tuning.job.event';
|
||||
|
||||
/**
|
||||
* The data associated with the event.
|
||||
*/
|
||||
data?: unknown;
|
||||
|
||||
/**
|
||||
* The type of event.
|
||||
*/
|
||||
type?: 'message' | 'metrics';
|
||||
}
|
||||
|
||||
export type FineTuningJobIntegration = FineTuningJobWandbIntegrationObject;
|
||||
|
||||
/**
|
||||
* The settings for your integration with Weights and Biases. This payload
|
||||
* specifies the project that metrics will be sent to. Optionally, you can set an
|
||||
* explicit display name for your run, add tags to your run, and set a default
|
||||
* entity (team, username, etc) to be associated with your run.
|
||||
*/
|
||||
export interface FineTuningJobWandbIntegration {
|
||||
/**
|
||||
* The name of the project that the new run will be created under.
|
||||
*/
|
||||
project: string;
|
||||
|
||||
/**
|
||||
* The entity to use for the run. This allows you to set the team or username of
|
||||
* the WandB user that you would like associated with the run. If not set, the
|
||||
* default entity for the registered WandB API key is used.
|
||||
*/
|
||||
entity?: string | null;
|
||||
|
||||
/**
|
||||
* A display name to set for the run. If not set, we will use the Job ID as the
|
||||
* name.
|
||||
*/
|
||||
name?: string | null;
|
||||
|
||||
/**
|
||||
* A list of tags to be attached to the newly created run. These tags are passed
|
||||
* through directly to WandB. Some default tags are generated by OpenAI:
|
||||
* "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".
|
||||
*/
|
||||
tags?: Array<string>;
|
||||
}
|
||||
|
||||
export interface FineTuningJobWandbIntegrationObject {
|
||||
/**
|
||||
* The type of the integration being enabled for the fine-tuning job
|
||||
*/
|
||||
type: 'wandb';
|
||||
|
||||
/**
|
||||
* The settings for your integration with Weights and Biases. This payload
|
||||
* specifies the project that metrics will be sent to. Optionally, you can set an
|
||||
* explicit display name for your run, add tags to your run, and set a default
|
||||
* entity (team, username, etc) to be associated with your run.
|
||||
*/
|
||||
wandb: FineTuningJobWandbIntegration;
|
||||
}
|
||||
|
||||
export interface JobCreateParams {
|
||||
/**
|
||||
* The name of the model to fine-tune. You can select one of the
|
||||
* [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
|
||||
*/
|
||||
model: (string & {}) | 'babbage-002' | 'davinci-002' | 'gpt-3.5-turbo' | 'gpt-4o-mini';
|
||||
|
||||
/**
|
||||
* The ID of an uploaded file that contains training data.
|
||||
*
|
||||
* See [upload file](https://platform.openai.com/docs/api-reference/files/create)
|
||||
* for how to upload a file.
|
||||
*
|
||||
* Your dataset must be formatted as a JSONL file. Additionally, you must upload
|
||||
* your file with the purpose `fine-tune`.
|
||||
*
|
||||
* The contents of the file should differ depending on if the model uses the
|
||||
* [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input),
|
||||
* [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
|
||||
* format, or if the fine-tuning method uses the
|
||||
* [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
|
||||
* format.
|
||||
*
|
||||
* See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
|
||||
* for more details.
|
||||
*/
|
||||
training_file: string;
|
||||
|
||||
/**
|
||||
* @deprecated The hyperparameters used for the fine-tuning job. This value is now
|
||||
* deprecated in favor of `method`, and should be passed in under the `method`
|
||||
* parameter.
|
||||
*/
|
||||
hyperparameters?: JobCreateParams.Hyperparameters;
|
||||
|
||||
/**
|
||||
* A list of integrations to enable for your fine-tuning job.
|
||||
*/
|
||||
integrations?: Array<JobCreateParams.Integration> | null;
|
||||
|
||||
/**
|
||||
* The method used for fine-tuning.
|
||||
*/
|
||||
method?: JobCreateParams.Method;
|
||||
|
||||
/**
|
||||
* The seed controls the reproducibility of the job. Passing in the same seed and
|
||||
* job parameters should produce the same results, but may differ in rare cases. If
|
||||
* a seed is not specified, one will be generated for you.
|
||||
*/
|
||||
seed?: number | null;
|
||||
|
||||
/**
|
||||
* A string of up to 64 characters that will be added to your fine-tuned model
|
||||
* name.
|
||||
*
|
||||
* For example, a `suffix` of "custom-model-name" would produce a model name like
|
||||
* `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`.
|
||||
*/
|
||||
suffix?: string | null;
|
||||
|
||||
/**
|
||||
* The ID of an uploaded file that contains validation data.
|
||||
*
|
||||
* If you provide this file, the data is used to generate validation metrics
|
||||
* periodically during fine-tuning. These metrics can be viewed in the fine-tuning
|
||||
* results file. The same data should not be present in both train and validation
|
||||
* files.
|
||||
*
|
||||
* Your dataset must be formatted as a JSONL file. You must upload your file with
|
||||
* the purpose `fine-tune`.
|
||||
*
|
||||
* See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
|
||||
* for more details.
|
||||
*/
|
||||
validation_file?: string | null;
|
||||
}
|
||||
|
||||
export namespace JobCreateParams {
|
||||
/**
|
||||
* @deprecated The hyperparameters used for the fine-tuning job. This value is now
|
||||
* deprecated in favor of `method`, and should be passed in under the `method`
|
||||
* parameter.
|
||||
*/
|
||||
export interface Hyperparameters {
|
||||
/**
|
||||
* Number of examples in each batch. A larger batch size means that model
|
||||
* parameters are updated less frequently, but with lower variance.
|
||||
*/
|
||||
batch_size?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* Scaling factor for the learning rate. A smaller learning rate may be useful to
|
||||
* avoid overfitting.
|
||||
*/
|
||||
learning_rate_multiplier?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* The number of epochs to train the model for. An epoch refers to one full cycle
|
||||
* through the training dataset.
|
||||
*/
|
||||
n_epochs?: 'auto' | number;
|
||||
}
|
||||
|
||||
export interface Integration {
|
||||
/**
|
||||
* The type of integration to enable. Currently, only "wandb" (Weights and Biases)
|
||||
* is supported.
|
||||
*/
|
||||
type: 'wandb';
|
||||
|
||||
/**
|
||||
* The settings for your integration with Weights and Biases. This payload
|
||||
* specifies the project that metrics will be sent to. Optionally, you can set an
|
||||
* explicit display name for your run, add tags to your run, and set a default
|
||||
* entity (team, username, etc) to be associated with your run.
|
||||
*/
|
||||
wandb: Integration.Wandb;
|
||||
}
|
||||
|
||||
export namespace Integration {
|
||||
/**
|
||||
* The settings for your integration with Weights and Biases. This payload
|
||||
* specifies the project that metrics will be sent to. Optionally, you can set an
|
||||
* explicit display name for your run, add tags to your run, and set a default
|
||||
* entity (team, username, etc) to be associated with your run.
|
||||
*/
|
||||
export interface Wandb {
|
||||
/**
|
||||
* The name of the project that the new run will be created under.
|
||||
*/
|
||||
project: string;
|
||||
|
||||
/**
|
||||
* The entity to use for the run. This allows you to set the team or username of
|
||||
* the WandB user that you would like associated with the run. If not set, the
|
||||
* default entity for the registered WandB API key is used.
|
||||
*/
|
||||
entity?: string | null;
|
||||
|
||||
/**
|
||||
* A display name to set for the run. If not set, we will use the Job ID as the
|
||||
* name.
|
||||
*/
|
||||
name?: string | null;
|
||||
|
||||
/**
|
||||
* A list of tags to be attached to the newly created run. These tags are passed
|
||||
* through directly to WandB. Some default tags are generated by OpenAI:
|
||||
* "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".
|
||||
*/
|
||||
tags?: Array<string>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method used for fine-tuning.
|
||||
*/
|
||||
export interface Method {
|
||||
/**
|
||||
* The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
|
||||
*/
|
||||
type: 'supervised' | 'dpo' | 'reinforcement';
|
||||
|
||||
/**
|
||||
* Configuration for the DPO fine-tuning method.
|
||||
*/
|
||||
dpo?: MethodsAPI.DpoMethod;
|
||||
|
||||
/**
|
||||
* Configuration for the reinforcement fine-tuning method.
|
||||
*/
|
||||
reinforcement?: MethodsAPI.ReinforcementMethod;
|
||||
|
||||
/**
|
||||
* Configuration for the supervised fine-tuning method.
|
||||
*/
|
||||
supervised?: MethodsAPI.SupervisedMethod;
|
||||
}
|
||||
}
|
||||
|
||||
export interface JobListParams extends CursorPageParams {}
|
||||
|
||||
export interface JobListEventsParams extends CursorPageParams {}
|
||||
|
||||
Jobs.FineTuningJobsPage = FineTuningJobsPage;
|
||||
Jobs.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
||||
Jobs.Checkpoints = Checkpoints;
|
||||
Jobs.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
|
||||
|
||||
export declare namespace Jobs {
|
||||
export {
|
||||
type FineTuningJob as FineTuningJob,
|
||||
type FineTuningJobEvent as FineTuningJobEvent,
|
||||
type FineTuningJobIntegration as FineTuningJobIntegration,
|
||||
type FineTuningJobWandbIntegration as FineTuningJobWandbIntegration,
|
||||
type FineTuningJobWandbIntegrationObject as FineTuningJobWandbIntegrationObject,
|
||||
FineTuningJobsPage as FineTuningJobsPage,
|
||||
FineTuningJobEventsPage as FineTuningJobEventsPage,
|
||||
type JobCreateParams as JobCreateParams,
|
||||
type JobListParams as JobListParams,
|
||||
type JobListEventsParams as JobListEventsParams,
|
||||
};
|
||||
|
||||
export {
|
||||
Checkpoints as Checkpoints,
|
||||
type FineTuningJobCheckpoint as FineTuningJobCheckpoint,
|
||||
FineTuningJobCheckpointsPage as FineTuningJobCheckpointsPage,
|
||||
type CheckpointListParams as CheckpointListParams,
|
||||
};
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as GraderModelsAPI from '../graders/grader-models';
|
||||
|
||||
export class Methods extends APIResource {}
|
||||
|
||||
/**
|
||||
* The hyperparameters used for the DPO fine-tuning job.
|
||||
*/
|
||||
export interface DpoHyperparameters {
|
||||
/**
|
||||
* Number of examples in each batch. A larger batch size means that model
|
||||
* parameters are updated less frequently, but with lower variance.
|
||||
*/
|
||||
batch_size?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* The beta value for the DPO method. A higher beta value will increase the weight
|
||||
* of the penalty between the policy and reference model.
|
||||
*/
|
||||
beta?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* Scaling factor for the learning rate. A smaller learning rate may be useful to
|
||||
* avoid overfitting.
|
||||
*/
|
||||
learning_rate_multiplier?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* The number of epochs to train the model for. An epoch refers to one full cycle
|
||||
* through the training dataset.
|
||||
*/
|
||||
n_epochs?: 'auto' | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for the DPO fine-tuning method.
|
||||
*/
|
||||
export interface DpoMethod {
|
||||
/**
|
||||
* The hyperparameters used for the DPO fine-tuning job.
|
||||
*/
|
||||
hyperparameters?: DpoHyperparameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hyperparameters used for the reinforcement fine-tuning job.
|
||||
*/
|
||||
export interface ReinforcementHyperparameters {
|
||||
/**
|
||||
* Number of examples in each batch. A larger batch size means that model
|
||||
* parameters are updated less frequently, but with lower variance.
|
||||
*/
|
||||
batch_size?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* Multiplier on amount of compute used for exploring search space during training.
|
||||
*/
|
||||
compute_multiplier?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* The number of training steps between evaluation runs.
|
||||
*/
|
||||
eval_interval?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* Number of evaluation samples to generate per training step.
|
||||
*/
|
||||
eval_samples?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* Scaling factor for the learning rate. A smaller learning rate may be useful to
|
||||
* avoid overfitting.
|
||||
*/
|
||||
learning_rate_multiplier?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* The number of epochs to train the model for. An epoch refers to one full cycle
|
||||
* through the training dataset.
|
||||
*/
|
||||
n_epochs?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* Level of reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: 'default' | 'low' | 'medium' | 'high';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for the reinforcement fine-tuning method.
|
||||
*/
|
||||
export interface ReinforcementMethod {
|
||||
/**
|
||||
* The grader used for the fine-tuning job.
|
||||
*/
|
||||
grader:
|
||||
| GraderModelsAPI.StringCheckGrader
|
||||
| GraderModelsAPI.TextSimilarityGrader
|
||||
| GraderModelsAPI.PythonGrader
|
||||
| GraderModelsAPI.ScoreModelGrader
|
||||
| GraderModelsAPI.MultiGrader;
|
||||
|
||||
/**
|
||||
* The hyperparameters used for the reinforcement fine-tuning job.
|
||||
*/
|
||||
hyperparameters?: ReinforcementHyperparameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hyperparameters used for the fine-tuning job.
|
||||
*/
|
||||
export interface SupervisedHyperparameters {
|
||||
/**
|
||||
* Number of examples in each batch. A larger batch size means that model
|
||||
* parameters are updated less frequently, but with lower variance.
|
||||
*/
|
||||
batch_size?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* Scaling factor for the learning rate. A smaller learning rate may be useful to
|
||||
* avoid overfitting.
|
||||
*/
|
||||
learning_rate_multiplier?: 'auto' | number;
|
||||
|
||||
/**
|
||||
* The number of epochs to train the model for. An epoch refers to one full cycle
|
||||
* through the training dataset.
|
||||
*/
|
||||
n_epochs?: 'auto' | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for the supervised fine-tuning method.
|
||||
*/
|
||||
export interface SupervisedMethod {
|
||||
/**
|
||||
* The hyperparameters used for the fine-tuning job.
|
||||
*/
|
||||
hyperparameters?: SupervisedHyperparameters;
|
||||
}
|
||||
|
||||
export declare namespace Methods {
|
||||
export {
|
||||
type DpoHyperparameters as DpoHyperparameters,
|
||||
type DpoMethod as DpoMethod,
|
||||
type ReinforcementHyperparameters as ReinforcementHyperparameters,
|
||||
type ReinforcementMethod as ReinforcementMethod,
|
||||
type SupervisedHyperparameters as SupervisedHyperparameters,
|
||||
type SupervisedMethod as SupervisedMethod,
|
||||
};
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './graders/index';
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as ResponsesAPI from '../responses/responses';
|
||||
|
||||
export class GraderModels extends APIResource {}
|
||||
|
||||
/**
|
||||
* A LabelModelGrader object which uses a model to assign labels to each item in
|
||||
* the evaluation.
|
||||
*/
|
||||
export interface LabelModelGrader {
|
||||
input: Array<LabelModelGrader.Input>;
|
||||
|
||||
/**
|
||||
* The labels to assign to each item in the evaluation.
|
||||
*/
|
||||
labels: Array<string>;
|
||||
|
||||
/**
|
||||
* The model to use for the evaluation. Must support structured outputs.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The labels that indicate a passing result. Must be a subset of labels.
|
||||
*/
|
||||
passing_labels: Array<string>;
|
||||
|
||||
/**
|
||||
* The object type, which is always `label_model`.
|
||||
*/
|
||||
type: 'label_model';
|
||||
}
|
||||
|
||||
export namespace LabelModelGrader {
|
||||
/**
|
||||
* A message input to the model with a role indicating instruction following
|
||||
* hierarchy. Instructions given with the `developer` or `system` role take
|
||||
* precedence over instructions given with the `user` role. Messages with the
|
||||
* `assistant` role are presumed to have been generated by the model in previous
|
||||
* interactions.
|
||||
*/
|
||||
export interface Input {
|
||||
/**
|
||||
* Text inputs to the model - can contain template strings.
|
||||
*/
|
||||
content: string | ResponsesAPI.ResponseInputText | Input.OutputText;
|
||||
|
||||
/**
|
||||
* The role of the message input. One of `user`, `assistant`, `system`, or
|
||||
* `developer`.
|
||||
*/
|
||||
role: 'user' | 'assistant' | 'system' | 'developer';
|
||||
|
||||
/**
|
||||
* The type of the message input. Always `message`.
|
||||
*/
|
||||
type?: 'message';
|
||||
}
|
||||
|
||||
export namespace Input {
|
||||
/**
|
||||
* A text output from the model.
|
||||
*/
|
||||
export interface OutputText {
|
||||
/**
|
||||
* The text output from the model.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the output text. Always `output_text`.
|
||||
*/
|
||||
type: 'output_text';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A MultiGrader object combines the output of multiple graders to produce a single
|
||||
* score.
|
||||
*/
|
||||
export interface MultiGrader {
|
||||
/**
|
||||
* A formula to calculate the output based on grader results.
|
||||
*/
|
||||
calculate_output: string;
|
||||
|
||||
graders: Record<
|
||||
string,
|
||||
StringCheckGrader | TextSimilarityGrader | PythonGrader | ScoreModelGrader | LabelModelGrader
|
||||
>;
|
||||
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always `multi`.
|
||||
*/
|
||||
type: 'multi';
|
||||
}
|
||||
|
||||
/**
|
||||
* A PythonGrader object that runs a python script on the input.
|
||||
*/
|
||||
export interface PythonGrader {
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The source code of the python script.
|
||||
*/
|
||||
source: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always `python`.
|
||||
*/
|
||||
type: 'python';
|
||||
|
||||
/**
|
||||
* The image tag to use for the python script.
|
||||
*/
|
||||
image_tag?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ScoreModelGrader object that uses a model to assign a score to the input.
|
||||
*/
|
||||
export interface ScoreModelGrader {
|
||||
/**
|
||||
* The input text. This may include template strings.
|
||||
*/
|
||||
input: Array<ScoreModelGrader.Input>;
|
||||
|
||||
/**
|
||||
* The model to use for the evaluation.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always `score_model`.
|
||||
*/
|
||||
type: 'score_model';
|
||||
|
||||
/**
|
||||
* The range of the score. Defaults to `[0, 1]`.
|
||||
*/
|
||||
range?: Array<number>;
|
||||
|
||||
/**
|
||||
* The sampling parameters for the model.
|
||||
*/
|
||||
sampling_params?: unknown;
|
||||
}
|
||||
|
||||
export namespace ScoreModelGrader {
|
||||
/**
|
||||
* A message input to the model with a role indicating instruction following
|
||||
* hierarchy. Instructions given with the `developer` or `system` role take
|
||||
* precedence over instructions given with the `user` role. Messages with the
|
||||
* `assistant` role are presumed to have been generated by the model in previous
|
||||
* interactions.
|
||||
*/
|
||||
export interface Input {
|
||||
/**
|
||||
* Text inputs to the model - can contain template strings.
|
||||
*/
|
||||
content: string | ResponsesAPI.ResponseInputText | Input.OutputText;
|
||||
|
||||
/**
|
||||
* The role of the message input. One of `user`, `assistant`, `system`, or
|
||||
* `developer`.
|
||||
*/
|
||||
role: 'user' | 'assistant' | 'system' | 'developer';
|
||||
|
||||
/**
|
||||
* The type of the message input. Always `message`.
|
||||
*/
|
||||
type?: 'message';
|
||||
}
|
||||
|
||||
export namespace Input {
|
||||
/**
|
||||
* A text output from the model.
|
||||
*/
|
||||
export interface OutputText {
|
||||
/**
|
||||
* The text output from the model.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the output text. Always `output_text`.
|
||||
*/
|
||||
type: 'output_text';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A StringCheckGrader object that performs a string comparison between input and
|
||||
* reference using a specified operation.
|
||||
*/
|
||||
export interface StringCheckGrader {
|
||||
/**
|
||||
* The input text. This may include template strings.
|
||||
*/
|
||||
input: string;
|
||||
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
|
||||
*/
|
||||
operation: 'eq' | 'ne' | 'like' | 'ilike';
|
||||
|
||||
/**
|
||||
* The reference text. This may include template strings.
|
||||
*/
|
||||
reference: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always `string_check`.
|
||||
*/
|
||||
type: 'string_check';
|
||||
}
|
||||
|
||||
/**
|
||||
* A TextSimilarityGrader object which grades text based on similarity metrics.
|
||||
*/
|
||||
export interface TextSimilarityGrader {
|
||||
/**
|
||||
* The evaluation metric to use. One of `fuzzy_match`, `bleu`, `gleu`, `meteor`,
|
||||
* `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, or `rouge_l`.
|
||||
*/
|
||||
evaluation_metric:
|
||||
| 'fuzzy_match'
|
||||
| 'bleu'
|
||||
| 'gleu'
|
||||
| 'meteor'
|
||||
| 'rouge_1'
|
||||
| 'rouge_2'
|
||||
| 'rouge_3'
|
||||
| 'rouge_4'
|
||||
| 'rouge_5'
|
||||
| 'rouge_l';
|
||||
|
||||
/**
|
||||
* The text being graded.
|
||||
*/
|
||||
input: string;
|
||||
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The text being graded against.
|
||||
*/
|
||||
reference: string;
|
||||
|
||||
/**
|
||||
* The type of grader.
|
||||
*/
|
||||
type: 'text_similarity';
|
||||
}
|
||||
|
||||
export declare namespace GraderModels {
|
||||
export {
|
||||
type LabelModelGrader as LabelModelGrader,
|
||||
type MultiGrader as MultiGrader,
|
||||
type PythonGrader as PythonGrader,
|
||||
type ScoreModelGrader as ScoreModelGrader,
|
||||
type StringCheckGrader as StringCheckGrader,
|
||||
type TextSimilarityGrader as TextSimilarityGrader,
|
||||
};
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as GraderModelsAPI from './grader-models';
|
||||
import {
|
||||
GraderModels,
|
||||
LabelModelGrader,
|
||||
MultiGrader,
|
||||
PythonGrader,
|
||||
ScoreModelGrader,
|
||||
StringCheckGrader,
|
||||
TextSimilarityGrader,
|
||||
} from './grader-models';
|
||||
|
||||
export class Graders extends APIResource {
|
||||
graderModels: GraderModelsAPI.GraderModels = new GraderModelsAPI.GraderModels(this._client);
|
||||
}
|
||||
|
||||
Graders.GraderModels = GraderModels;
|
||||
|
||||
export declare namespace Graders {
|
||||
export {
|
||||
GraderModels as GraderModels,
|
||||
type LabelModelGrader as LabelModelGrader,
|
||||
type MultiGrader as MultiGrader,
|
||||
type PythonGrader as PythonGrader,
|
||||
type ScoreModelGrader as ScoreModelGrader,
|
||||
type StringCheckGrader as StringCheckGrader,
|
||||
type TextSimilarityGrader as TextSimilarityGrader,
|
||||
};
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
GraderModels,
|
||||
type LabelModelGrader,
|
||||
type MultiGrader,
|
||||
type PythonGrader,
|
||||
type ScoreModelGrader,
|
||||
type StringCheckGrader,
|
||||
type TextSimilarityGrader,
|
||||
} from './grader-models';
|
||||
export { Graders } from './graders';
|
||||
+376
@@ -0,0 +1,376 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../resource';
|
||||
import * as Core from '../core';
|
||||
|
||||
export class Images extends APIResource {
|
||||
/**
|
||||
* Creates a variation of a given image. This endpoint only supports `dall-e-2`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const imagesResponse = await client.images.createVariation({
|
||||
* image: fs.createReadStream('otter.png'),
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
createVariation(
|
||||
body: ImageCreateVariationParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<ImagesResponse> {
|
||||
return this._client.post('/images/variations', Core.multipartFormRequestOptions({ body, ...options }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an edited or extended image given one or more source images and a
|
||||
* prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const imagesResponse = await client.images.edit({
|
||||
* image: fs.createReadStream('path/to/file'),
|
||||
* prompt: 'A cute baby sea otter wearing a beret',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
edit(body: ImageEditParams, options?: Core.RequestOptions): Core.APIPromise<ImagesResponse> {
|
||||
return this._client.post('/images/edits', Core.multipartFormRequestOptions({ body, ...options }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an image given a prompt.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/images).
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const imagesResponse = await client.images.generate({
|
||||
* prompt: 'A cute baby sea otter',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
generate(body: ImageGenerateParams, options?: Core.RequestOptions): Core.APIPromise<ImagesResponse> {
|
||||
return this._client.post('/images/generations', { body, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the content or the URL of an image generated by the OpenAI API.
|
||||
*/
|
||||
export interface Image {
|
||||
/**
|
||||
* The base64-encoded JSON of the generated image. Default value for `gpt-image-1`,
|
||||
* and only present if `response_format` is set to `b64_json` for `dall-e-2` and
|
||||
* `dall-e-3`.
|
||||
*/
|
||||
b64_json?: string;
|
||||
|
||||
/**
|
||||
* For `dall-e-3` only, the revised prompt that was used to generate the image.
|
||||
*/
|
||||
revised_prompt?: string;
|
||||
|
||||
/**
|
||||
* When using `dall-e-2` or `dall-e-3`, the URL of the generated image if
|
||||
* `response_format` is set to `url` (default value). Unsupported for
|
||||
* `gpt-image-1`.
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export type ImageModel = 'dall-e-2' | 'dall-e-3' | 'gpt-image-1';
|
||||
|
||||
/**
|
||||
* The response from the image generation endpoint.
|
||||
*/
|
||||
export interface ImagesResponse {
|
||||
/**
|
||||
* The Unix timestamp (in seconds) of when the image was created.
|
||||
*/
|
||||
created: number;
|
||||
|
||||
/**
|
||||
* The list of generated images.
|
||||
*/
|
||||
data?: Array<Image>;
|
||||
|
||||
/**
|
||||
* For `gpt-image-1` only, the token usage information for the image generation.
|
||||
*/
|
||||
usage?: ImagesResponse.Usage;
|
||||
}
|
||||
|
||||
export namespace ImagesResponse {
|
||||
/**
|
||||
* For `gpt-image-1` only, the token usage information for the image generation.
|
||||
*/
|
||||
export interface Usage {
|
||||
/**
|
||||
* The number of tokens (images and text) in the input prompt.
|
||||
*/
|
||||
input_tokens: number;
|
||||
|
||||
/**
|
||||
* The input tokens detailed information for the image generation.
|
||||
*/
|
||||
input_tokens_details: Usage.InputTokensDetails;
|
||||
|
||||
/**
|
||||
* The number of image tokens in the output image.
|
||||
*/
|
||||
output_tokens: number;
|
||||
|
||||
/**
|
||||
* The total number of tokens (images and text) used for the image generation.
|
||||
*/
|
||||
total_tokens: number;
|
||||
}
|
||||
|
||||
export namespace Usage {
|
||||
/**
|
||||
* The input tokens detailed information for the image generation.
|
||||
*/
|
||||
export interface InputTokensDetails {
|
||||
/**
|
||||
* The number of image tokens in the input prompt.
|
||||
*/
|
||||
image_tokens: number;
|
||||
|
||||
/**
|
||||
* The number of text tokens in the input prompt.
|
||||
*/
|
||||
text_tokens: number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ImageCreateVariationParams {
|
||||
/**
|
||||
* The image to use as the basis for the variation(s). Must be a valid PNG file,
|
||||
* less than 4MB, and square.
|
||||
*/
|
||||
image: Core.Uploadable;
|
||||
|
||||
/**
|
||||
* The model to use for image generation. Only `dall-e-2` is supported at this
|
||||
* time.
|
||||
*/
|
||||
model?: (string & {}) | ImageModel | null;
|
||||
|
||||
/**
|
||||
* The number of images to generate. Must be between 1 and 10.
|
||||
*/
|
||||
n?: number | null;
|
||||
|
||||
/**
|
||||
* The format in which the generated images are returned. Must be one of `url` or
|
||||
* `b64_json`. URLs are only valid for 60 minutes after the image has been
|
||||
* generated.
|
||||
*/
|
||||
response_format?: 'url' | 'b64_json' | null;
|
||||
|
||||
/**
|
||||
* The size of the generated images. Must be one of `256x256`, `512x512`, or
|
||||
* `1024x1024`.
|
||||
*/
|
||||
size?: '256x256' | '512x512' | '1024x1024' | null;
|
||||
|
||||
/**
|
||||
* A unique identifier representing your end-user, which can help OpenAI to monitor
|
||||
* and detect abuse.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
|
||||
*/
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export interface ImageEditParams {
|
||||
/**
|
||||
* The image(s) to edit. Must be a supported image file or an array of images.
|
||||
*
|
||||
* For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
|
||||
* 25MB. You can provide up to 16 images.
|
||||
*
|
||||
* For `dall-e-2`, you can only provide one image, and it should be a square `png`
|
||||
* file less than 4MB.
|
||||
*/
|
||||
image: Core.Uploadable | Array<Core.Uploadable>;
|
||||
|
||||
/**
|
||||
* A text description of the desired image(s). The maximum length is 1000
|
||||
* characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.
|
||||
*/
|
||||
prompt: string;
|
||||
|
||||
/**
|
||||
* Allows to set transparency for the background of the generated image(s). This
|
||||
* parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
|
||||
* `opaque` or `auto` (default value). When `auto` is used, the model will
|
||||
* automatically determine the best background for the image.
|
||||
*
|
||||
* If `transparent`, the output format needs to support transparency, so it should
|
||||
* be set to either `png` (default value) or `webp`.
|
||||
*/
|
||||
background?: 'transparent' | 'opaque' | 'auto' | null;
|
||||
|
||||
/**
|
||||
* An additional image whose fully transparent areas (e.g. where alpha is zero)
|
||||
* indicate where `image` should be edited. If there are multiple images provided,
|
||||
* the mask will be applied on the first image. Must be a valid PNG file, less than
|
||||
* 4MB, and have the same dimensions as `image`.
|
||||
*/
|
||||
mask?: Core.Uploadable;
|
||||
|
||||
/**
|
||||
* The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are
|
||||
* supported. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1`
|
||||
* is used.
|
||||
*/
|
||||
model?: (string & {}) | ImageModel | null;
|
||||
|
||||
/**
|
||||
* The number of images to generate. Must be between 1 and 10.
|
||||
*/
|
||||
n?: number | null;
|
||||
|
||||
/**
|
||||
* The quality of the image that will be generated. `high`, `medium` and `low` are
|
||||
* only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
|
||||
* Defaults to `auto`.
|
||||
*/
|
||||
quality?: 'standard' | 'low' | 'medium' | 'high' | 'auto' | null;
|
||||
|
||||
/**
|
||||
* The format in which the generated images are returned. Must be one of `url` or
|
||||
* `b64_json`. URLs are only valid for 60 minutes after the image has been
|
||||
* generated. This parameter is only supported for `dall-e-2`, as `gpt-image-1`
|
||||
* will always return base64-encoded images.
|
||||
*/
|
||||
response_format?: 'url' | 'b64_json' | null;
|
||||
|
||||
/**
|
||||
* The size of the generated images. Must be one of `1024x1024`, `1536x1024`
|
||||
* (landscape), `1024x1536` (portrait), or `auto` (default value) for
|
||||
* `gpt-image-1`, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.
|
||||
*/
|
||||
size?: '256x256' | '512x512' | '1024x1024' | '1536x1024' | '1024x1536' | 'auto' | null;
|
||||
|
||||
/**
|
||||
* A unique identifier representing your end-user, which can help OpenAI to monitor
|
||||
* and detect abuse.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
|
||||
*/
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export interface ImageGenerateParams {
|
||||
/**
|
||||
* A text description of the desired image(s). The maximum length is 32000
|
||||
* characters for `gpt-image-1`, 1000 characters for `dall-e-2` and 4000 characters
|
||||
* for `dall-e-3`.
|
||||
*/
|
||||
prompt: string;
|
||||
|
||||
/**
|
||||
* Allows to set transparency for the background of the generated image(s). This
|
||||
* parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
|
||||
* `opaque` or `auto` (default value). When `auto` is used, the model will
|
||||
* automatically determine the best background for the image.
|
||||
*
|
||||
* If `transparent`, the output format needs to support transparency, so it should
|
||||
* be set to either `png` (default value) or `webp`.
|
||||
*/
|
||||
background?: 'transparent' | 'opaque' | 'auto' | null;
|
||||
|
||||
/**
|
||||
* The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or
|
||||
* `gpt-image-1`. Defaults to `dall-e-2` unless a parameter specific to
|
||||
* `gpt-image-1` is used.
|
||||
*/
|
||||
model?: (string & {}) | ImageModel | null;
|
||||
|
||||
/**
|
||||
* Control the content-moderation level for images generated by `gpt-image-1`. Must
|
||||
* be either `low` for less restrictive filtering or `auto` (default value).
|
||||
*/
|
||||
moderation?: 'low' | 'auto' | null;
|
||||
|
||||
/**
|
||||
* The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
|
||||
* `n=1` is supported.
|
||||
*/
|
||||
n?: number | null;
|
||||
|
||||
/**
|
||||
* The compression level (0-100%) for the generated images. This parameter is only
|
||||
* supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
|
||||
* defaults to 100.
|
||||
*/
|
||||
output_compression?: number | null;
|
||||
|
||||
/**
|
||||
* The format in which the generated images are returned. This parameter is only
|
||||
* supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`.
|
||||
*/
|
||||
output_format?: 'png' | 'jpeg' | 'webp' | null;
|
||||
|
||||
/**
|
||||
* The quality of the image that will be generated.
|
||||
*
|
||||
* - `auto` (default value) will automatically select the best quality for the
|
||||
* given model.
|
||||
* - `high`, `medium` and `low` are supported for `gpt-image-1`.
|
||||
* - `hd` and `standard` are supported for `dall-e-3`.
|
||||
* - `standard` is the only option for `dall-e-2`.
|
||||
*/
|
||||
quality?: 'standard' | 'hd' | 'low' | 'medium' | 'high' | 'auto' | null;
|
||||
|
||||
/**
|
||||
* The format in which generated images with `dall-e-2` and `dall-e-3` are
|
||||
* returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes
|
||||
* after the image has been generated. This parameter isn't supported for
|
||||
* `gpt-image-1` which will always return base64-encoded images.
|
||||
*/
|
||||
response_format?: 'url' | 'b64_json' | null;
|
||||
|
||||
/**
|
||||
* The size of the generated images. Must be one of `1024x1024`, `1536x1024`
|
||||
* (landscape), `1024x1536` (portrait), or `auto` (default value) for
|
||||
* `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and
|
||||
* one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.
|
||||
*/
|
||||
size?:
|
||||
| 'auto'
|
||||
| '1024x1024'
|
||||
| '1536x1024'
|
||||
| '1024x1536'
|
||||
| '256x256'
|
||||
| '512x512'
|
||||
| '1792x1024'
|
||||
| '1024x1792'
|
||||
| null;
|
||||
|
||||
/**
|
||||
* The style of the generated images. This parameter is only supported for
|
||||
* `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean
|
||||
* towards generating hyper-real and dramatic images. Natural causes the model to
|
||||
* produce more natural, less hyper-real looking images.
|
||||
*/
|
||||
style?: 'vivid' | 'natural' | null;
|
||||
|
||||
/**
|
||||
* A unique identifier representing your end-user, which can help OpenAI to monitor
|
||||
* and detect abuse.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
|
||||
*/
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export declare namespace Images {
|
||||
export {
|
||||
type Image as Image,
|
||||
type ImageModel as ImageModel,
|
||||
type ImagesResponse as ImagesResponse,
|
||||
type ImageCreateVariationParams as ImageCreateVariationParams,
|
||||
type ImageEditParams as ImageEditParams,
|
||||
type ImageGenerateParams as ImageGenerateParams,
|
||||
};
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './chat/index';
|
||||
export * from './shared';
|
||||
export { Audio, type AudioModel, type AudioResponseFormat } from './audio/audio';
|
||||
export {
|
||||
BatchesPage,
|
||||
Batches,
|
||||
type Batch,
|
||||
type BatchError,
|
||||
type BatchRequestCounts,
|
||||
type BatchCreateParams,
|
||||
type BatchListParams,
|
||||
} from './batches';
|
||||
export { Beta } from './beta/beta';
|
||||
export {
|
||||
Completions,
|
||||
type Completion,
|
||||
type CompletionChoice,
|
||||
type CompletionUsage,
|
||||
type CompletionCreateParams,
|
||||
type CompletionCreateParamsNonStreaming,
|
||||
type CompletionCreateParamsStreaming,
|
||||
} from './completions';
|
||||
export {
|
||||
ContainerListResponsesPage,
|
||||
Containers,
|
||||
type ContainerCreateResponse,
|
||||
type ContainerRetrieveResponse,
|
||||
type ContainerListResponse,
|
||||
type ContainerCreateParams,
|
||||
type ContainerListParams,
|
||||
} from './containers/containers';
|
||||
export {
|
||||
Embeddings,
|
||||
type CreateEmbeddingResponse,
|
||||
type Embedding,
|
||||
type EmbeddingModel,
|
||||
type EmbeddingCreateParams,
|
||||
} from './embeddings';
|
||||
export {
|
||||
EvalListResponsesPage,
|
||||
Evals,
|
||||
type EvalCustomDataSourceConfig,
|
||||
type EvalStoredCompletionsDataSourceConfig,
|
||||
type EvalCreateResponse,
|
||||
type EvalRetrieveResponse,
|
||||
type EvalUpdateResponse,
|
||||
type EvalListResponse,
|
||||
type EvalDeleteResponse,
|
||||
type EvalCreateParams,
|
||||
type EvalUpdateParams,
|
||||
type EvalListParams,
|
||||
} from './evals/evals';
|
||||
export {
|
||||
FileObjectsPage,
|
||||
Files,
|
||||
type FileContent,
|
||||
type FileDeleted,
|
||||
type FileObject,
|
||||
type FilePurpose,
|
||||
type FileCreateParams,
|
||||
type FileListParams,
|
||||
} from './files';
|
||||
export { FineTuning } from './fine-tuning/fine-tuning';
|
||||
export { Graders } from './graders/graders';
|
||||
export {
|
||||
Images,
|
||||
type Image,
|
||||
type ImageModel,
|
||||
type ImagesResponse,
|
||||
type ImageCreateVariationParams,
|
||||
type ImageEditParams,
|
||||
type ImageGenerateParams,
|
||||
} from './images';
|
||||
export { ModelsPage, Models, type Model, type ModelDeleted } from './models';
|
||||
export {
|
||||
Moderations,
|
||||
type Moderation,
|
||||
type ModerationImageURLInput,
|
||||
type ModerationModel,
|
||||
type ModerationMultiModalInput,
|
||||
type ModerationTextInput,
|
||||
type ModerationCreateResponse,
|
||||
type ModerationCreateParams,
|
||||
} from './moderations';
|
||||
export { Responses } from './responses/responses';
|
||||
export { Uploads, type Upload, type UploadCreateParams, type UploadCompleteParams } from './uploads/uploads';
|
||||
export {
|
||||
VectorStoresPage,
|
||||
VectorStoreSearchResponsesPage,
|
||||
VectorStores,
|
||||
type AutoFileChunkingStrategyParam,
|
||||
type FileChunkingStrategy,
|
||||
type FileChunkingStrategyParam,
|
||||
type OtherFileChunkingStrategyObject,
|
||||
type StaticFileChunkingStrategy,
|
||||
type StaticFileChunkingStrategyObject,
|
||||
type StaticFileChunkingStrategyObjectParam,
|
||||
type VectorStore,
|
||||
type VectorStoreDeleted,
|
||||
type VectorStoreSearchResponse,
|
||||
type VectorStoreCreateParams,
|
||||
type VectorStoreUpdateParams,
|
||||
type VectorStoreListParams,
|
||||
type VectorStoreSearchParams,
|
||||
} from './vector-stores/vector-stores';
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../resource';
|
||||
import * as Core from '../core';
|
||||
import { Page } from '../pagination';
|
||||
|
||||
export class Models extends APIResource {
|
||||
/**
|
||||
* Retrieves a model instance, providing basic information about the model such as
|
||||
* the owner and permissioning.
|
||||
*/
|
||||
retrieve(model: string, options?: Core.RequestOptions): Core.APIPromise<Model> {
|
||||
return this._client.get(`/models/${model}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists the currently available models, and provides basic information about each
|
||||
* one such as the owner and availability.
|
||||
*/
|
||||
list(options?: Core.RequestOptions): Core.PagePromise<ModelsPage, Model> {
|
||||
return this._client.getAPIList('/models', ModelsPage, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a fine-tuned model. You must have the Owner role in your organization to
|
||||
* delete a model.
|
||||
*/
|
||||
del(model: string, options?: Core.RequestOptions): Core.APIPromise<ModelDeleted> {
|
||||
return this._client.delete(`/models/${model}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: no pagination actually occurs yet, this is for forwards-compatibility.
|
||||
*/
|
||||
export class ModelsPage extends Page<Model> {}
|
||||
|
||||
/**
|
||||
* Describes an OpenAI model offering that can be used with the API.
|
||||
*/
|
||||
export interface Model {
|
||||
/**
|
||||
* The model identifier, which can be referenced in the API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) when the model was created.
|
||||
*/
|
||||
created: number;
|
||||
|
||||
/**
|
||||
* The object type, which is always "model".
|
||||
*/
|
||||
object: 'model';
|
||||
|
||||
/**
|
||||
* The organization that owns the model.
|
||||
*/
|
||||
owned_by: string;
|
||||
}
|
||||
|
||||
export interface ModelDeleted {
|
||||
id: string;
|
||||
|
||||
deleted: boolean;
|
||||
|
||||
object: string;
|
||||
}
|
||||
|
||||
Models.ModelsPage = ModelsPage;
|
||||
|
||||
export declare namespace Models {
|
||||
export { type Model as Model, type ModelDeleted as ModelDeleted, ModelsPage as ModelsPage };
|
||||
}
|
||||
+369
@@ -0,0 +1,369 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../resource';
|
||||
import * as Core from '../core';
|
||||
|
||||
export class Moderations extends APIResource {
|
||||
/**
|
||||
* Classifies if text and/or image inputs are potentially harmful. Learn more in
|
||||
* the [moderation guide](https://platform.openai.com/docs/guides/moderation).
|
||||
*/
|
||||
create(
|
||||
body: ModerationCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<ModerationCreateResponse> {
|
||||
return this._client.post('/moderations', { body, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
export interface Moderation {
|
||||
/**
|
||||
* A list of the categories, and whether they are flagged or not.
|
||||
*/
|
||||
categories: Moderation.Categories;
|
||||
|
||||
/**
|
||||
* A list of the categories along with the input type(s) that the score applies to.
|
||||
*/
|
||||
category_applied_input_types: Moderation.CategoryAppliedInputTypes;
|
||||
|
||||
/**
|
||||
* A list of the categories along with their scores as predicted by model.
|
||||
*/
|
||||
category_scores: Moderation.CategoryScores;
|
||||
|
||||
/**
|
||||
* Whether any of the below categories are flagged.
|
||||
*/
|
||||
flagged: boolean;
|
||||
}
|
||||
|
||||
export namespace Moderation {
|
||||
/**
|
||||
* A list of the categories, and whether they are flagged or not.
|
||||
*/
|
||||
export interface Categories {
|
||||
/**
|
||||
* Content that expresses, incites, or promotes harassing language towards any
|
||||
* target.
|
||||
*/
|
||||
harassment: boolean;
|
||||
|
||||
/**
|
||||
* Harassment content that also includes violence or serious harm towards any
|
||||
* target.
|
||||
*/
|
||||
'harassment/threatening': boolean;
|
||||
|
||||
/**
|
||||
* Content that expresses, incites, or promotes hate based on race, gender,
|
||||
* ethnicity, religion, nationality, sexual orientation, disability status, or
|
||||
* caste. Hateful content aimed at non-protected groups (e.g., chess players) is
|
||||
* harassment.
|
||||
*/
|
||||
hate: boolean;
|
||||
|
||||
/**
|
||||
* Hateful content that also includes violence or serious harm towards the targeted
|
||||
* group based on race, gender, ethnicity, religion, nationality, sexual
|
||||
* orientation, disability status, or caste.
|
||||
*/
|
||||
'hate/threatening': boolean;
|
||||
|
||||
/**
|
||||
* Content that includes instructions or advice that facilitate the planning or
|
||||
* execution of wrongdoing, or that gives advice or instruction on how to commit
|
||||
* illicit acts. For example, "how to shoplift" would fit this category.
|
||||
*/
|
||||
illicit: boolean | null;
|
||||
|
||||
/**
|
||||
* Content that includes instructions or advice that facilitate the planning or
|
||||
* execution of wrongdoing that also includes violence, or that gives advice or
|
||||
* instruction on the procurement of any weapon.
|
||||
*/
|
||||
'illicit/violent': boolean | null;
|
||||
|
||||
/**
|
||||
* Content that promotes, encourages, or depicts acts of self-harm, such as
|
||||
* suicide, cutting, and eating disorders.
|
||||
*/
|
||||
'self-harm': boolean;
|
||||
|
||||
/**
|
||||
* Content that encourages performing acts of self-harm, such as suicide, cutting,
|
||||
* and eating disorders, or that gives instructions or advice on how to commit such
|
||||
* acts.
|
||||
*/
|
||||
'self-harm/instructions': boolean;
|
||||
|
||||
/**
|
||||
* Content where the speaker expresses that they are engaging or intend to engage
|
||||
* in acts of self-harm, such as suicide, cutting, and eating disorders.
|
||||
*/
|
||||
'self-harm/intent': boolean;
|
||||
|
||||
/**
|
||||
* Content meant to arouse sexual excitement, such as the description of sexual
|
||||
* activity, or that promotes sexual services (excluding sex education and
|
||||
* wellness).
|
||||
*/
|
||||
sexual: boolean;
|
||||
|
||||
/**
|
||||
* Sexual content that includes an individual who is under 18 years old.
|
||||
*/
|
||||
'sexual/minors': boolean;
|
||||
|
||||
/**
|
||||
* Content that depicts death, violence, or physical injury.
|
||||
*/
|
||||
violence: boolean;
|
||||
|
||||
/**
|
||||
* Content that depicts death, violence, or physical injury in graphic detail.
|
||||
*/
|
||||
'violence/graphic': boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of the categories along with the input type(s) that the score applies to.
|
||||
*/
|
||||
export interface CategoryAppliedInputTypes {
|
||||
/**
|
||||
* The applied input type(s) for the category 'harassment'.
|
||||
*/
|
||||
harassment: Array<'text'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'harassment/threatening'.
|
||||
*/
|
||||
'harassment/threatening': Array<'text'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'hate'.
|
||||
*/
|
||||
hate: Array<'text'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'hate/threatening'.
|
||||
*/
|
||||
'hate/threatening': Array<'text'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'illicit'.
|
||||
*/
|
||||
illicit: Array<'text'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'illicit/violent'.
|
||||
*/
|
||||
'illicit/violent': Array<'text'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'self-harm'.
|
||||
*/
|
||||
'self-harm': Array<'text' | 'image'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'self-harm/instructions'.
|
||||
*/
|
||||
'self-harm/instructions': Array<'text' | 'image'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'self-harm/intent'.
|
||||
*/
|
||||
'self-harm/intent': Array<'text' | 'image'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'sexual'.
|
||||
*/
|
||||
sexual: Array<'text' | 'image'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'sexual/minors'.
|
||||
*/
|
||||
'sexual/minors': Array<'text'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'violence'.
|
||||
*/
|
||||
violence: Array<'text' | 'image'>;
|
||||
|
||||
/**
|
||||
* The applied input type(s) for the category 'violence/graphic'.
|
||||
*/
|
||||
'violence/graphic': Array<'text' | 'image'>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of the categories along with their scores as predicted by model.
|
||||
*/
|
||||
export interface CategoryScores {
|
||||
/**
|
||||
* The score for the category 'harassment'.
|
||||
*/
|
||||
harassment: number;
|
||||
|
||||
/**
|
||||
* The score for the category 'harassment/threatening'.
|
||||
*/
|
||||
'harassment/threatening': number;
|
||||
|
||||
/**
|
||||
* The score for the category 'hate'.
|
||||
*/
|
||||
hate: number;
|
||||
|
||||
/**
|
||||
* The score for the category 'hate/threatening'.
|
||||
*/
|
||||
'hate/threatening': number;
|
||||
|
||||
/**
|
||||
* The score for the category 'illicit'.
|
||||
*/
|
||||
illicit: number;
|
||||
|
||||
/**
|
||||
* The score for the category 'illicit/violent'.
|
||||
*/
|
||||
'illicit/violent': number;
|
||||
|
||||
/**
|
||||
* The score for the category 'self-harm'.
|
||||
*/
|
||||
'self-harm': number;
|
||||
|
||||
/**
|
||||
* The score for the category 'self-harm/instructions'.
|
||||
*/
|
||||
'self-harm/instructions': number;
|
||||
|
||||
/**
|
||||
* The score for the category 'self-harm/intent'.
|
||||
*/
|
||||
'self-harm/intent': number;
|
||||
|
||||
/**
|
||||
* The score for the category 'sexual'.
|
||||
*/
|
||||
sexual: number;
|
||||
|
||||
/**
|
||||
* The score for the category 'sexual/minors'.
|
||||
*/
|
||||
'sexual/minors': number;
|
||||
|
||||
/**
|
||||
* The score for the category 'violence'.
|
||||
*/
|
||||
violence: number;
|
||||
|
||||
/**
|
||||
* The score for the category 'violence/graphic'.
|
||||
*/
|
||||
'violence/graphic': number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An object describing an image to classify.
|
||||
*/
|
||||
export interface ModerationImageURLInput {
|
||||
/**
|
||||
* Contains either an image URL or a data URL for a base64 encoded image.
|
||||
*/
|
||||
image_url: ModerationImageURLInput.ImageURL;
|
||||
|
||||
/**
|
||||
* Always `image_url`.
|
||||
*/
|
||||
type: 'image_url';
|
||||
}
|
||||
|
||||
export namespace ModerationImageURLInput {
|
||||
/**
|
||||
* Contains either an image URL or a data URL for a base64 encoded image.
|
||||
*/
|
||||
export interface ImageURL {
|
||||
/**
|
||||
* Either a URL of the image or the base64 encoded image data.
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
}
|
||||
|
||||
export type ModerationModel =
|
||||
| 'omni-moderation-latest'
|
||||
| 'omni-moderation-2024-09-26'
|
||||
| 'text-moderation-latest'
|
||||
| 'text-moderation-stable';
|
||||
|
||||
/**
|
||||
* An object describing an image to classify.
|
||||
*/
|
||||
export type ModerationMultiModalInput = ModerationImageURLInput | ModerationTextInput;
|
||||
|
||||
/**
|
||||
* An object describing text to classify.
|
||||
*/
|
||||
export interface ModerationTextInput {
|
||||
/**
|
||||
* A string of text to classify.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Always `text`.
|
||||
*/
|
||||
type: 'text';
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents if a given text input is potentially harmful.
|
||||
*/
|
||||
export interface ModerationCreateResponse {
|
||||
/**
|
||||
* The unique identifier for the moderation request.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The model used to generate the moderation results.
|
||||
*/
|
||||
model: string;
|
||||
|
||||
/**
|
||||
* A list of moderation objects.
|
||||
*/
|
||||
results: Array<Moderation>;
|
||||
}
|
||||
|
||||
export interface ModerationCreateParams {
|
||||
/**
|
||||
* Input (or inputs) to classify. Can be a single string, an array of strings, or
|
||||
* an array of multi-modal input objects similar to other models.
|
||||
*/
|
||||
input: string | Array<string> | Array<ModerationMultiModalInput>;
|
||||
|
||||
/**
|
||||
* The content moderation model you would like to use. Learn more in
|
||||
* [the moderation guide](https://platform.openai.com/docs/guides/moderation), and
|
||||
* learn about available models
|
||||
* [here](https://platform.openai.com/docs/models#moderation).
|
||||
*/
|
||||
model?: (string & {}) | ModerationModel;
|
||||
}
|
||||
|
||||
export declare namespace Moderations {
|
||||
export {
|
||||
type Moderation as Moderation,
|
||||
type ModerationImageURLInput as ModerationImageURLInput,
|
||||
type ModerationModel as ModerationModel,
|
||||
type ModerationMultiModalInput as ModerationMultiModalInput,
|
||||
type ModerationTextInput as ModerationTextInput,
|
||||
type ModerationCreateResponse as ModerationCreateResponse,
|
||||
type ModerationCreateParams as ModerationCreateParams,
|
||||
};
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { InputItems, type ResponseItemList, type InputItemListParams } from './input-items';
|
||||
export { Responses } from './responses';
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import { isRequestOptions } from '../../core';
|
||||
import * as Core from '../../core';
|
||||
import * as ResponsesAPI from './responses';
|
||||
import { ResponseItemsPage } from './responses';
|
||||
import { type CursorPageParams } from '../../pagination';
|
||||
|
||||
export class InputItems extends APIResource {
|
||||
/**
|
||||
* Returns a list of input items for a given response.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Automatically fetches more pages as needed.
|
||||
* for await (const responseItem of client.responses.inputItems.list(
|
||||
* 'response_id',
|
||||
* )) {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
list(
|
||||
responseId: string,
|
||||
query?: InputItemListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem>;
|
||||
list(
|
||||
responseId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem>;
|
||||
list(
|
||||
responseId: string,
|
||||
query: InputItemListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(responseId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(`/responses/${responseId}/input_items`, ResponseItemsPage, {
|
||||
query,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of Response items.
|
||||
*/
|
||||
export interface ResponseItemList {
|
||||
/**
|
||||
* A list of items used to generate this response.
|
||||
*/
|
||||
data: Array<ResponsesAPI.ResponseItem>;
|
||||
|
||||
/**
|
||||
* The ID of the first item in the list.
|
||||
*/
|
||||
first_id: string;
|
||||
|
||||
/**
|
||||
* Whether there are more items available.
|
||||
*/
|
||||
has_more: boolean;
|
||||
|
||||
/**
|
||||
* The ID of the last item in the list.
|
||||
*/
|
||||
last_id: string;
|
||||
|
||||
/**
|
||||
* The type of object returned, must be `list`.
|
||||
*/
|
||||
object: 'list';
|
||||
}
|
||||
|
||||
export interface InputItemListParams extends CursorPageParams {
|
||||
/**
|
||||
* An item ID to list items before, used in pagination.
|
||||
*/
|
||||
before?: string;
|
||||
|
||||
/**
|
||||
* Additional fields to include in the response. See the `include` parameter for
|
||||
* Response creation above for more information.
|
||||
*/
|
||||
include?: Array<ResponsesAPI.ResponseIncludable>;
|
||||
|
||||
/**
|
||||
* The order to return the input items in. Default is `desc`.
|
||||
*
|
||||
* - `asc`: Return the input items in ascending order.
|
||||
* - `desc`: Return the input items in descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export declare namespace InputItems {
|
||||
export { type ResponseItemList as ResponseItemList, type InputItemListParams as InputItemListParams };
|
||||
}
|
||||
|
||||
export { ResponseItemsPage };
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import { isRequestOptions } from '../../core';
|
||||
import * as Core from '../../core';
|
||||
import * as ResponsesAPI from './responses';
|
||||
import { ResponseItemsPage } from './responses';
|
||||
import { type CursorPageParams } from '../../pagination';
|
||||
|
||||
export class InputItems extends APIResource {
|
||||
/**
|
||||
* Returns a list of input items for a given response.
|
||||
*/
|
||||
list(
|
||||
responseId: string,
|
||||
query?: InputItemListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem>;
|
||||
list(
|
||||
responseId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem>;
|
||||
list(
|
||||
responseId: string,
|
||||
query: InputItemListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(responseId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(`/responses/${responseId}/input_items`, ResponseItemsPage, {
|
||||
query,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
export class ResponseItemListDataPage extends CursorPage<
|
||||
// @ts-ignore some items don't necessarily have the `id` property
|
||||
| ResponseItemList.Message
|
||||
| ResponsesAPI.ResponseOutputMessage
|
||||
| ResponsesAPI.ResponseFileSearchToolCall
|
||||
| ResponsesAPI.ResponseComputerToolCall
|
||||
| ResponseItemList.ComputerCallOutput
|
||||
| ResponsesAPI.ResponseFunctionWebSearch
|
||||
| ResponsesAPI.ResponseFunctionToolCall
|
||||
| ResponseItemList.FunctionCallOutput
|
||||
> {}
|
||||
|
||||
||||||| parent of e5ea4a71 (fix(types): improve responses type names (#1392))
|
||||
export class ResponseItemListDataPage extends CursorPage<
|
||||
| ResponseItemList.Message
|
||||
| ResponsesAPI.ResponseOutputMessage
|
||||
| ResponsesAPI.ResponseFileSearchToolCall
|
||||
| ResponsesAPI.ResponseComputerToolCall
|
||||
| ResponseItemList.ComputerCallOutput
|
||||
| ResponsesAPI.ResponseFunctionWebSearch
|
||||
| ResponsesAPI.ResponseFunctionToolCall
|
||||
| ResponseItemList.FunctionCallOutput
|
||||
> {}
|
||||
|
||||
=======
|
||||
>>>>>>> e5ea4a71 (fix(types): improve responses type names (#1392))
|
||||
/**
|
||||
* A list of Response items.
|
||||
*/
|
||||
export interface ResponseItemList {
|
||||
/**
|
||||
* A list of items used to generate this response.
|
||||
*/
|
||||
data: Array<ResponsesAPI.ResponseItem>;
|
||||
|
||||
/**
|
||||
* The ID of the first item in the list.
|
||||
*/
|
||||
first_id: string;
|
||||
|
||||
/**
|
||||
* Whether there are more items available.
|
||||
*/
|
||||
has_more: boolean;
|
||||
|
||||
/**
|
||||
* The ID of the last item in the list.
|
||||
*/
|
||||
last_id: string;
|
||||
|
||||
/**
|
||||
* The type of object returned, must be `list`.
|
||||
*/
|
||||
object: 'list';
|
||||
}
|
||||
|
||||
export interface InputItemListParams extends CursorPageParams {
|
||||
/**
|
||||
* An item ID to list items before, used in pagination.
|
||||
*/
|
||||
before?: string;
|
||||
|
||||
/**
|
||||
* The order to return the input items in. Default is `asc`.
|
||||
*
|
||||
* - `asc`: Return the input items in ascending order.
|
||||
* - `desc`: Return the input items in descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export declare namespace InputItems {
|
||||
export { type ResponseItemList as ResponseItemList, type InputItemListParams as InputItemListParams };
|
||||
}
|
||||
|
||||
export { ResponseItemsPage };
|
||||
+4929
File diff suppressed because it is too large
Load Diff
+300
@@ -0,0 +1,300 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export type AllModels =
|
||||
| (string & {})
|
||||
| ChatModel
|
||||
| 'o1-pro'
|
||||
| 'o1-pro-2025-03-19'
|
||||
| 'computer-use-preview'
|
||||
| 'computer-use-preview-2025-03-11';
|
||||
|
||||
export type ChatModel =
|
||||
| 'gpt-4.1'
|
||||
| 'gpt-4.1-mini'
|
||||
| 'gpt-4.1-nano'
|
||||
| 'gpt-4.1-2025-04-14'
|
||||
| 'gpt-4.1-mini-2025-04-14'
|
||||
| 'gpt-4.1-nano-2025-04-14'
|
||||
| 'o4-mini'
|
||||
| 'o4-mini-2025-04-16'
|
||||
| 'o3'
|
||||
| 'o3-2025-04-16'
|
||||
| 'o3-mini'
|
||||
| 'o3-mini-2025-01-31'
|
||||
| 'o1'
|
||||
| 'o1-2024-12-17'
|
||||
| 'o1-preview'
|
||||
| 'o1-preview-2024-09-12'
|
||||
| 'o1-mini'
|
||||
| 'o1-mini-2024-09-12'
|
||||
| 'gpt-4o'
|
||||
| 'gpt-4o-2024-11-20'
|
||||
| 'gpt-4o-2024-08-06'
|
||||
| 'gpt-4o-2024-05-13'
|
||||
| 'gpt-4o-audio-preview'
|
||||
| 'gpt-4o-audio-preview-2024-10-01'
|
||||
| 'gpt-4o-audio-preview-2024-12-17'
|
||||
| 'gpt-4o-mini-audio-preview'
|
||||
| 'gpt-4o-mini-audio-preview-2024-12-17'
|
||||
| 'gpt-4o-search-preview'
|
||||
| 'gpt-4o-mini-search-preview'
|
||||
| 'gpt-4o-search-preview-2025-03-11'
|
||||
| 'gpt-4o-mini-search-preview-2025-03-11'
|
||||
| 'chatgpt-4o-latest'
|
||||
| 'codex-mini-latest'
|
||||
| 'gpt-4o-mini'
|
||||
| 'gpt-4o-mini-2024-07-18'
|
||||
| 'gpt-4-turbo'
|
||||
| 'gpt-4-turbo-2024-04-09'
|
||||
| 'gpt-4-0125-preview'
|
||||
| 'gpt-4-turbo-preview'
|
||||
| 'gpt-4-1106-preview'
|
||||
| 'gpt-4-vision-preview'
|
||||
| 'gpt-4'
|
||||
| 'gpt-4-0314'
|
||||
| 'gpt-4-0613'
|
||||
| 'gpt-4-32k'
|
||||
| 'gpt-4-32k-0314'
|
||||
| 'gpt-4-32k-0613'
|
||||
| 'gpt-3.5-turbo'
|
||||
| 'gpt-3.5-turbo-16k'
|
||||
| 'gpt-3.5-turbo-0301'
|
||||
| 'gpt-3.5-turbo-0613'
|
||||
| 'gpt-3.5-turbo-1106'
|
||||
| 'gpt-3.5-turbo-0125'
|
||||
| 'gpt-3.5-turbo-16k-0613';
|
||||
|
||||
/**
|
||||
* A filter used to compare a specified attribute key to a given value using a
|
||||
* defined comparison operation.
|
||||
*/
|
||||
export interface ComparisonFilter {
|
||||
/**
|
||||
* The key to compare against the value.
|
||||
*/
|
||||
key: string;
|
||||
|
||||
/**
|
||||
* Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`.
|
||||
*
|
||||
* - `eq`: equals
|
||||
* - `ne`: not equal
|
||||
* - `gt`: greater than
|
||||
* - `gte`: greater than or equal
|
||||
* - `lt`: less than
|
||||
* - `lte`: less than or equal
|
||||
*/
|
||||
type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
|
||||
|
||||
/**
|
||||
* The value to compare against the attribute key; supports string, number, or
|
||||
* boolean types.
|
||||
*/
|
||||
value: string | number | boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine multiple filters using `and` or `or`.
|
||||
*/
|
||||
export interface CompoundFilter {
|
||||
/**
|
||||
* Array of filters to combine. Items can be `ComparisonFilter` or
|
||||
* `CompoundFilter`.
|
||||
*/
|
||||
filters: Array<ComparisonFilter | unknown>;
|
||||
|
||||
/**
|
||||
* Type of operation: `and` or `or`.
|
||||
*/
|
||||
type: 'and' | 'or';
|
||||
}
|
||||
|
||||
export interface ErrorObject {
|
||||
code: string | null;
|
||||
|
||||
message: string;
|
||||
|
||||
param: string | null;
|
||||
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface FunctionDefinition {
|
||||
/**
|
||||
* The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
|
||||
* underscores and dashes, with a maximum length of 64.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A description of what the function does, used by the model to choose when and
|
||||
* how to call the function.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* The parameters the functions accepts, described as a JSON Schema object. See the
|
||||
* [guide](https://platform.openai.com/docs/guides/function-calling) for examples,
|
||||
* and the
|
||||
* [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
|
||||
* documentation about the format.
|
||||
*
|
||||
* Omitting `parameters` defines a function with an empty parameter list.
|
||||
*/
|
||||
parameters?: FunctionParameters;
|
||||
|
||||
/**
|
||||
* Whether to enable strict schema adherence when generating the function call. If
|
||||
* set to true, the model will follow the exact schema defined in the `parameters`
|
||||
* field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn
|
||||
* more about Structured Outputs in the
|
||||
* [function calling guide](docs/guides/function-calling).
|
||||
*/
|
||||
strict?: boolean | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The parameters the functions accepts, described as a JSON Schema object. See the
|
||||
* [guide](https://platform.openai.com/docs/guides/function-calling) for examples,
|
||||
* and the
|
||||
* [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
|
||||
* documentation about the format.
|
||||
*
|
||||
* Omitting `parameters` defines a function with an empty parameter list.
|
||||
*/
|
||||
export type FunctionParameters = Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
export type Metadata = Record<string, string>;
|
||||
|
||||
/**
|
||||
* **o-series models only**
|
||||
*
|
||||
* Configuration options for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
||||
*/
|
||||
export interface Reasoning {
|
||||
/**
|
||||
* **o-series models only**
|
||||
*
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
|
||||
* result in faster responses and fewer tokens used on reasoning in a response.
|
||||
*/
|
||||
effort?: ReasoningEffort | null;
|
||||
|
||||
/**
|
||||
* @deprecated **Deprecated:** use `summary` instead.
|
||||
*
|
||||
* A summary of the reasoning performed by the model. This can be useful for
|
||||
* debugging and understanding the model's reasoning process. One of `auto`,
|
||||
* `concise`, or `detailed`.
|
||||
*/
|
||||
generate_summary?: 'auto' | 'concise' | 'detailed' | null;
|
||||
|
||||
/**
|
||||
* A summary of the reasoning performed by the model. This can be useful for
|
||||
* debugging and understanding the model's reasoning process. One of `auto`,
|
||||
* `concise`, or `detailed`.
|
||||
*/
|
||||
summary?: 'auto' | 'concise' | 'detailed' | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* **o-series models only**
|
||||
*
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
|
||||
* result in faster responses and fewer tokens used on reasoning in a response.
|
||||
*/
|
||||
export type ReasoningEffort = 'low' | 'medium' | 'high' | null;
|
||||
|
||||
/**
|
||||
* JSON object response format. An older method of generating JSON responses. Using
|
||||
* `json_schema` is recommended for models that support it. Note that the model
|
||||
* will not generate JSON without a system or user message instructing it to do so.
|
||||
*/
|
||||
export interface ResponseFormatJSONObject {
|
||||
/**
|
||||
* The type of response format being defined. Always `json_object`.
|
||||
*/
|
||||
type: 'json_object';
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON Schema response format. Used to generate structured JSON responses. Learn
|
||||
* more about
|
||||
* [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
|
||||
*/
|
||||
export interface ResponseFormatJSONSchema {
|
||||
/**
|
||||
* Structured Outputs configuration options, including a JSON Schema.
|
||||
*/
|
||||
json_schema: ResponseFormatJSONSchema.JSONSchema;
|
||||
|
||||
/**
|
||||
* The type of response format being defined. Always `json_schema`.
|
||||
*/
|
||||
type: 'json_schema';
|
||||
}
|
||||
|
||||
export namespace ResponseFormatJSONSchema {
|
||||
/**
|
||||
* Structured Outputs configuration options, including a JSON Schema.
|
||||
*/
|
||||
export interface JSONSchema {
|
||||
/**
|
||||
* The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
|
||||
* and dashes, with a maximum length of 64.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A description of what the response format is for, used by the model to determine
|
||||
* how to respond in the format.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* The schema for the response format, described as a JSON Schema object. Learn how
|
||||
* to build JSON schemas [here](https://json-schema.org/).
|
||||
*/
|
||||
schema?: Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* Whether to enable strict schema adherence when generating the output. If set to
|
||||
* true, the model will always follow the exact schema defined in the `schema`
|
||||
* field. Only a subset of JSON Schema is supported when `strict` is `true`. To
|
||||
* learn more, read the
|
||||
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
|
||||
*/
|
||||
strict?: boolean | null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default response format. Used to generate text responses.
|
||||
*/
|
||||
export interface ResponseFormatText {
|
||||
/**
|
||||
* The type of response format being defined. Always `text`.
|
||||
*/
|
||||
type: 'text';
|
||||
}
|
||||
|
||||
export type ResponsesModel =
|
||||
| (string & {})
|
||||
| ChatModel
|
||||
| 'o1-pro'
|
||||
| 'o1-pro-2025-03-19'
|
||||
| 'computer-use-preview'
|
||||
| 'computer-use-preview-2025-03-11';
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Parts, type UploadPart, type PartCreateParams } from './parts';
|
||||
export { Uploads, type Upload, type UploadCreateParams, type UploadCompleteParams } from './uploads';
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as Core from '../../core';
|
||||
|
||||
export class Parts extends APIResource {
|
||||
/**
|
||||
* Adds a
|
||||
* [Part](https://platform.openai.com/docs/api-reference/uploads/part-object) to an
|
||||
* [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object.
|
||||
* A Part represents a chunk of bytes from the file you are trying to upload.
|
||||
*
|
||||
* Each Part can be at most 64 MB, and you can add Parts until you hit the Upload
|
||||
* maximum of 8 GB.
|
||||
*
|
||||
* It is possible to add multiple Parts in parallel. You can decide the intended
|
||||
* order of the Parts when you
|
||||
* [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).
|
||||
*/
|
||||
create(
|
||||
uploadId: string,
|
||||
body: PartCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<UploadPart> {
|
||||
return this._client.post(
|
||||
`/uploads/${uploadId}/parts`,
|
||||
Core.multipartFormRequestOptions({ body, ...options }),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The upload Part represents a chunk of bytes we can add to an Upload object.
|
||||
*/
|
||||
export interface UploadPart {
|
||||
/**
|
||||
* The upload Part unique identifier, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the Part was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The object type, which is always `upload.part`.
|
||||
*/
|
||||
object: 'upload.part';
|
||||
|
||||
/**
|
||||
* The ID of the Upload object that this Part was added to.
|
||||
*/
|
||||
upload_id: string;
|
||||
}
|
||||
|
||||
export interface PartCreateParams {
|
||||
/**
|
||||
* The chunk of bytes for this Part.
|
||||
*/
|
||||
data: Core.Uploadable;
|
||||
}
|
||||
|
||||
export declare namespace Parts {
|
||||
export { type UploadPart as UploadPart, type PartCreateParams as PartCreateParams };
|
||||
}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import * as Core from '../../core';
|
||||
import * as FilesAPI from '../files';
|
||||
import * as PartsAPI from './parts';
|
||||
import { PartCreateParams, Parts, UploadPart } from './parts';
|
||||
|
||||
export class Uploads extends APIResource {
|
||||
parts: PartsAPI.Parts = new PartsAPI.Parts(this._client);
|
||||
|
||||
/**
|
||||
* Creates an intermediate
|
||||
* [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object
|
||||
* that you can add
|
||||
* [Parts](https://platform.openai.com/docs/api-reference/uploads/part-object) to.
|
||||
* Currently, an Upload can accept at most 8 GB in total and expires after an hour
|
||||
* after you create it.
|
||||
*
|
||||
* Once you complete the Upload, we will create a
|
||||
* [File](https://platform.openai.com/docs/api-reference/files/object) object that
|
||||
* contains all the parts you uploaded. This File is usable in the rest of our
|
||||
* platform as a regular File object.
|
||||
*
|
||||
* For certain `purpose` values, the correct `mime_type` must be specified. Please
|
||||
* refer to documentation for the
|
||||
* [supported MIME types for your use case](https://platform.openai.com/docs/assistants/tools/file-search#supported-files).
|
||||
*
|
||||
* For guidance on the proper filename extensions for each purpose, please follow
|
||||
* the documentation on
|
||||
* [creating a File](https://platform.openai.com/docs/api-reference/files/create).
|
||||
*/
|
||||
create(body: UploadCreateParams, options?: Core.RequestOptions): Core.APIPromise<Upload> {
|
||||
return this._client.post('/uploads', { body, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the Upload. No Parts may be added after an Upload is cancelled.
|
||||
*/
|
||||
cancel(uploadId: string, options?: Core.RequestOptions): Core.APIPromise<Upload> {
|
||||
return this._client.post(`/uploads/${uploadId}/cancel`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes the
|
||||
* [Upload](https://platform.openai.com/docs/api-reference/uploads/object).
|
||||
*
|
||||
* Within the returned Upload object, there is a nested
|
||||
* [File](https://platform.openai.com/docs/api-reference/files/object) object that
|
||||
* is ready to use in the rest of the platform.
|
||||
*
|
||||
* You can specify the order of the Parts by passing in an ordered list of the Part
|
||||
* IDs.
|
||||
*
|
||||
* The number of bytes uploaded upon completion must match the number of bytes
|
||||
* initially specified when creating the Upload object. No Parts may be added after
|
||||
* an Upload is completed.
|
||||
*/
|
||||
complete(
|
||||
uploadId: string,
|
||||
body: UploadCompleteParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<Upload> {
|
||||
return this._client.post(`/uploads/${uploadId}/complete`, { body, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Upload object can accept byte chunks in the form of Parts.
|
||||
*/
|
||||
export interface Upload {
|
||||
/**
|
||||
* The Upload unique identifier, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The intended number of bytes to be uploaded.
|
||||
*/
|
||||
bytes: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the Upload was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the Upload will expire.
|
||||
*/
|
||||
expires_at: number;
|
||||
|
||||
/**
|
||||
* The name of the file to be uploaded.
|
||||
*/
|
||||
filename: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always "upload".
|
||||
*/
|
||||
object: 'upload';
|
||||
|
||||
/**
|
||||
* The intended purpose of the file.
|
||||
* [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose)
|
||||
* for acceptable values.
|
||||
*/
|
||||
purpose: string;
|
||||
|
||||
/**
|
||||
* The status of the Upload.
|
||||
*/
|
||||
status: 'pending' | 'completed' | 'cancelled' | 'expired';
|
||||
|
||||
/**
|
||||
* The `File` object represents a document that has been uploaded to OpenAI.
|
||||
*/
|
||||
file?: FilesAPI.FileObject | null;
|
||||
}
|
||||
|
||||
export interface UploadCreateParams {
|
||||
/**
|
||||
* The number of bytes in the file you are uploading.
|
||||
*/
|
||||
bytes: number;
|
||||
|
||||
/**
|
||||
* The name of the file to upload.
|
||||
*/
|
||||
filename: string;
|
||||
|
||||
/**
|
||||
* The MIME type of the file.
|
||||
*
|
||||
* This must fall within the supported MIME types for your file purpose. See the
|
||||
* supported MIME types for assistants and vision.
|
||||
*/
|
||||
mime_type: string;
|
||||
|
||||
/**
|
||||
* The intended purpose of the uploaded file.
|
||||
*
|
||||
* See the
|
||||
* [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose).
|
||||
*/
|
||||
purpose: FilesAPI.FilePurpose;
|
||||
}
|
||||
|
||||
export interface UploadCompleteParams {
|
||||
/**
|
||||
* The ordered list of Part IDs.
|
||||
*/
|
||||
part_ids: Array<string>;
|
||||
|
||||
/**
|
||||
* The optional md5 checksum for the file contents to verify if the bytes uploaded
|
||||
* matches what you expect.
|
||||
*/
|
||||
md5?: string;
|
||||
}
|
||||
|
||||
Uploads.Parts = Parts;
|
||||
|
||||
export declare namespace Uploads {
|
||||
export {
|
||||
type Upload as Upload,
|
||||
type UploadCreateParams as UploadCreateParams,
|
||||
type UploadCompleteParams as UploadCompleteParams,
|
||||
};
|
||||
|
||||
export { Parts as Parts, type UploadPart as UploadPart, type PartCreateParams as PartCreateParams };
|
||||
}
|
||||
+313
@@ -0,0 +1,313 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import { isRequestOptions } from '../../core';
|
||||
import { sleep } from '../../core';
|
||||
import { Uploadable } from '../../core';
|
||||
import { allSettledWithThrow } from '../../lib/Util';
|
||||
import * as Core from '../../core';
|
||||
import * as FilesAPI from './files';
|
||||
import { VectorStoreFilesPage } from './files';
|
||||
import * as VectorStoresAPI from './vector-stores';
|
||||
import { type CursorPageParams } from '../../pagination';
|
||||
|
||||
export class FileBatches extends APIResource {
|
||||
/**
|
||||
* Create a vector store file batch.
|
||||
*/
|
||||
create(
|
||||
vectorStoreId: string,
|
||||
body: FileBatchCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<VectorStoreFileBatch> {
|
||||
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches`, {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a vector store file batch.
|
||||
*/
|
||||
retrieve(
|
||||
vectorStoreId: string,
|
||||
batchId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<VectorStoreFileBatch> {
|
||||
return this._client.get(`/vector_stores/${vectorStoreId}/file_batches/${batchId}`, {
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a vector store file batch. This attempts to cancel the processing of
|
||||
* files in this batch as soon as possible.
|
||||
*/
|
||||
cancel(
|
||||
vectorStoreId: string,
|
||||
batchId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<VectorStoreFileBatch> {
|
||||
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches/${batchId}/cancel`, {
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a vector store batch and poll until all files have been processed.
|
||||
*/
|
||||
async createAndPoll(
|
||||
vectorStoreId: string,
|
||||
body: FileBatchCreateParams,
|
||||
options?: Core.RequestOptions & { pollIntervalMs?: number },
|
||||
): Promise<VectorStoreFileBatch> {
|
||||
const batch = await this.create(vectorStoreId, body);
|
||||
return await this.poll(vectorStoreId, batch.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of vector store files in a batch.
|
||||
*/
|
||||
listFiles(
|
||||
vectorStoreId: string,
|
||||
batchId: string,
|
||||
query?: FileBatchListFilesParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoreFilesPage, FilesAPI.VectorStoreFile>;
|
||||
listFiles(
|
||||
vectorStoreId: string,
|
||||
batchId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoreFilesPage, FilesAPI.VectorStoreFile>;
|
||||
listFiles(
|
||||
vectorStoreId: string,
|
||||
batchId: string,
|
||||
query: FileBatchListFilesParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoreFilesPage, FilesAPI.VectorStoreFile> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.listFiles(vectorStoreId, batchId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(
|
||||
`/vector_stores/${vectorStoreId}/file_batches/${batchId}/files`,
|
||||
VectorStoreFilesPage,
|
||||
{ query, ...options, headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers } },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the given file batch to be processed.
|
||||
*
|
||||
* Note: this will return even if one of the files failed to process, you need to
|
||||
* check batch.file_counts.failed_count to handle this case.
|
||||
*/
|
||||
async poll(
|
||||
vectorStoreId: string,
|
||||
batchId: string,
|
||||
options?: Core.RequestOptions & { pollIntervalMs?: number },
|
||||
): Promise<VectorStoreFileBatch> {
|
||||
const headers: { [key: string]: string } = { ...options?.headers, 'X-Stainless-Poll-Helper': 'true' };
|
||||
if (options?.pollIntervalMs) {
|
||||
headers['X-Stainless-Custom-Poll-Interval'] = options.pollIntervalMs.toString();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
const { data: batch, response } = await this.retrieve(vectorStoreId, batchId, {
|
||||
...options,
|
||||
headers,
|
||||
}).withResponse();
|
||||
|
||||
switch (batch.status) {
|
||||
case 'in_progress':
|
||||
let sleepInterval = 5000;
|
||||
|
||||
if (options?.pollIntervalMs) {
|
||||
sleepInterval = options.pollIntervalMs;
|
||||
} else {
|
||||
const headerInterval = response.headers.get('openai-poll-after-ms');
|
||||
if (headerInterval) {
|
||||
const headerIntervalMs = parseInt(headerInterval);
|
||||
if (!isNaN(headerIntervalMs)) {
|
||||
sleepInterval = headerIntervalMs;
|
||||
}
|
||||
}
|
||||
}
|
||||
await sleep(sleepInterval);
|
||||
break;
|
||||
case 'failed':
|
||||
case 'cancelled':
|
||||
case 'completed':
|
||||
return batch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads the given files concurrently and then creates a vector store file batch.
|
||||
*
|
||||
* The concurrency limit is configurable using the `maxConcurrency` parameter.
|
||||
*/
|
||||
async uploadAndPoll(
|
||||
vectorStoreId: string,
|
||||
{ files, fileIds = [] }: { files: Uploadable[]; fileIds?: string[] },
|
||||
options?: Core.RequestOptions & { pollIntervalMs?: number; maxConcurrency?: number },
|
||||
): Promise<VectorStoreFileBatch> {
|
||||
if (files == null || files.length == 0) {
|
||||
throw new Error(
|
||||
`No \`files\` provided to process. If you've already uploaded files you should use \`.createAndPoll()\` instead`,
|
||||
);
|
||||
}
|
||||
|
||||
const configuredConcurrency = options?.maxConcurrency ?? 5;
|
||||
|
||||
// We cap the number of workers at the number of files (so we don't start any unnecessary workers)
|
||||
const concurrencyLimit = Math.min(configuredConcurrency, files.length);
|
||||
|
||||
const client = this._client;
|
||||
const fileIterator = files.values();
|
||||
const allFileIds: string[] = [...fileIds];
|
||||
|
||||
// This code is based on this design. The libraries don't accommodate our environment limits.
|
||||
// https://stackoverflow.com/questions/40639432/what-is-the-best-way-to-limit-concurrency-when-using-es6s-promise-all
|
||||
async function processFiles(iterator: IterableIterator<Uploadable>) {
|
||||
for (let item of iterator) {
|
||||
const fileObj = await client.files.create({ file: item, purpose: 'assistants' }, options);
|
||||
allFileIds.push(fileObj.id);
|
||||
}
|
||||
}
|
||||
|
||||
// Start workers to process results
|
||||
const workers = Array(concurrencyLimit).fill(fileIterator).map(processFiles);
|
||||
|
||||
// Wait for all processing to complete.
|
||||
await allSettledWithThrow(workers);
|
||||
|
||||
return await this.createAndPoll(vectorStoreId, {
|
||||
file_ids: allFileIds,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A batch of files attached to a vector store.
|
||||
*/
|
||||
export interface VectorStoreFileBatch {
|
||||
/**
|
||||
* The identifier, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the vector store files batch was
|
||||
* created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
file_counts: VectorStoreFileBatch.FileCounts;
|
||||
|
||||
/**
|
||||
* The object type, which is always `vector_store.file_batch`.
|
||||
*/
|
||||
object: 'vector_store.files_batch';
|
||||
|
||||
/**
|
||||
* The status of the vector store files batch, which can be either `in_progress`,
|
||||
* `completed`, `cancelled` or `failed`.
|
||||
*/
|
||||
status: 'in_progress' | 'completed' | 'cancelled' | 'failed';
|
||||
|
||||
/**
|
||||
* The ID of the
|
||||
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
|
||||
* that the [File](https://platform.openai.com/docs/api-reference/files) is
|
||||
* attached to.
|
||||
*/
|
||||
vector_store_id: string;
|
||||
}
|
||||
|
||||
export namespace VectorStoreFileBatch {
|
||||
export interface FileCounts {
|
||||
/**
|
||||
* The number of files that where cancelled.
|
||||
*/
|
||||
cancelled: number;
|
||||
|
||||
/**
|
||||
* The number of files that have been processed.
|
||||
*/
|
||||
completed: number;
|
||||
|
||||
/**
|
||||
* The number of files that have failed to process.
|
||||
*/
|
||||
failed: number;
|
||||
|
||||
/**
|
||||
* The number of files that are currently being processed.
|
||||
*/
|
||||
in_progress: number;
|
||||
|
||||
/**
|
||||
* The total number of files.
|
||||
*/
|
||||
total: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface FileBatchCreateParams {
|
||||
/**
|
||||
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
|
||||
* the vector store should use. Useful for tools like `file_search` that can access
|
||||
* files.
|
||||
*/
|
||||
file_ids: Array<string>;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard. Keys are strings with a maximum
|
||||
* length of 64 characters. Values are strings with a maximum length of 512
|
||||
* characters, booleans, or numbers.
|
||||
*/
|
||||
attributes?: Record<string, string | number | boolean> | null;
|
||||
|
||||
/**
|
||||
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
|
||||
* strategy. Only applicable if `file_ids` is non-empty.
|
||||
*/
|
||||
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
|
||||
}
|
||||
|
||||
export interface FileBatchListFilesParams extends CursorPageParams {
|
||||
/**
|
||||
* A cursor for use in pagination. `before` is an object ID that defines your place
|
||||
* in the list. For instance, if you make a list request and receive 100 objects,
|
||||
* starting with obj_foo, your subsequent call can include before=obj_foo in order
|
||||
* to fetch the previous page of the list.
|
||||
*/
|
||||
before?: string;
|
||||
|
||||
/**
|
||||
* Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
|
||||
*/
|
||||
filter?: 'in_progress' | 'completed' | 'failed' | 'cancelled';
|
||||
|
||||
/**
|
||||
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
||||
* order and `desc` for descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export declare namespace FileBatches {
|
||||
export {
|
||||
type VectorStoreFileBatch as VectorStoreFileBatch,
|
||||
type FileBatchCreateParams as FileBatchCreateParams,
|
||||
type FileBatchListFilesParams as FileBatchListFilesParams,
|
||||
};
|
||||
}
|
||||
|
||||
export { VectorStoreFilesPage };
|
||||
+379
@@ -0,0 +1,379 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import { sleep, Uploadable, isRequestOptions } from '../../core';
|
||||
import * as Core from '../../core';
|
||||
import * as VectorStoresAPI from './vector-stores';
|
||||
import { CursorPage, type CursorPageParams, Page } from '../../pagination';
|
||||
|
||||
export class Files extends APIResource {
|
||||
/**
|
||||
* Create a vector store file by attaching a
|
||||
* [File](https://platform.openai.com/docs/api-reference/files) to a
|
||||
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).
|
||||
*/
|
||||
create(
|
||||
vectorStoreId: string,
|
||||
body: FileCreateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<VectorStoreFile> {
|
||||
return this._client.post(`/vector_stores/${vectorStoreId}/files`, {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a vector store file.
|
||||
*/
|
||||
retrieve(
|
||||
vectorStoreId: string,
|
||||
fileId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<VectorStoreFile> {
|
||||
return this._client.get(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update attributes on a vector store file.
|
||||
*/
|
||||
update(
|
||||
vectorStoreId: string,
|
||||
fileId: string,
|
||||
body: FileUpdateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<VectorStoreFile> {
|
||||
return this._client.post(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of vector store files.
|
||||
*/
|
||||
list(
|
||||
vectorStoreId: string,
|
||||
query?: FileListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoreFilesPage, VectorStoreFile>;
|
||||
list(
|
||||
vectorStoreId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoreFilesPage, VectorStoreFile>;
|
||||
list(
|
||||
vectorStoreId: string,
|
||||
query: FileListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoreFilesPage, VectorStoreFile> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list(vectorStoreId, {}, query);
|
||||
}
|
||||
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/files`, VectorStoreFilesPage, {
|
||||
query,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a vector store file. This will remove the file from the vector store but
|
||||
* the file itself will not be deleted. To delete the file, use the
|
||||
* [delete file](https://platform.openai.com/docs/api-reference/files/delete)
|
||||
* endpoint.
|
||||
*/
|
||||
del(
|
||||
vectorStoreId: string,
|
||||
fileId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<VectorStoreFileDeleted> {
|
||||
return this._client.delete(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a file to the given vector store and wait for it to be processed.
|
||||
*/
|
||||
async createAndPoll(
|
||||
vectorStoreId: string,
|
||||
body: FileCreateParams,
|
||||
options?: Core.RequestOptions & { pollIntervalMs?: number },
|
||||
): Promise<VectorStoreFile> {
|
||||
const file = await this.create(vectorStoreId, body, options);
|
||||
return await this.poll(vectorStoreId, file.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the vector store file to finish processing.
|
||||
*
|
||||
* Note: this will return even if the file failed to process, you need to check
|
||||
* file.last_error and file.status to handle these cases
|
||||
*/
|
||||
async poll(
|
||||
vectorStoreId: string,
|
||||
fileId: string,
|
||||
options?: Core.RequestOptions & { pollIntervalMs?: number },
|
||||
): Promise<VectorStoreFile> {
|
||||
const headers: { [key: string]: string } = { ...options?.headers, 'X-Stainless-Poll-Helper': 'true' };
|
||||
if (options?.pollIntervalMs) {
|
||||
headers['X-Stainless-Custom-Poll-Interval'] = options.pollIntervalMs.toString();
|
||||
}
|
||||
while (true) {
|
||||
const fileResponse = await this.retrieve(vectorStoreId, fileId, {
|
||||
...options,
|
||||
headers,
|
||||
}).withResponse();
|
||||
|
||||
const file = fileResponse.data;
|
||||
|
||||
switch (file.status) {
|
||||
case 'in_progress':
|
||||
let sleepInterval = 5000;
|
||||
|
||||
if (options?.pollIntervalMs) {
|
||||
sleepInterval = options.pollIntervalMs;
|
||||
} else {
|
||||
const headerInterval = fileResponse.response.headers.get('openai-poll-after-ms');
|
||||
if (headerInterval) {
|
||||
const headerIntervalMs = parseInt(headerInterval);
|
||||
if (!isNaN(headerIntervalMs)) {
|
||||
sleepInterval = headerIntervalMs;
|
||||
}
|
||||
}
|
||||
}
|
||||
await sleep(sleepInterval);
|
||||
break;
|
||||
case 'failed':
|
||||
case 'completed':
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file to the `files` API and then attach it to the given vector store.
|
||||
*
|
||||
* Note the file will be asynchronously processed (you can use the alternative
|
||||
* polling helper method to wait for processing to complete).
|
||||
*/
|
||||
async upload(
|
||||
vectorStoreId: string,
|
||||
file: Uploadable,
|
||||
options?: Core.RequestOptions,
|
||||
): Promise<VectorStoreFile> {
|
||||
const fileInfo = await this._client.files.create({ file: file, purpose: 'assistants' }, options);
|
||||
return this.create(vectorStoreId, { file_id: fileInfo.id }, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a file to a vector store and poll until processing is complete.
|
||||
*/
|
||||
async uploadAndPoll(
|
||||
vectorStoreId: string,
|
||||
file: Uploadable,
|
||||
options?: Core.RequestOptions & { pollIntervalMs?: number },
|
||||
): Promise<VectorStoreFile> {
|
||||
const fileInfo = await this.upload(vectorStoreId, file, options);
|
||||
return await this.poll(vectorStoreId, fileInfo.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the parsed contents of a vector store file.
|
||||
*/
|
||||
content(
|
||||
vectorStoreId: string,
|
||||
fileId: string,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<FileContentResponsesPage, FileContentResponse> {
|
||||
return this._client.getAPIList(
|
||||
`/vector_stores/${vectorStoreId}/files/${fileId}/content`,
|
||||
FileContentResponsesPage,
|
||||
{ ...options, headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers } },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class VectorStoreFilesPage extends CursorPage<VectorStoreFile> {}
|
||||
|
||||
/**
|
||||
* Note: no pagination actually occurs yet, this is for forwards-compatibility.
|
||||
*/
|
||||
export class FileContentResponsesPage extends Page<FileContentResponse> {}
|
||||
|
||||
/**
|
||||
* A list of files attached to a vector store.
|
||||
*/
|
||||
export interface VectorStoreFile {
|
||||
/**
|
||||
* The identifier, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the vector store file was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* The last error associated with this vector store file. Will be `null` if there
|
||||
* are no errors.
|
||||
*/
|
||||
last_error: VectorStoreFile.LastError | null;
|
||||
|
||||
/**
|
||||
* The object type, which is always `vector_store.file`.
|
||||
*/
|
||||
object: 'vector_store.file';
|
||||
|
||||
/**
|
||||
* The status of the vector store file, which can be either `in_progress`,
|
||||
* `completed`, `cancelled`, or `failed`. The status `completed` indicates that the
|
||||
* vector store file is ready for use.
|
||||
*/
|
||||
status: 'in_progress' | 'completed' | 'cancelled' | 'failed';
|
||||
|
||||
/**
|
||||
* The total vector store usage in bytes. Note that this may be different from the
|
||||
* original file size.
|
||||
*/
|
||||
usage_bytes: number;
|
||||
|
||||
/**
|
||||
* The ID of the
|
||||
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
|
||||
* that the [File](https://platform.openai.com/docs/api-reference/files) is
|
||||
* attached to.
|
||||
*/
|
||||
vector_store_id: string;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard. Keys are strings with a maximum
|
||||
* length of 64 characters. Values are strings with a maximum length of 512
|
||||
* characters, booleans, or numbers.
|
||||
*/
|
||||
attributes?: Record<string, string | number | boolean> | null;
|
||||
|
||||
/**
|
||||
* The strategy used to chunk the file.
|
||||
*/
|
||||
chunking_strategy?: VectorStoresAPI.FileChunkingStrategy;
|
||||
}
|
||||
|
||||
export namespace VectorStoreFile {
|
||||
/**
|
||||
* The last error associated with this vector store file. Will be `null` if there
|
||||
* are no errors.
|
||||
*/
|
||||
export interface LastError {
|
||||
/**
|
||||
* One of `server_error` or `rate_limit_exceeded`.
|
||||
*/
|
||||
code: 'server_error' | 'unsupported_file' | 'invalid_file';
|
||||
|
||||
/**
|
||||
* A human-readable description of the error.
|
||||
*/
|
||||
message: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface VectorStoreFileDeleted {
|
||||
id: string;
|
||||
|
||||
deleted: boolean;
|
||||
|
||||
object: 'vector_store.file.deleted';
|
||||
}
|
||||
|
||||
export interface FileContentResponse {
|
||||
/**
|
||||
* The text content
|
||||
*/
|
||||
text?: string;
|
||||
|
||||
/**
|
||||
* The content type (currently only `"text"`)
|
||||
*/
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface FileCreateParams {
|
||||
/**
|
||||
* A [File](https://platform.openai.com/docs/api-reference/files) ID that the
|
||||
* vector store should use. Useful for tools like `file_search` that can access
|
||||
* files.
|
||||
*/
|
||||
file_id: string;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard. Keys are strings with a maximum
|
||||
* length of 64 characters. Values are strings with a maximum length of 512
|
||||
* characters, booleans, or numbers.
|
||||
*/
|
||||
attributes?: Record<string, string | number | boolean> | null;
|
||||
|
||||
/**
|
||||
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
|
||||
* strategy. Only applicable if `file_ids` is non-empty.
|
||||
*/
|
||||
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
|
||||
}
|
||||
|
||||
export interface FileUpdateParams {
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard. Keys are strings with a maximum
|
||||
* length of 64 characters. Values are strings with a maximum length of 512
|
||||
* characters, booleans, or numbers.
|
||||
*/
|
||||
attributes: Record<string, string | number | boolean> | null;
|
||||
}
|
||||
|
||||
export interface FileListParams extends CursorPageParams {
|
||||
/**
|
||||
* A cursor for use in pagination. `before` is an object ID that defines your place
|
||||
* in the list. For instance, if you make a list request and receive 100 objects,
|
||||
* starting with obj_foo, your subsequent call can include before=obj_foo in order
|
||||
* to fetch the previous page of the list.
|
||||
*/
|
||||
before?: string;
|
||||
|
||||
/**
|
||||
* Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
|
||||
*/
|
||||
filter?: 'in_progress' | 'completed' | 'failed' | 'cancelled';
|
||||
|
||||
/**
|
||||
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
||||
* order and `desc` for descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
Files.VectorStoreFilesPage = VectorStoreFilesPage;
|
||||
Files.FileContentResponsesPage = FileContentResponsesPage;
|
||||
|
||||
export declare namespace Files {
|
||||
export {
|
||||
type VectorStoreFile as VectorStoreFile,
|
||||
type VectorStoreFileDeleted as VectorStoreFileDeleted,
|
||||
type FileContentResponse as FileContentResponse,
|
||||
VectorStoreFilesPage as VectorStoreFilesPage,
|
||||
FileContentResponsesPage as FileContentResponsesPage,
|
||||
type FileCreateParams as FileCreateParams,
|
||||
type FileUpdateParams as FileUpdateParams,
|
||||
type FileListParams as FileListParams,
|
||||
};
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export {
|
||||
FileBatches,
|
||||
type VectorStoreFileBatch,
|
||||
type FileBatchCreateParams,
|
||||
type FileBatchListFilesParams,
|
||||
} from './file-batches';
|
||||
export {
|
||||
VectorStoreFilesPage,
|
||||
FileContentResponsesPage,
|
||||
Files,
|
||||
type VectorStoreFile,
|
||||
type VectorStoreFileDeleted,
|
||||
type FileContentResponse,
|
||||
type FileCreateParams,
|
||||
type FileUpdateParams,
|
||||
type FileListParams,
|
||||
} from './files';
|
||||
export {
|
||||
VectorStoresPage,
|
||||
VectorStoreSearchResponsesPage,
|
||||
VectorStores,
|
||||
type AutoFileChunkingStrategyParam,
|
||||
type FileChunkingStrategy,
|
||||
type FileChunkingStrategyParam,
|
||||
type OtherFileChunkingStrategyObject,
|
||||
type StaticFileChunkingStrategy,
|
||||
type StaticFileChunkingStrategyObject,
|
||||
type StaticFileChunkingStrategyObjectParam,
|
||||
type VectorStore,
|
||||
type VectorStoreDeleted,
|
||||
type VectorStoreSearchResponse,
|
||||
type VectorStoreCreateParams,
|
||||
type VectorStoreUpdateParams,
|
||||
type VectorStoreListParams,
|
||||
type VectorStoreSearchParams,
|
||||
} from './vector-stores';
|
||||
+551
@@ -0,0 +1,551 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../resource';
|
||||
import { isRequestOptions } from '../../core';
|
||||
import * as Core from '../../core';
|
||||
import * as Shared from '../shared';
|
||||
import * as FileBatchesAPI from './file-batches';
|
||||
import {
|
||||
FileBatchCreateParams,
|
||||
FileBatchListFilesParams,
|
||||
FileBatches,
|
||||
VectorStoreFileBatch,
|
||||
} from './file-batches';
|
||||
import * as FilesAPI from './files';
|
||||
import {
|
||||
FileContentResponse,
|
||||
FileContentResponsesPage,
|
||||
FileCreateParams,
|
||||
FileListParams,
|
||||
FileUpdateParams,
|
||||
Files,
|
||||
VectorStoreFile,
|
||||
VectorStoreFileDeleted,
|
||||
VectorStoreFilesPage,
|
||||
} from './files';
|
||||
import { CursorPage, type CursorPageParams, Page } from '../../pagination';
|
||||
|
||||
export class VectorStores extends APIResource {
|
||||
files: FilesAPI.Files = new FilesAPI.Files(this._client);
|
||||
fileBatches: FileBatchesAPI.FileBatches = new FileBatchesAPI.FileBatches(this._client);
|
||||
|
||||
/**
|
||||
* Create a vector store.
|
||||
*/
|
||||
create(body: VectorStoreCreateParams, options?: Core.RequestOptions): Core.APIPromise<VectorStore> {
|
||||
return this._client.post('/vector_stores', {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a vector store.
|
||||
*/
|
||||
retrieve(vectorStoreId: string, options?: Core.RequestOptions): Core.APIPromise<VectorStore> {
|
||||
return this._client.get(`/vector_stores/${vectorStoreId}`, {
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies a vector store.
|
||||
*/
|
||||
update(
|
||||
vectorStoreId: string,
|
||||
body: VectorStoreUpdateParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.APIPromise<VectorStore> {
|
||||
return this._client.post(`/vector_stores/${vectorStoreId}`, {
|
||||
body,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of vector stores.
|
||||
*/
|
||||
list(
|
||||
query?: VectorStoreListParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoresPage, VectorStore>;
|
||||
list(options?: Core.RequestOptions): Core.PagePromise<VectorStoresPage, VectorStore>;
|
||||
list(
|
||||
query: VectorStoreListParams | Core.RequestOptions = {},
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoresPage, VectorStore> {
|
||||
if (isRequestOptions(query)) {
|
||||
return this.list({}, query);
|
||||
}
|
||||
return this._client.getAPIList('/vector_stores', VectorStoresPage, {
|
||||
query,
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a vector store.
|
||||
*/
|
||||
del(vectorStoreId: string, options?: Core.RequestOptions): Core.APIPromise<VectorStoreDeleted> {
|
||||
return this._client.delete(`/vector_stores/${vectorStoreId}`, {
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Search a vector store for relevant chunks based on a query and file attributes
|
||||
* filter.
|
||||
*/
|
||||
search(
|
||||
vectorStoreId: string,
|
||||
body: VectorStoreSearchParams,
|
||||
options?: Core.RequestOptions,
|
||||
): Core.PagePromise<VectorStoreSearchResponsesPage, VectorStoreSearchResponse> {
|
||||
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/search`, VectorStoreSearchResponsesPage, {
|
||||
body,
|
||||
method: 'post',
|
||||
...options,
|
||||
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class VectorStoresPage extends CursorPage<VectorStore> {}
|
||||
|
||||
/**
|
||||
* Note: no pagination actually occurs yet, this is for forwards-compatibility.
|
||||
*/
|
||||
export class VectorStoreSearchResponsesPage extends Page<VectorStoreSearchResponse> {}
|
||||
|
||||
/**
|
||||
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
|
||||
* `800` and `chunk_overlap_tokens` of `400`.
|
||||
*/
|
||||
export interface AutoFileChunkingStrategyParam {
|
||||
/**
|
||||
* Always `auto`.
|
||||
*/
|
||||
type: 'auto';
|
||||
}
|
||||
|
||||
/**
|
||||
* The strategy used to chunk the file.
|
||||
*/
|
||||
export type FileChunkingStrategy = StaticFileChunkingStrategyObject | OtherFileChunkingStrategyObject;
|
||||
|
||||
/**
|
||||
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
|
||||
* strategy. Only applicable if `file_ids` is non-empty.
|
||||
*/
|
||||
export type FileChunkingStrategyParam = AutoFileChunkingStrategyParam | StaticFileChunkingStrategyObjectParam;
|
||||
|
||||
/**
|
||||
* This is returned when the chunking strategy is unknown. Typically, this is
|
||||
* because the file was indexed before the `chunking_strategy` concept was
|
||||
* introduced in the API.
|
||||
*/
|
||||
export interface OtherFileChunkingStrategyObject {
|
||||
/**
|
||||
* Always `other`.
|
||||
*/
|
||||
type: 'other';
|
||||
}
|
||||
|
||||
export interface StaticFileChunkingStrategy {
|
||||
/**
|
||||
* The number of tokens that overlap between chunks. The default value is `400`.
|
||||
*
|
||||
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
|
||||
*/
|
||||
chunk_overlap_tokens: number;
|
||||
|
||||
/**
|
||||
* The maximum number of tokens in each chunk. The default value is `800`. The
|
||||
* minimum value is `100` and the maximum value is `4096`.
|
||||
*/
|
||||
max_chunk_size_tokens: number;
|
||||
}
|
||||
|
||||
export interface StaticFileChunkingStrategyObject {
|
||||
static: StaticFileChunkingStrategy;
|
||||
|
||||
/**
|
||||
* Always `static`.
|
||||
*/
|
||||
type: 'static';
|
||||
}
|
||||
|
||||
/**
|
||||
* Customize your own chunking strategy by setting chunk size and chunk overlap.
|
||||
*/
|
||||
export interface StaticFileChunkingStrategyObjectParam {
|
||||
static: StaticFileChunkingStrategy;
|
||||
|
||||
/**
|
||||
* Always `static`.
|
||||
*/
|
||||
type: 'static';
|
||||
}
|
||||
|
||||
/**
|
||||
* A vector store is a collection of processed files can be used by the
|
||||
* `file_search` tool.
|
||||
*/
|
||||
export interface VectorStore {
|
||||
/**
|
||||
* The identifier, which can be referenced in API endpoints.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the vector store was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
file_counts: VectorStore.FileCounts;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the vector store was last active.
|
||||
*/
|
||||
last_active_at: number | null;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The name of the vector store.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The object type, which is always `vector_store`.
|
||||
*/
|
||||
object: 'vector_store';
|
||||
|
||||
/**
|
||||
* The status of the vector store, which can be either `expired`, `in_progress`, or
|
||||
* `completed`. A status of `completed` indicates that the vector store is ready
|
||||
* for use.
|
||||
*/
|
||||
status: 'expired' | 'in_progress' | 'completed';
|
||||
|
||||
/**
|
||||
* The total number of bytes used by the files in the vector store.
|
||||
*/
|
||||
usage_bytes: number;
|
||||
|
||||
/**
|
||||
* The expiration policy for a vector store.
|
||||
*/
|
||||
expires_after?: VectorStore.ExpiresAfter;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) for when the vector store will expire.
|
||||
*/
|
||||
expires_at?: number | null;
|
||||
}
|
||||
|
||||
export namespace VectorStore {
|
||||
export interface FileCounts {
|
||||
/**
|
||||
* The number of files that were cancelled.
|
||||
*/
|
||||
cancelled: number;
|
||||
|
||||
/**
|
||||
* The number of files that have been successfully processed.
|
||||
*/
|
||||
completed: number;
|
||||
|
||||
/**
|
||||
* The number of files that have failed to process.
|
||||
*/
|
||||
failed: number;
|
||||
|
||||
/**
|
||||
* The number of files that are currently being processed.
|
||||
*/
|
||||
in_progress: number;
|
||||
|
||||
/**
|
||||
* The total number of files.
|
||||
*/
|
||||
total: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The expiration policy for a vector store.
|
||||
*/
|
||||
export interface ExpiresAfter {
|
||||
/**
|
||||
* Anchor timestamp after which the expiration policy applies. Supported anchors:
|
||||
* `last_active_at`.
|
||||
*/
|
||||
anchor: 'last_active_at';
|
||||
|
||||
/**
|
||||
* The number of days after the anchor time that the vector store will expire.
|
||||
*/
|
||||
days: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface VectorStoreDeleted {
|
||||
id: string;
|
||||
|
||||
deleted: boolean;
|
||||
|
||||
object: 'vector_store.deleted';
|
||||
}
|
||||
|
||||
export interface VectorStoreSearchResponse {
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard. Keys are strings with a maximum
|
||||
* length of 64 characters. Values are strings with a maximum length of 512
|
||||
* characters, booleans, or numbers.
|
||||
*/
|
||||
attributes: Record<string, string | number | boolean> | null;
|
||||
|
||||
/**
|
||||
* Content chunks from the file.
|
||||
*/
|
||||
content: Array<VectorStoreSearchResponse.Content>;
|
||||
|
||||
/**
|
||||
* The ID of the vector store file.
|
||||
*/
|
||||
file_id: string;
|
||||
|
||||
/**
|
||||
* The name of the vector store file.
|
||||
*/
|
||||
filename: string;
|
||||
|
||||
/**
|
||||
* The similarity score for the result.
|
||||
*/
|
||||
score: number;
|
||||
}
|
||||
|
||||
export namespace VectorStoreSearchResponse {
|
||||
export interface Content {
|
||||
/**
|
||||
* The text content returned from search.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of content.
|
||||
*/
|
||||
type: 'text';
|
||||
}
|
||||
}
|
||||
|
||||
export interface VectorStoreCreateParams {
|
||||
/**
|
||||
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
|
||||
* strategy. Only applicable if `file_ids` is non-empty.
|
||||
*/
|
||||
chunking_strategy?: FileChunkingStrategyParam;
|
||||
|
||||
/**
|
||||
* The expiration policy for a vector store.
|
||||
*/
|
||||
expires_after?: VectorStoreCreateParams.ExpiresAfter;
|
||||
|
||||
/**
|
||||
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
|
||||
* the vector store should use. Useful for tools like `file_search` that can access
|
||||
* files.
|
||||
*/
|
||||
file_ids?: Array<string>;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The name of the vector store.
|
||||
*/
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export namespace VectorStoreCreateParams {
|
||||
/**
|
||||
* The expiration policy for a vector store.
|
||||
*/
|
||||
export interface ExpiresAfter {
|
||||
/**
|
||||
* Anchor timestamp after which the expiration policy applies. Supported anchors:
|
||||
* `last_active_at`.
|
||||
*/
|
||||
anchor: 'last_active_at';
|
||||
|
||||
/**
|
||||
* The number of days after the anchor time that the vector store will expire.
|
||||
*/
|
||||
days: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface VectorStoreUpdateParams {
|
||||
/**
|
||||
* The expiration policy for a vector store.
|
||||
*/
|
||||
expires_after?: VectorStoreUpdateParams.ExpiresAfter | null;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
|
||||
/**
|
||||
* The name of the vector store.
|
||||
*/
|
||||
name?: string | null;
|
||||
}
|
||||
|
||||
export namespace VectorStoreUpdateParams {
|
||||
/**
|
||||
* The expiration policy for a vector store.
|
||||
*/
|
||||
export interface ExpiresAfter {
|
||||
/**
|
||||
* Anchor timestamp after which the expiration policy applies. Supported anchors:
|
||||
* `last_active_at`.
|
||||
*/
|
||||
anchor: 'last_active_at';
|
||||
|
||||
/**
|
||||
* The number of days after the anchor time that the vector store will expire.
|
||||
*/
|
||||
days: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface VectorStoreListParams extends CursorPageParams {
|
||||
/**
|
||||
* A cursor for use in pagination. `before` is an object ID that defines your place
|
||||
* in the list. For instance, if you make a list request and receive 100 objects,
|
||||
* starting with obj_foo, your subsequent call can include before=obj_foo in order
|
||||
* to fetch the previous page of the list.
|
||||
*/
|
||||
before?: string;
|
||||
|
||||
/**
|
||||
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
||||
* order and `desc` for descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export interface VectorStoreSearchParams {
|
||||
/**
|
||||
* A query string for a search
|
||||
*/
|
||||
query: string | Array<string>;
|
||||
|
||||
/**
|
||||
* A filter to apply based on file attributes.
|
||||
*/
|
||||
filters?: Shared.ComparisonFilter | Shared.CompoundFilter;
|
||||
|
||||
/**
|
||||
* The maximum number of results to return. This number should be between 1 and 50
|
||||
* inclusive.
|
||||
*/
|
||||
max_num_results?: number;
|
||||
|
||||
/**
|
||||
* Ranking options for search.
|
||||
*/
|
||||
ranking_options?: VectorStoreSearchParams.RankingOptions;
|
||||
|
||||
/**
|
||||
* Whether to rewrite the natural language query for vector search.
|
||||
*/
|
||||
rewrite_query?: boolean;
|
||||
}
|
||||
|
||||
export namespace VectorStoreSearchParams {
|
||||
/**
|
||||
* Ranking options for search.
|
||||
*/
|
||||
export interface RankingOptions {
|
||||
ranker?: 'auto' | 'default-2024-11-15';
|
||||
|
||||
score_threshold?: number;
|
||||
}
|
||||
}
|
||||
|
||||
VectorStores.VectorStoresPage = VectorStoresPage;
|
||||
VectorStores.VectorStoreSearchResponsesPage = VectorStoreSearchResponsesPage;
|
||||
VectorStores.Files = Files;
|
||||
VectorStores.VectorStoreFilesPage = VectorStoreFilesPage;
|
||||
VectorStores.FileContentResponsesPage = FileContentResponsesPage;
|
||||
VectorStores.FileBatches = FileBatches;
|
||||
|
||||
export declare namespace VectorStores {
|
||||
export {
|
||||
type AutoFileChunkingStrategyParam as AutoFileChunkingStrategyParam,
|
||||
type FileChunkingStrategy as FileChunkingStrategy,
|
||||
type FileChunkingStrategyParam as FileChunkingStrategyParam,
|
||||
type OtherFileChunkingStrategyObject as OtherFileChunkingStrategyObject,
|
||||
type StaticFileChunkingStrategy as StaticFileChunkingStrategy,
|
||||
type StaticFileChunkingStrategyObject as StaticFileChunkingStrategyObject,
|
||||
type StaticFileChunkingStrategyObjectParam as StaticFileChunkingStrategyObjectParam,
|
||||
type VectorStore as VectorStore,
|
||||
type VectorStoreDeleted as VectorStoreDeleted,
|
||||
type VectorStoreSearchResponse as VectorStoreSearchResponse,
|
||||
VectorStoresPage as VectorStoresPage,
|
||||
VectorStoreSearchResponsesPage as VectorStoreSearchResponsesPage,
|
||||
type VectorStoreCreateParams as VectorStoreCreateParams,
|
||||
type VectorStoreUpdateParams as VectorStoreUpdateParams,
|
||||
type VectorStoreListParams as VectorStoreListParams,
|
||||
type VectorStoreSearchParams as VectorStoreSearchParams,
|
||||
};
|
||||
|
||||
export {
|
||||
Files as Files,
|
||||
type VectorStoreFile as VectorStoreFile,
|
||||
type VectorStoreFileDeleted as VectorStoreFileDeleted,
|
||||
type FileContentResponse as FileContentResponse,
|
||||
VectorStoreFilesPage as VectorStoreFilesPage,
|
||||
FileContentResponsesPage as FileContentResponsesPage,
|
||||
type FileCreateParams as FileCreateParams,
|
||||
type FileUpdateParams as FileUpdateParams,
|
||||
type FileListParams as FileListParams,
|
||||
};
|
||||
|
||||
export {
|
||||
FileBatches as FileBatches,
|
||||
type VectorStoreFileBatch as VectorStoreFileBatch,
|
||||
type FileBatchCreateParams as FileBatchCreateParams,
|
||||
type FileBatchListFilesParams as FileBatchListFilesParams,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user