🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ai-sdk/provider

Package Overview
Dependencies
Maintainers
3
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/provider - npm Package Compare versions

Comparing version
4.0.3
to
4.0.4
+14
src/shared/v4/shared-v4-audio-format.ts
/**
* Audio format configuration shared by provider V4 model specifications.
*/
export type SharedV4AudioFormat = {
/**
* Audio format type, e.g. `audio/pcm`, `audio/pcmu`, or `audio/pcma`.
*/
type: string;
/**
* Sample rate in Hz. Only applicable for formats that require a rate.
*/
rate?: number;
};
export * from './v4/index';
export type { SpeechTranslationModelV4 as Experimental_SpeechTranslationModelV4 } from './speech-translation-model-v4';
export type { SpeechTranslationModelV4StreamOptions as Experimental_SpeechTranslationModelV4StreamOptions } from './speech-translation-model-v4-stream-options';
export type { SpeechTranslationModelV4StreamPart as Experimental_SpeechTranslationModelV4StreamPart } from './speech-translation-model-v4-stream-part';
export type { SpeechTranslationModelV4StreamResult as Experimental_SpeechTranslationModelV4StreamResult } from './speech-translation-model-v4-stream-result';
export type { SpeechTranslationModelV4Usage as Experimental_SpeechTranslationModelV4Usage } from './speech-translation-model-v4-usage';
import type { JSONObject } from '../../json-value/json-value';
import type { SharedV4AudioFormat } from '../../shared';
type SpeechTranslationModelV4ProviderOptions = Record<string, JSONObject>;
/**
* Options for a speech translation model stream call.
*/
export type SpeechTranslationModelV4StreamOptions = {
/**
* Source audio chunks to transform.
*
* `Uint8Array` chunks contain raw audio bytes. `string` chunks contain
* base64-encoded raw audio bytes.
*/
audio: ReadableStream<Uint8Array | string>;
/**
* The input audio format for the raw audio chunks.
*/
inputAudioFormat: SharedV4AudioFormat;
/**
* The language to produce output audio and text in, as a BCP-47-style
* language tag (e.g. `en`, `es`, `fr-CA`). Supported values are
* provider-specific and validated by the provider.
*/
targetLanguage: string;
/**
* The language of the source audio, as a BCP-47-style language tag.
* When absent, providers should auto-detect the source language.
*/
sourceLanguage?: string;
/**
* The desired audio format for output audio chunks.
* When absent, the provider default output format is used.
*/
outputAudioFormat?: SharedV4AudioFormat;
/**
* Additional provider-specific options that are passed through to the provider.
*
* The outer record is keyed by the provider name, and the inner record is keyed
* by provider-specific option names.
*/
providerOptions?: SpeechTranslationModelV4ProviderOptions;
/**
* Abort signal for cancelling the operation.
*/
abortSignal?: AbortSignal;
/**
* Additional HTTP headers to be sent with the request.
* Only applicable for HTTP/WebSocket-based providers that support headers.
*/
headers?: Record<string, string | undefined>;
/**
* When true, providers should include raw provider chunks in the stream.
*/
includeRawChunks?: boolean;
};
import type { JSONObject } from '../../json-value/json-value';
import type { SharedV4Headers } from '../../shared';
import type { SharedV4ProviderMetadata } from '../../shared/v4/shared-v4-provider-metadata';
import type { SharedV4Warning } from '../../shared/v4/shared-v4-warning';
import type { SpeechTranslationModelV4Usage } from './speech-translation-model-v4-usage';
export type SpeechTranslationModelV4StreamPart =
| {
/**
* Stream start event with warnings for the call, e.g. unsupported settings.
*/
type: 'stream-start';
warnings: Array<SharedV4Warning>;
}
| {
/**
* Output audio chunk.
*
* `Uint8Array` chunks contain raw audio bytes. `string` chunks contain
* base64-encoded raw audio bytes.
*/
type: 'audio';
id?: string;
audio: Uint8Array | string;
providerMetadata?: SharedV4ProviderMetadata;
}
| {
/**
* Append-only output text delta.
*
* Output text is append-only: providers stream `output-text-delta`
* parts and finalize per-utterance with `output-text-final`. There is
* no partial/revision part for output text by design for now.
*/
type: 'output-text-delta';
id?: string;
delta: string;
providerMetadata?: SharedV4ProviderMetadata;
}
| {
/**
* Final output text for a provider-defined segment or utterance.
*
* Output text is append-only: providers stream `output-text-delta`
* parts and finalize per-utterance with `output-text-final`. There is
* no partial/revision part for output text by design for now.
*/
type: 'output-text-final';
id?: string;
text: string;
providerMetadata?: SharedV4ProviderMetadata;
}
| {
/**
* Append-only source transcript delta.
*/
type: 'source-transcript-delta';
id?: string;
delta: string;
providerMetadata?: SharedV4ProviderMetadata;
}
| {
/**
* Non-final source transcript text. The text may be revised by later parts.
*/
type: 'source-transcript-partial';
id?: string;
text: string;
startSecond?: number;
endSecond?: number;
channelIndex?: number;
providerMetadata?: SharedV4ProviderMetadata;
}
| {
/**
* Final source transcript text for a provider-defined segment or utterance.
*/
type: 'source-transcript-final';
id?: string;
text: string;
startSecond?: number;
endSecond?: number;
channelIndex?: number;
providerMetadata?: SharedV4ProviderMetadata;
}
| {
/**
* Metadata for the response, emitted once available.
*/
type: 'response-metadata';
timestamp?: Date;
modelId?: string;
headers?: SharedV4Headers;
body?: unknown;
}
| {
/**
* Metadata that is available after the stream is finished.
*/
type: 'finish';
/**
* The final source-language transcript of the input audio.
*/
sourceText: string;
/**
* The final output text. May be an empty string for providers that
* produce only audio output.
*/
outputText: string;
/**
* The duration of the source audio in seconds, if available.
*/
durationInSeconds?: number;
/**
* Usage information for the call, if reported by the provider.
*/
usage?: SpeechTranslationModelV4Usage;
/**
* Additional provider-specific metadata.
*/
providerMetadata?: Record<string, JSONObject>;
}
| {
/**
* Raw provider chunks if enabled.
*/
type: 'raw';
rawValue: unknown;
}
| {
/**
* Error parts are streamed, allowing for multiple errors.
*/
type: 'error';
error: unknown;
};
import type { SharedV4Headers } from '../../shared';
import type { SpeechTranslationModelV4StreamPart } from './speech-translation-model-v4-stream-part';
/**
* The result of a speech translation model doStream call.
*/
export type SpeechTranslationModelV4StreamResult = {
/**
* The stream.
*/
stream: ReadableStream<SpeechTranslationModelV4StreamPart>;
/**
* Optional request information for telemetry and debugging purposes.
*/
request?: {
/**
* Request body or setup payload that was sent to the provider API.
*/
body?: unknown;
};
/**
* Optional response data.
*/
response?: {
/**
* Timestamp for the start of the streamed response.
*/
timestamp?: Date;
/**
* The ID of the response model that was used to generate the response.
*/
modelId?: string;
/**
* Response headers.
*/
headers?: SharedV4Headers;
/**
* Response body.
*/
body?: unknown;
};
};
/**
* Usage information for a speech translation call.
*
* All fields are optional because providers report usage with different
* granularity (seconds of audio, audio tokens, and/or text tokens).
*/
export type SpeechTranslationModelV4Usage = {
/**
* Seconds of input audio that were processed, if reported.
*/
inputAudioSeconds?: number;
/**
* Number of input audio tokens, if reported.
*/
inputAudioTokens?: number;
/**
* Number of output audio tokens, if reported.
*/
outputAudioTokens?: number;
/**
* Number of input text tokens, if reported.
*/
inputTextTokens?: number;
/**
* Number of output text tokens, if reported.
*/
outputTextTokens?: number;
};
import type { SpeechTranslationModelV4StreamOptions } from './speech-translation-model-v4-stream-options';
import type { SpeechTranslationModelV4StreamResult } from './speech-translation-model-v4-stream-result';
/**
* Speech translation model specification version 4.
*
* Speech translation is a streaming-only modality: models translate live
* source audio into target-language audio and text.
*
* Experimental: the speech translation model contract may change in patch
* releases while the functions built on it are experimental. All types of
* this modality are exported with `Experimental_` prefixes for this reason.
*/
export type SpeechTranslationModelV4 = {
/**
* The speech translation model must specify which speech translation model
* interface version it implements. This will allow us to evolve the
* speech translation model interface and retain backwards compatibility.
* The different implementation versions can be handled as a discriminated
* union on our side.
*/
readonly specificationVersion: 'v4';
/**
* Name of the provider for logging purposes.
*/
readonly provider: string;
/**
* Provider-specific model ID for logging purposes.
*/
readonly modelId: string;
/**
* Streams a speech translation for live audio.
*/
doStream(
options: SpeechTranslationModelV4StreamOptions,
): PromiseLike<SpeechTranslationModelV4StreamResult>;
};
+6
-0
# @ai-sdk/provider
## 4.0.4
### Patch Changes
- 1e2f324: feat: add experimental speech translation model specification (`Experimental_SpeechTranslationModelV4`) and `experimental_streamTranslate` for streaming speech-to-speech translation
## 4.0.3

@@ -4,0 +10,0 @@

+1
-1
{
"name": "@ai-sdk/provider",
"version": "4.0.3",
"version": "4.0.4",
"type": "module",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -6,3 +6,3 @@ import type { EmbeddingModelV4CallOptions } from './embedding-model-v4-call-options';

* Specification for an embedding model that implements the embedding model
* interface version 3.
* interface version 4.
*

@@ -9,0 +9,0 @@ * It is specific to text embeddings.

@@ -9,3 +9,3 @@ import type { ImageModelV4CallOptions } from './image-model-v4-call-options';

/**
* Image generation model specification version 3.
* Image generation model specification version 4.
*/

@@ -12,0 +12,0 @@ export type ImageModelV4 = {

@@ -16,2 +16,3 @@ export * from './embedding-model/index';

export * from './speech-model/index';
export * from './speech-translation-model/index';
export * from './transcription-model/index';

@@ -18,0 +19,0 @@ export * from './video-model/index';

@@ -0,1 +1,2 @@

import type { SharedV4AudioFormat } from '../../shared';
import type { RealtimeModelV4ToolDefinition } from './realtime-model-v4-tool-definition';

@@ -26,14 +27,4 @@

*/
inputAudioFormat?: {
/**
* Audio format type (e.g. "audio/pcm", "audio/pcmu", "audio/pcma").
*/
type: string;
inputAudioFormat?: SharedV4AudioFormat;
/**
* Sample rate in Hz. Only applicable for PCM format.
*/
rate?: number;
};
/**

@@ -91,14 +82,4 @@ * Input audio transcription configuration.

*/
outputAudioFormat?: {
/**
* Audio format type (e.g. "audio/pcm", "audio/pcmu", "audio/pcma").
*/
type: string;
outputAudioFormat?: SharedV4AudioFormat;
/**
* Sample rate in Hz. Only applicable for PCM format.
*/
rate?: number;
};
/**

@@ -105,0 +86,0 @@ * Voice activity detection configuration.

@@ -5,3 +5,3 @@ import type { RerankingModelV4CallOptions } from './reranking-model-v4-call-options';

/**
* Specification for a reranking model that implements the reranking model interface version 3.
* Specification for a reranking model that implements the reranking model interface version 4.
*/

@@ -8,0 +8,0 @@ export type RerankingModelV4 = {

@@ -0,1 +1,2 @@

export * from './shared-v4-audio-format';
export * from './shared-v4-file-data';

@@ -2,0 +3,0 @@ export * from './shared-v4-headers';

@@ -5,3 +5,3 @@ import type { SpeechModelV4CallOptions } from './speech-model-v4-call-options';

/**
* Speech model specification version 3.
* Speech model specification version 4.
*/

@@ -8,0 +8,0 @@ export type SpeechModelV4 = {

import type { JSONObject } from '../../json-value/json-value';
import type { SharedV4AudioFormat } from '../../shared';

@@ -17,14 +18,4 @@ type TranscriptionModelV4ProviderOptions = Record<string, JSONObject>;

*/
inputAudioFormat: {
/**
* Audio format type, e.g. `audio/pcm`, `audio/pcmu`, or `audio/pcma`.
*/
type: string;
inputAudioFormat: SharedV4AudioFormat;
/**
* Sample rate in Hz. Only applicable for formats that require a rate.
*/
rate?: number;
};
/**

@@ -31,0 +22,0 @@ * Additional provider-specific options that are passed through to the provider.

@@ -7,3 +7,3 @@ import type { TranscriptionModelV4CallOptions } from './transcription-model-v4-call-options';

/**
* Transcription model specification version 3.
* Transcription model specification version 4.
*/

@@ -10,0 +10,0 @@ export type TranscriptionModelV4 = {

@@ -9,3 +9,3 @@ import type { VideoModelV4CallOptions } from './video-model-v4-call-options';

/**
* Video generation model specification version 3.
* Video generation model specification version 4.
*/

@@ -12,0 +12,0 @@ export type VideoModelV4 = {

Sorry, the diff of this file is too big to display