@vellumai/assistant 0.10.10-dev.202607201338.c6dec1d → 0.10.10-dev.202607201449.71ed188
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/openapi.yaml
CHANGED
|
@@ -30188,6 +30188,53 @@ paths:
|
|
|
30188
30188
|
- description
|
|
30189
30189
|
- scopeOptions
|
|
30190
30190
|
additionalProperties: false
|
|
30191
|
+
/v1/tts/managed-voices:
|
|
30192
|
+
get:
|
|
30193
|
+
operationId: tts_managedvoices_get
|
|
30194
|
+
summary: List managed TTS voices
|
|
30195
|
+
description:
|
|
30196
|
+
Return the voices offered by Vellum managed TTS, fetched live from the platform. Only currently-usable
|
|
30197
|
+
voices are returned; defaultModel is always one of them (null when none are offered).
|
|
30198
|
+
tags:
|
|
30199
|
+
- tts
|
|
30200
|
+
responses:
|
|
30201
|
+
"200":
|
|
30202
|
+
description: Successful response
|
|
30203
|
+
content:
|
|
30204
|
+
application/json:
|
|
30205
|
+
schema:
|
|
30206
|
+
type: object
|
|
30207
|
+
properties:
|
|
30208
|
+
voices:
|
|
30209
|
+
type: array
|
|
30210
|
+
items:
|
|
30211
|
+
type: object
|
|
30212
|
+
properties:
|
|
30213
|
+
model:
|
|
30214
|
+
type: string
|
|
30215
|
+
label:
|
|
30216
|
+
type: string
|
|
30217
|
+
description:
|
|
30218
|
+
type: string
|
|
30219
|
+
sampleUrl:
|
|
30220
|
+
type: string
|
|
30221
|
+
source:
|
|
30222
|
+
type: string
|
|
30223
|
+
required:
|
|
30224
|
+
- model
|
|
30225
|
+
- label
|
|
30226
|
+
- description
|
|
30227
|
+
- sampleUrl
|
|
30228
|
+
- source
|
|
30229
|
+
additionalProperties: false
|
|
30230
|
+
defaultModel:
|
|
30231
|
+
anyOf:
|
|
30232
|
+
- type: string
|
|
30233
|
+
- type: "null"
|
|
30234
|
+
required:
|
|
30235
|
+
- voices
|
|
30236
|
+
- defaultModel
|
|
30237
|
+
additionalProperties: false
|
|
30191
30238
|
/v1/tts/providers:
|
|
30192
30239
|
get:
|
|
30193
30240
|
operationId: tts_providers_get
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ mock.module("./client.js", () => ({
|
|
|
16
16
|
import {
|
|
17
17
|
managedSpeechSynthesize,
|
|
18
18
|
managedSpeechTranscribe,
|
|
19
|
+
managedSpeechVoices,
|
|
19
20
|
} from "./managed-speech.js";
|
|
20
21
|
|
|
21
22
|
const AUDIO = Buffer.from([0x01, 0x02, 0x03, 0xff]);
|
|
@@ -132,6 +133,84 @@ describe("managedSpeechTranscribe", () => {
|
|
|
132
133
|
});
|
|
133
134
|
});
|
|
134
135
|
|
|
136
|
+
describe("managedSpeechVoices", () => {
|
|
137
|
+
const CATALOG = {
|
|
138
|
+
voices: [
|
|
139
|
+
{
|
|
140
|
+
model: "aura-2-thalia-en",
|
|
141
|
+
label: "Thalia",
|
|
142
|
+
description: "American · clear, confident, energetic",
|
|
143
|
+
sampleUrl: "https://static.deepgram.com/examples/Aura-2-thalia.wav",
|
|
144
|
+
source: "deepgram",
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
defaultModel: "aura-2-thalia-en",
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
beforeEach(() => {
|
|
151
|
+
mockClient = {
|
|
152
|
+
platformAssistantId: "asst-123",
|
|
153
|
+
fetch: mock(async () => Response.json(CATALOG)),
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
afterEach(() => {
|
|
158
|
+
mockClient = null;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("fetches and parses the platform voice catalog", async () => {
|
|
162
|
+
const result = await managedSpeechVoices();
|
|
163
|
+
|
|
164
|
+
expect(result.ok).toBe(true);
|
|
165
|
+
if (result.ok) {
|
|
166
|
+
expect(result.value).toEqual(CATALOG);
|
|
167
|
+
}
|
|
168
|
+
const [path, init] = mockClient!.fetch.mock.calls[0] as [
|
|
169
|
+
string,
|
|
170
|
+
RequestInit,
|
|
171
|
+
];
|
|
172
|
+
expect(path).toBe("/v1/assistants/asst-123/managed-speech/tts/voices/");
|
|
173
|
+
expect(init.method).toBe("GET");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("drops malformed voice entries and tolerates a null default", async () => {
|
|
177
|
+
mockClient!.fetch = mock(async () =>
|
|
178
|
+
Response.json({
|
|
179
|
+
voices: [CATALOG.voices[0], { model: "missing-fields" }],
|
|
180
|
+
defaultModel: null,
|
|
181
|
+
}),
|
|
182
|
+
);
|
|
183
|
+
const result = await managedSpeechVoices();
|
|
184
|
+
|
|
185
|
+
expect(result.ok).toBe(true);
|
|
186
|
+
if (result.ok) {
|
|
187
|
+
expect(result.value.voices).toEqual(CATALOG.voices);
|
|
188
|
+
expect(result.value.defaultModel).toBeNull();
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test("treats a malformed body as a platform error", async () => {
|
|
193
|
+
mockClient!.fetch = mock(async () => Response.json({ nope: true }));
|
|
194
|
+
const result = await managedSpeechVoices();
|
|
195
|
+
expect(result).toMatchObject({ ok: false, kind: "platform-error" });
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("propagates platform error responses", async () => {
|
|
199
|
+
mockClient!.fetch = mock(
|
|
200
|
+
async () =>
|
|
201
|
+
new Response(JSON.stringify({ code: "x", detail: "nope" }), {
|
|
202
|
+
status: 502,
|
|
203
|
+
}),
|
|
204
|
+
);
|
|
205
|
+
const result = await managedSpeechVoices();
|
|
206
|
+
expect(result).toMatchObject({
|
|
207
|
+
ok: false,
|
|
208
|
+
kind: "platform-error",
|
|
209
|
+
status: 502,
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
135
214
|
describe("managedSpeechSynthesize", () => {
|
|
136
215
|
const MP3_BYTES = Buffer.from([0x49, 0x44, 0x33, 0x04, 0x00]);
|
|
137
216
|
|
|
@@ -186,6 +186,83 @@ export async function managedSpeechSynthesize(input: {
|
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
export interface ManagedSpeechVoice {
|
|
190
|
+
model: string;
|
|
191
|
+
label: string;
|
|
192
|
+
description: string;
|
|
193
|
+
sampleUrl: string;
|
|
194
|
+
/** Upstream provider that synthesizes this voice (e.g. "deepgram"). */
|
|
195
|
+
source: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface ManagedSpeechVoiceCatalog {
|
|
199
|
+
/** Offered voices in display order; only currently-usable voices. */
|
|
200
|
+
voices: ManagedSpeechVoice[];
|
|
201
|
+
/** Always one of `voices`; null when no voices are offered. */
|
|
202
|
+
defaultModel: string | null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function parseVoice(value: unknown): ManagedSpeechVoice | null {
|
|
206
|
+
const voice = value as Partial<Record<keyof ManagedSpeechVoice, unknown>>;
|
|
207
|
+
if (
|
|
208
|
+
typeof voice?.model !== "string" ||
|
|
209
|
+
typeof voice.label !== "string" ||
|
|
210
|
+
typeof voice.description !== "string" ||
|
|
211
|
+
typeof voice.sampleUrl !== "string" ||
|
|
212
|
+
typeof voice.source !== "string"
|
|
213
|
+
) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
model: voice.model,
|
|
218
|
+
label: voice.label,
|
|
219
|
+
description: voice.description,
|
|
220
|
+
sampleUrl: voice.sampleUrl,
|
|
221
|
+
source: voice.source,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export async function managedSpeechVoices(input?: {
|
|
226
|
+
signal?: AbortSignal;
|
|
227
|
+
}): Promise<ManagedSpeechResult<ManagedSpeechVoiceCatalog>> {
|
|
228
|
+
const resolved = await resolveClient();
|
|
229
|
+
if ("error" in resolved) {
|
|
230
|
+
return resolved.error;
|
|
231
|
+
}
|
|
232
|
+
const { client } = resolved;
|
|
233
|
+
|
|
234
|
+
const response = await client.fetch(
|
|
235
|
+
`/v1/assistants/${encodeURIComponent(client.platformAssistantId)}/managed-speech/tts/voices/`,
|
|
236
|
+
{ method: "GET", signal: input?.signal },
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
if (!response.ok) {
|
|
240
|
+
return await platformError(response, "voice listing");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const body: unknown = await response.json().catch(() => null);
|
|
244
|
+
const raw = body as { voices?: unknown; defaultModel?: unknown } | null;
|
|
245
|
+
const voices = Array.isArray(raw?.voices)
|
|
246
|
+
? raw.voices.map(parseVoice).filter((v): v is ManagedSpeechVoice => !!v)
|
|
247
|
+
: null;
|
|
248
|
+
if (!voices) {
|
|
249
|
+
return {
|
|
250
|
+
ok: false,
|
|
251
|
+
kind: "platform-error",
|
|
252
|
+
status: response.status,
|
|
253
|
+
message: "Managed speech voice listing returned a malformed response.",
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
ok: true,
|
|
258
|
+
value: {
|
|
259
|
+
voices,
|
|
260
|
+
defaultModel:
|
|
261
|
+
typeof raw?.defaultModel === "string" ? raw.defaultModel : null,
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
189
266
|
async function platformError(
|
|
190
267
|
response: Response,
|
|
191
268
|
operation: string,
|
|
@@ -121,13 +121,17 @@ afterEach(() => {
|
|
|
121
121
|
// ---------------------------------------------------------------------------
|
|
122
122
|
|
|
123
123
|
describe("tts-routes", () => {
|
|
124
|
-
test("exports route definitions for tts/providers, tts/synthesize, and tts/synthesize-cli", () => {
|
|
125
|
-
expect(ROUTES).toHaveLength(
|
|
124
|
+
test("exports route definitions for tts/providers, tts/managed-voices, tts/synthesize, and tts/synthesize-cli", () => {
|
|
125
|
+
expect(ROUTES).toHaveLength(4);
|
|
126
126
|
|
|
127
127
|
const providers = getRoute("tts/providers");
|
|
128
128
|
expect(providers.method).toBe("GET");
|
|
129
129
|
expect(providers.policy?.requiredScopes).toContain("settings.read");
|
|
130
130
|
|
|
131
|
+
const managedVoices = getRoute("tts/managed-voices");
|
|
132
|
+
expect(managedVoices.method).toBe("GET");
|
|
133
|
+
expect(managedVoices.policy?.requiredScopes).toContain("settings.read");
|
|
134
|
+
|
|
131
135
|
const synthesize = getRoute("tts/synthesize");
|
|
132
136
|
expect(synthesize.method).toBe("POST");
|
|
133
137
|
expect(synthesize.policy?.requiredScopes).toContain("chat.read");
|
|
@@ -9,6 +9,7 @@ import { z } from "zod";
|
|
|
9
9
|
|
|
10
10
|
import { sanitizeForTts } from "../../calls/tts-text-sanitizer.js";
|
|
11
11
|
import { getConfig } from "../../config/loader.js";
|
|
12
|
+
import { managedSpeechVoices } from "../../platform/managed-speech.js";
|
|
12
13
|
import { listCatalogProvidersForDisplay } from "../../tts/provider-catalog.js";
|
|
13
14
|
import {
|
|
14
15
|
synthesizeText,
|
|
@@ -131,6 +132,17 @@ function handleListTtsProviders() {
|
|
|
131
132
|
return { providers: listCatalogProvidersForDisplay() };
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
async function handleListManagedVoices() {
|
|
136
|
+
const result = await managedSpeechVoices();
|
|
137
|
+
if (!result.ok) {
|
|
138
|
+
if (result.kind === "unavailable") {
|
|
139
|
+
throw new ServiceUnavailableError(result.message);
|
|
140
|
+
}
|
|
141
|
+
throw new BadGatewayError(result.message);
|
|
142
|
+
}
|
|
143
|
+
return result.value;
|
|
144
|
+
}
|
|
145
|
+
|
|
134
146
|
async function handleSynthesizeTts({ body }: RouteHandlerArgs) {
|
|
135
147
|
if (!body?.text || typeof body.text !== "string") {
|
|
136
148
|
throw new BadRequestError("text is required");
|
|
@@ -222,6 +234,32 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
222
234
|
}),
|
|
223
235
|
handler: handleListTtsProviders,
|
|
224
236
|
},
|
|
237
|
+
{
|
|
238
|
+
operationId: "tts_managed_voices",
|
|
239
|
+
endpoint: "tts/managed-voices",
|
|
240
|
+
method: "GET",
|
|
241
|
+
policy: {
|
|
242
|
+
requiredScopes: ["settings.read"],
|
|
243
|
+
allowedPrincipalTypes: ACTOR_PRINCIPALS,
|
|
244
|
+
},
|
|
245
|
+
summary: "List managed TTS voices",
|
|
246
|
+
description:
|
|
247
|
+
"Return the voices offered by Vellum managed TTS, fetched live from the platform. Only currently-usable voices are returned; defaultModel is always one of them (null when none are offered).",
|
|
248
|
+
tags: ["tts"],
|
|
249
|
+
responseBody: z.object({
|
|
250
|
+
voices: z.array(
|
|
251
|
+
z.object({
|
|
252
|
+
model: z.string(),
|
|
253
|
+
label: z.string(),
|
|
254
|
+
description: z.string(),
|
|
255
|
+
sampleUrl: z.string(),
|
|
256
|
+
source: z.string(),
|
|
257
|
+
}),
|
|
258
|
+
),
|
|
259
|
+
defaultModel: z.string().nullable(),
|
|
260
|
+
}),
|
|
261
|
+
handler: handleListManagedVoices,
|
|
262
|
+
},
|
|
225
263
|
{
|
|
226
264
|
operationId: "tts_synthesize",
|
|
227
265
|
endpoint: "tts/synthesize",
|