@rudderjs/ai 1.4.0 → 1.6.0
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/README.md +484 -7
- package/boost/guidelines.md +62 -2
- package/boost/skills/ai-tools/SKILL.md +14 -5
- package/dist/agent.d.ts +66 -15
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +529 -58
- package/dist/agent.js.map +1 -1
- package/dist/budget/pricing.d.ts +124 -0
- package/dist/budget/pricing.d.ts.map +1 -0
- package/dist/budget/pricing.js +175 -0
- package/dist/budget/pricing.js.map +1 -0
- package/dist/budget/storage.d.ts +104 -0
- package/dist/budget/storage.d.ts.map +1 -0
- package/dist/budget/storage.js +0 -0
- package/dist/budget/storage.js.map +1 -0
- package/dist/budget/with-budget.d.ts +119 -0
- package/dist/budget/with-budget.d.ts.map +1 -0
- package/dist/budget/with-budget.js +175 -0
- package/dist/budget/with-budget.js.map +1 -0
- package/dist/budget-orm/index.d.ts +96 -0
- package/dist/budget-orm/index.d.ts.map +1 -0
- package/dist/budget-orm/index.js +177 -0
- package/dist/budget-orm/index.js.map +1 -0
- package/dist/commands/ai-eval.d.ts +93 -0
- package/dist/commands/ai-eval.d.ts.map +1 -0
- package/dist/commands/ai-eval.js +378 -0
- package/dist/commands/ai-eval.js.map +1 -0
- package/dist/computer-use/actions.d.ts +214 -0
- package/dist/computer-use/actions.d.ts.map +1 -0
- package/dist/computer-use/actions.js +48 -0
- package/dist/computer-use/actions.js.map +1 -0
- package/dist/computer-use/errors.d.ts +57 -0
- package/dist/computer-use/errors.d.ts.map +1 -0
- package/dist/computer-use/errors.js +76 -0
- package/dist/computer-use/errors.js.map +1 -0
- package/dist/computer-use/index.d.ts +53 -0
- package/dist/computer-use/index.d.ts.map +1 -0
- package/dist/computer-use/index.js +51 -0
- package/dist/computer-use/index.js.map +1 -0
- package/dist/computer-use/playwright.d.ts +76 -0
- package/dist/computer-use/playwright.d.ts.map +1 -0
- package/dist/computer-use/playwright.js +270 -0
- package/dist/computer-use/playwright.js.map +1 -0
- package/dist/computer-use/tool.d.ts +154 -0
- package/dist/computer-use/tool.d.ts.map +1 -0
- package/dist/computer-use/tool.js +210 -0
- package/dist/computer-use/tool.js.map +1 -0
- package/dist/eval/fixtures.d.ts +65 -0
- package/dist/eval/fixtures.d.ts.map +1 -0
- package/dist/eval/fixtures.js +110 -0
- package/dist/eval/fixtures.js.map +1 -0
- package/dist/eval/html-reporter.d.ts +25 -0
- package/dist/eval/html-reporter.d.ts.map +1 -0
- package/dist/eval/html-reporter.js +209 -0
- package/dist/eval/html-reporter.js.map +1 -0
- package/dist/eval/index.d.ts +271 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +510 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/json-reporter.d.ts +43 -0
- package/dist/eval/json-reporter.d.ts.map +1 -0
- package/dist/eval/json-reporter.js +40 -0
- package/dist/eval/json-reporter.js.map +1 -0
- package/dist/fake.d.ts +36 -1
- package/dist/fake.d.ts.map +1 -1
- package/dist/fake.js +49 -2
- package/dist/fake.js.map +1 -1
- package/dist/file-search.d.ts +168 -0
- package/dist/file-search.d.ts.map +1 -0
- package/dist/file-search.js +158 -0
- package/dist/file-search.js.map +1 -0
- package/dist/handoff.d.ts +95 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +78 -0
- package/dist/handoff.js.map +1 -0
- package/dist/index.d.ts +29 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/client-tools.d.ts +39 -0
- package/dist/mcp/client-tools.d.ts.map +1 -0
- package/dist/mcp/client-tools.js +147 -0
- package/dist/mcp/client-tools.js.map +1 -0
- package/dist/mcp/index.d.ts +16 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +15 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server-from-agent.d.ts +24 -0
- package/dist/mcp/server-from-agent.d.ts.map +1 -0
- package/dist/mcp/server-from-agent.js +113 -0
- package/dist/mcp/server-from-agent.js.map +1 -0
- package/dist/mcp/types.d.ts +64 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +6 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/memory-embedding/index.d.ts +121 -0
- package/dist/memory-embedding/index.d.ts.map +1 -0
- package/dist/memory-embedding/index.js +229 -0
- package/dist/memory-embedding/index.js.map +1 -0
- package/dist/memory-extract.d.ts +60 -0
- package/dist/memory-extract.d.ts.map +1 -0
- package/dist/memory-extract.js +163 -0
- package/dist/memory-extract.js.map +1 -0
- package/dist/memory-inject.d.ts +39 -0
- package/dist/memory-inject.d.ts.map +1 -0
- package/dist/memory-inject.js +135 -0
- package/dist/memory-inject.js.map +1 -0
- package/dist/memory-orm/index.d.ts +118 -0
- package/dist/memory-orm/index.d.ts.map +1 -0
- package/dist/memory-orm/index.js +187 -0
- package/dist/memory-orm/index.js.map +1 -0
- package/dist/memory.d.ts +55 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +132 -0
- package/dist/memory.js.map +1 -0
- package/dist/observers.d.ts +22 -0
- package/dist/observers.d.ts.map +1 -1
- package/dist/observers.js.map +1 -1
- package/dist/provider-tools.d.ts +15 -1
- package/dist/provider-tools.d.ts.map +1 -1
- package/dist/provider-tools.js +21 -1
- package/dist/provider-tools.js.map +1 -1
- package/dist/providers/anthropic.d.ts +9 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +66 -11
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/bedrock.d.ts +60 -0
- package/dist/providers/bedrock.d.ts.map +1 -0
- package/dist/providers/bedrock.js +167 -0
- package/dist/providers/bedrock.js.map +1 -0
- package/dist/providers/elevenlabs.d.ts +98 -0
- package/dist/providers/elevenlabs.d.ts.map +1 -0
- package/dist/providers/elevenlabs.js +229 -0
- package/dist/providers/elevenlabs.js.map +1 -0
- package/dist/providers/google.d.ts +83 -1
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +491 -8
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/openai.d.ts +8 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +215 -5
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +43 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +21 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/voyage.d.ts +91 -0
- package/dist/providers/voyage.d.ts.map +1 -0
- package/dist/providers/voyage.js +166 -0
- package/dist/providers/voyage.js.map +1 -0
- package/dist/queue-job.d.ts +69 -4
- package/dist/queue-job.d.ts.map +1 -1
- package/dist/queue-job.js +114 -11
- package/dist/queue-job.js.map +1 -1
- package/dist/registry.d.ts +3 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +10 -0
- package/dist/registry.js.map +1 -1
- package/dist/server/provider.d.ts.map +1 -1
- package/dist/server/provider.js +38 -1
- package/dist/server/provider.js.map +1 -1
- package/dist/similarity-search.d.ts +163 -0
- package/dist/similarity-search.d.ts.map +1 -0
- package/dist/similarity-search.js +147 -0
- package/dist/similarity-search.js.map +1 -0
- package/dist/sub-agent-run-store.d.ts +40 -3
- package/dist/sub-agent-run-store.d.ts.map +1 -1
- package/dist/sub-agent-run-store.js.map +1 -1
- package/dist/tool.d.ts +59 -0
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +45 -4
- package/dist/tool.js.map +1 -1
- package/dist/types.d.ts +285 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vector-stores/index.d.ts +96 -0
- package/dist/vector-stores/index.d.ts.map +1 -0
- package/dist/vector-stores/index.js +153 -0
- package/dist/vector-stores/index.js.map +1 -0
- package/package.json +43 -4
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { splitSystemMessages, toAnthropicMessages, toAnthropicTools, toAnthropicToolChoice, fromAnthropicResponse, applyCacheToSystem, applyCacheToTools, applyCacheToMessages, } from './anthropic.js';
|
|
2
|
+
export class BedrockProvider {
|
|
3
|
+
name = 'bedrock';
|
|
4
|
+
config;
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
create(model) {
|
|
9
|
+
return new BedrockAdapter(this.config, model);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
// ─── Adapter ──────────────────────────────────────────────
|
|
13
|
+
class BedrockAdapter {
|
|
14
|
+
config;
|
|
15
|
+
model;
|
|
16
|
+
client = null;
|
|
17
|
+
constructor(config, model) {
|
|
18
|
+
this.config = config;
|
|
19
|
+
this.model = model;
|
|
20
|
+
if (!isAnthropicOnBedrock(model)) {
|
|
21
|
+
throw new Error(`[RudderJS AI] Bedrock model "${model}" is not yet supported. v1 only supports Anthropic Claude models on Bedrock ` +
|
|
22
|
+
`(model id starts with "anthropic."). File an issue at https://github.com/rudderjs/rudder/issues if you need another family.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async getClient() {
|
|
26
|
+
if (this.client)
|
|
27
|
+
return this.client;
|
|
28
|
+
const sdk = await import(/* @vite-ignore */ '@aws-sdk/client-bedrock-runtime');
|
|
29
|
+
const BedrockRuntimeClient = sdk.BedrockRuntimeClient;
|
|
30
|
+
const clientConfig = { region: this.config.region };
|
|
31
|
+
if (this.config.credentials) {
|
|
32
|
+
const c = this.config.credentials;
|
|
33
|
+
clientConfig['credentials'] = {
|
|
34
|
+
accessKeyId: c.accessKeyId,
|
|
35
|
+
secretAccessKey: c.secretAccessKey,
|
|
36
|
+
...(c.sessionToken ? { sessionToken: c.sessionToken } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
this.client = new BedrockRuntimeClient(clientConfig);
|
|
40
|
+
return this.client;
|
|
41
|
+
}
|
|
42
|
+
async generate(options) {
|
|
43
|
+
const client = await this.getClient();
|
|
44
|
+
const sdk = await import(/* @vite-ignore */ '@aws-sdk/client-bedrock-runtime');
|
|
45
|
+
const InvokeModelCommand = sdk.InvokeModelCommand;
|
|
46
|
+
const body = this.buildAnthropicBody(options);
|
|
47
|
+
const command = new InvokeModelCommand({
|
|
48
|
+
modelId: this.model,
|
|
49
|
+
contentType: 'application/json',
|
|
50
|
+
accept: 'application/json',
|
|
51
|
+
body: JSON.stringify(body),
|
|
52
|
+
});
|
|
53
|
+
const abortOpts = options.signal ? { abortSignal: options.signal } : undefined;
|
|
54
|
+
const response = await client.send(command, abortOpts);
|
|
55
|
+
const decoded = JSON.parse(new TextDecoder().decode(response.body));
|
|
56
|
+
return fromAnthropicResponse(decoded);
|
|
57
|
+
}
|
|
58
|
+
async *stream(options) {
|
|
59
|
+
const client = await this.getClient();
|
|
60
|
+
const sdk = await import(/* @vite-ignore */ '@aws-sdk/client-bedrock-runtime');
|
|
61
|
+
const InvokeModelWithResponseStreamCommand = sdk.InvokeModelWithResponseStreamCommand;
|
|
62
|
+
const body = this.buildAnthropicBody(options);
|
|
63
|
+
const command = new InvokeModelWithResponseStreamCommand({
|
|
64
|
+
modelId: this.model,
|
|
65
|
+
contentType: 'application/json',
|
|
66
|
+
accept: 'application/json',
|
|
67
|
+
body: JSON.stringify(body),
|
|
68
|
+
});
|
|
69
|
+
const abortOpts = options.signal ? { abortSignal: options.signal } : undefined;
|
|
70
|
+
const response = await client.send(command, abortOpts);
|
|
71
|
+
if (!response.body)
|
|
72
|
+
return;
|
|
73
|
+
const decoder = new TextDecoder();
|
|
74
|
+
for await (const event of response.body) {
|
|
75
|
+
if (!event.chunk?.bytes)
|
|
76
|
+
continue;
|
|
77
|
+
const decoded = JSON.parse(decoder.decode(event.chunk.bytes));
|
|
78
|
+
yield* mapBedrockAnthropicEvent(decoded);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Build the Bedrock-Anthropic request body. The shape mirrors the native
|
|
83
|
+
* Anthropic Messages API minus `model` (Bedrock takes the modelId in the
|
|
84
|
+
* URL) and plus `anthropic_version` (required by Bedrock).
|
|
85
|
+
*
|
|
86
|
+
* Spec: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages.html
|
|
87
|
+
*/
|
|
88
|
+
buildAnthropicBody(options) {
|
|
89
|
+
const { system, messages } = splitSystemMessages(options.messages);
|
|
90
|
+
const cache = options.cache;
|
|
91
|
+
const body = {
|
|
92
|
+
anthropic_version: 'bedrock-2023-05-31',
|
|
93
|
+
max_tokens: options.maxTokens ?? 4096,
|
|
94
|
+
messages: applyCacheToMessages(toAnthropicMessages(messages), cache?.messages),
|
|
95
|
+
};
|
|
96
|
+
const sys = applyCacheToSystem(system, cache?.instructions === true);
|
|
97
|
+
if (sys !== undefined)
|
|
98
|
+
body['system'] = sys;
|
|
99
|
+
if (options.temperature !== undefined)
|
|
100
|
+
body['temperature'] = options.temperature;
|
|
101
|
+
if (options.topP !== undefined)
|
|
102
|
+
body['top_p'] = options.topP;
|
|
103
|
+
if (options.stop)
|
|
104
|
+
body['stop_sequences'] = options.stop;
|
|
105
|
+
if (options.tools?.length) {
|
|
106
|
+
body['tools'] = applyCacheToTools(toAnthropicTools(options.tools), cache?.tools === true);
|
|
107
|
+
}
|
|
108
|
+
const choice = options.toolChoice ? toAnthropicToolChoice(options.toolChoice) : undefined;
|
|
109
|
+
if (choice !== undefined)
|
|
110
|
+
body['tool_choice'] = choice;
|
|
111
|
+
return body;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// ─── Helpers ──────────────────────────────────────────────
|
|
115
|
+
/**
|
|
116
|
+
* Bedrock model ids for Anthropic look like `anthropic.claude-3-5-sonnet-20241022-v2:0`.
|
|
117
|
+
* Any other prefix (`meta.`, `amazon.`, `cohere.`, `mistral.`, `ai21.`) is a
|
|
118
|
+
* different model family that needs its own conversion path.
|
|
119
|
+
*/
|
|
120
|
+
export function isAnthropicOnBedrock(model) {
|
|
121
|
+
return model.startsWith('anthropic.') || model.startsWith('us.anthropic.') || model.startsWith('eu.anthropic.') || model.startsWith('apac.anthropic.');
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Map a single decoded Bedrock-Anthropic stream event to zero-or-more
|
|
125
|
+
* `StreamChunk`s. Bedrock wraps Anthropic's native streaming events 1:1 in
|
|
126
|
+
* `chunk.bytes`, so the body shape matches `anthropic.ts`'s loop — but we
|
|
127
|
+
* keep the mapping here so a future model family can be added cleanly.
|
|
128
|
+
*/
|
|
129
|
+
export function* mapBedrockAnthropicEvent(event) {
|
|
130
|
+
if (event['type'] === 'content_block_delta') {
|
|
131
|
+
const delta = event['delta'];
|
|
132
|
+
if (delta?.type === 'text_delta') {
|
|
133
|
+
yield { type: 'text-delta', text: delta.text };
|
|
134
|
+
}
|
|
135
|
+
else if (delta?.type === 'input_json_delta') {
|
|
136
|
+
yield { type: 'tool-call-delta', text: delta.partial_json };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (event['type'] === 'content_block_start' && event['content_block']?.type === 'tool_use') {
|
|
140
|
+
yield {
|
|
141
|
+
type: 'tool-call-delta',
|
|
142
|
+
toolCall: { id: event['content_block'].id, name: event['content_block'].name },
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
else if (event['type'] === 'message_delta') {
|
|
146
|
+
yield {
|
|
147
|
+
type: 'finish',
|
|
148
|
+
finishReason: event['delta']?.stop_reason === 'tool_use' ? 'tool_calls' : 'stop',
|
|
149
|
+
usage: {
|
|
150
|
+
promptTokens: 0,
|
|
151
|
+
completionTokens: event['usage']?.output_tokens ?? 0,
|
|
152
|
+
totalTokens: event['usage']?.output_tokens ?? 0,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
else if (event['type'] === 'message_start' && event['message']?.usage) {
|
|
157
|
+
yield {
|
|
158
|
+
type: 'usage',
|
|
159
|
+
usage: {
|
|
160
|
+
promptTokens: event['message'].usage.input_tokens ?? 0,
|
|
161
|
+
completionTokens: event['message'].usage.output_tokens ?? 0,
|
|
162
|
+
totalTokens: (event['message'].usage.input_tokens ?? 0) + (event['message'].usage.output_tokens ?? 0),
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=bedrock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bedrock.js","sourceRoot":"","sources":["../../src/providers/bedrock.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,gBAAgB,CAAA;AA0CvB,MAAM,OAAO,eAAe;IACjB,IAAI,GAAG,SAAS,CAAA;IACR,MAAM,CAAe;IAEtC,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC/C,CAAC;CACF;AAED,6DAA6D;AAE7D,MAAM,cAAc;IAIC;IACA;IAJX,MAAM,GAAQ,IAAI,CAAA;IAE1B,YACmB,MAAqB,EACrB,KAAa;QADb,WAAM,GAAN,MAAM,CAAe;QACrB,UAAK,GAAL,KAAK,CAAQ;QAE9B,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,gCAAgC,KAAK,8EAA8E;gBACnH,6HAA6H,CAC9H,CAAA;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,SAAS;QACrB,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,MAAM,CAAA;QACnC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,iCAAiC,CAAC,CAAA;QAC9E,MAAM,oBAAoB,GA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ter` + `SpeechToTextAdapter` only — ElevenLabs
|
|
5
|
+
* has no chat-completions surface, so `create()` throws. Apps reach this
|
|
6
|
+
* provider through `AudioGenerator.of(...).model('elevenlabs/<voice_id>').generate()`
|
|
7
|
+
* and `Transcription.of(...).model('elevenlabs/scribe_v1').transcribe()`.
|
|
8
|
+
*
|
|
9
|
+
* Wire-protocol via raw `fetch` (no SDK peer dep), matching the Jina /
|
|
10
|
+
* Cohere shape. ElevenLabs's REST API is small enough that pulling in
|
|
11
|
+
* `@elevenlabs/elevenlabs-js` (or any SDK) would add weight without much
|
|
12
|
+
* leverage.
|
|
13
|
+
*
|
|
14
|
+
* @example Config-driven (recommended)
|
|
15
|
+
* ```ts
|
|
16
|
+
* // config/ai.ts
|
|
17
|
+
* export default {
|
|
18
|
+
* default: 'openai/gpt-4o',
|
|
19
|
+
* providers: {
|
|
20
|
+
* openai: { driver: 'openai', apiKey: env('OPENAI_API_KEY')! },
|
|
21
|
+
* elevenlabs: { driver: 'elevenlabs', apiKey: env('ELEVENLABS_API_KEY')! },
|
|
22
|
+
* },
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* // somewhere in app code
|
|
26
|
+
* await AudioGenerator
|
|
27
|
+
* .of('Hello world')
|
|
28
|
+
* .model('elevenlabs/21m00Tcm4TlvDq8ikWAM') // voice_id (Rachel)
|
|
29
|
+
* .generate()
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example Failover from OpenAI TTS to ElevenLabs
|
|
33
|
+
* ```ts
|
|
34
|
+
* await AudioGenerator
|
|
35
|
+
* .of('Hello')
|
|
36
|
+
* .model('openai/tts-1-hd')
|
|
37
|
+
* .failover('elevenlabs/21m00Tcm4TlvDq8ikWAM')
|
|
38
|
+
* .generate()
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* # Model strings
|
|
42
|
+
*
|
|
43
|
+
* **TTS:** the model string after `elevenlabs/` is the **voice id**
|
|
44
|
+
* (e.g. `21m00Tcm4TlvDq8ikWAM` for Rachel). The actual TTS model
|
|
45
|
+
* (`eleven_multilingual_v2`, `eleven_turbo_v2_5`, ...) defaults to
|
|
46
|
+
* {@link DEFAULT_TTS_MODEL_ID}; override via `ElevenLabsConfig.defaultTtsModelId`.
|
|
47
|
+
* Voice ids are the discriminator most apps want to vary per-call — the
|
|
48
|
+
* underlying TTS model is usually stable per deployment.
|
|
49
|
+
*
|
|
50
|
+
* **STT:** the model string is the actual model id (`scribe_v1` is the
|
|
51
|
+
* only model today).
|
|
52
|
+
*
|
|
53
|
+
* # Format mapping (TTS)
|
|
54
|
+
*
|
|
55
|
+
* `TextToSpeechOptions.format` maps to ElevenLabs's `output_format`:
|
|
56
|
+
*
|
|
57
|
+
* | Our format | ElevenLabs |
|
|
58
|
+
* |---|---|
|
|
59
|
+
* | `mp3` (default) | `mp3_44100_128` |
|
|
60
|
+
* | `opus` | `opus_48000_128` |
|
|
61
|
+
* | `wav` / `aac` / `flac` | not supported by ElevenLabs — throws clearly |
|
|
62
|
+
*
|
|
63
|
+
* # Speed knob (TTS)
|
|
64
|
+
*
|
|
65
|
+
* `TextToSpeechOptions.speed` is **ignored** by this adapter — ElevenLabs
|
|
66
|
+
* doesn't expose a top-level speed multiplier on the TTS endpoint
|
|
67
|
+
* (timing is steered via `voice_settings.stability` etc., out of scope
|
|
68
|
+
* for v1). OpenAI's TTS supports speed natively; failover from OpenAI
|
|
69
|
+
* to ElevenLabs will produce audio at default speed.
|
|
70
|
+
*/
|
|
71
|
+
import type { ProviderFactory, ProviderAdapter, TextToSpeechAdapter, SpeechToTextAdapter } from '../types.js';
|
|
72
|
+
/** Default TTS model when `ElevenLabsConfig.defaultTtsModelId` is unset. */
|
|
73
|
+
export declare const DEFAULT_TTS_MODEL_ID = "eleven_multilingual_v2";
|
|
74
|
+
/** Default voice when no voice id is encoded into the model string and no `opts.voice` override. */
|
|
75
|
+
export declare const DEFAULT_VOICE_ID = "21m00Tcm4TlvDq8ikWAM";
|
|
76
|
+
export interface ElevenLabsConfig {
|
|
77
|
+
apiKey: string;
|
|
78
|
+
/**
|
|
79
|
+
* Override `https://api.elevenlabs.io`. Useful for proxying through a
|
|
80
|
+
* gateway or for self-hosted ElevenLabs-compatible APIs.
|
|
81
|
+
*/
|
|
82
|
+
baseUrl?: string;
|
|
83
|
+
/**
|
|
84
|
+
* The TTS model id to send in the request body. Defaults to
|
|
85
|
+
* `eleven_multilingual_v2`. Override per-deployment when piloting a
|
|
86
|
+
* newer model (e.g. `eleven_turbo_v2_5` for lower-latency runs).
|
|
87
|
+
*/
|
|
88
|
+
defaultTtsModelId?: string;
|
|
89
|
+
}
|
|
90
|
+
export declare class ElevenLabsProvider implements ProviderFactory {
|
|
91
|
+
readonly name = "elevenlabs";
|
|
92
|
+
private readonly config;
|
|
93
|
+
constructor(config: ElevenLabsConfig);
|
|
94
|
+
create(_model: string): ProviderAdapter;
|
|
95
|
+
createTts(model: string): TextToSpeechAdapter;
|
|
96
|
+
createStt(model: string): SpeechToTextAdapter;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=elevenlabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elevenlabs.d.ts","sourceRoot":"","sources":["../../src/providers/elevenlabs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,mBAAmB,EAGnB,mBAAmB,EAGpB,MAAM,aAAa,CAAA;AAIpB,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,2BAA2B,CAAA;AAE5D,oGAAoG;AACpG,eAAO,MAAM,gBAAgB,yBAAyB,CAAA;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,qBAAa,kBAAmB,YAAW,eAAe;IACxD,QAAQ,CAAC,IAAI,gBAAe;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;gBAE7B,MAAM,EAAE,gBAAgB;IAIpC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;IAIvC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB;IAI7C,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB;CAG9C"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ElevenLabs provider — premium TTS + STT (#B9).
|
|
3
|
+
*
|
|
4
|
+
* Implements `TextToSpeechAdapter` + `SpeechToTextAdapter` only — ElevenLabs
|
|
5
|
+
* has no chat-completions surface, so `create()` throws. Apps reach this
|
|
6
|
+
* provider through `AudioGenerator.of(...).model('elevenlabs/<voice_id>').generate()`
|
|
7
|
+
* and `Transcription.of(...).model('elevenlabs/scribe_v1').transcribe()`.
|
|
8
|
+
*
|
|
9
|
+
* Wire-protocol via raw `fetch` (no SDK peer dep), matching the Jina /
|
|
10
|
+
* Cohere shape. ElevenLabs's REST API is small enough that pulling in
|
|
11
|
+
* `@elevenlabs/elevenlabs-js` (or any SDK) would add weight without much
|
|
12
|
+
* leverage.
|
|
13
|
+
*
|
|
14
|
+
* @example Config-driven (recommended)
|
|
15
|
+
* ```ts
|
|
16
|
+
* // config/ai.ts
|
|
17
|
+
* export default {
|
|
18
|
+
* default: 'openai/gpt-4o',
|
|
19
|
+
* providers: {
|
|
20
|
+
* openai: { driver: 'openai', apiKey: env('OPENAI_API_KEY')! },
|
|
21
|
+
* elevenlabs: { driver: 'elevenlabs', apiKey: env('ELEVENLABS_API_KEY')! },
|
|
22
|
+
* },
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* // somewhere in app code
|
|
26
|
+
* await AudioGenerator
|
|
27
|
+
* .of('Hello world')
|
|
28
|
+
* .model('elevenlabs/21m00Tcm4TlvDq8ikWAM') // voice_id (Rachel)
|
|
29
|
+
* .generate()
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example Failover from OpenAI TTS to ElevenLabs
|
|
33
|
+
* ```ts
|
|
34
|
+
* await AudioGenerator
|
|
35
|
+
* .of('Hello')
|
|
36
|
+
* .model('openai/tts-1-hd')
|
|
37
|
+
* .failover('elevenlabs/21m00Tcm4TlvDq8ikWAM')
|
|
38
|
+
* .generate()
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* # Model strings
|
|
42
|
+
*
|
|
43
|
+
* **TTS:** the model string after `elevenlabs/` is the **voice id**
|
|
44
|
+
* (e.g. `21m00Tcm4TlvDq8ikWAM` for Rachel). The actual TTS model
|
|
45
|
+
* (`eleven_multilingual_v2`, `eleven_turbo_v2_5`, ...) defaults to
|
|
46
|
+
* {@link DEFAULT_TTS_MODEL_ID}; override via `ElevenLabsConfig.defaultTtsModelId`.
|
|
47
|
+
* Voice ids are the discriminator most apps want to vary per-call — the
|
|
48
|
+
* underlying TTS model is usually stable per deployment.
|
|
49
|
+
*
|
|
50
|
+
* **STT:** the model string is the actual model id (`scribe_v1` is the
|
|
51
|
+
* only model today).
|
|
52
|
+
*
|
|
53
|
+
* # Format mapping (TTS)
|
|
54
|
+
*
|
|
55
|
+
* `TextToSpeechOptions.format` maps to ElevenLabs's `output_format`:
|
|
56
|
+
*
|
|
57
|
+
* | Our format | ElevenLabs |
|
|
58
|
+
* |---|---|
|
|
59
|
+
* | `mp3` (default) | `mp3_44100_128` |
|
|
60
|
+
* | `opus` | `opus_48000_128` |
|
|
61
|
+
* | `wav` / `aac` / `flac` | not supported by ElevenLabs — throws clearly |
|
|
62
|
+
*
|
|
63
|
+
* # Speed knob (TTS)
|
|
64
|
+
*
|
|
65
|
+
* `TextToSpeechOptions.speed` is **ignored** by this adapter — ElevenLabs
|
|
66
|
+
* doesn't expose a top-level speed multiplier on the TTS endpoint
|
|
67
|
+
* (timing is steered via `voice_settings.stability` etc., out of scope
|
|
68
|
+
* for v1). OpenAI's TTS supports speed natively; failover from OpenAI
|
|
69
|
+
* to ElevenLabs will produce audio at default speed.
|
|
70
|
+
*/
|
|
71
|
+
const ELEVENLABS_BASE_URL = 'https://api.elevenlabs.io';
|
|
72
|
+
/** Default TTS model when `ElevenLabsConfig.defaultTtsModelId` is unset. */
|
|
73
|
+
export const DEFAULT_TTS_MODEL_ID = 'eleven_multilingual_v2';
|
|
74
|
+
/** Default voice when no voice id is encoded into the model string and no `opts.voice` override. */
|
|
75
|
+
export const DEFAULT_VOICE_ID = '21m00Tcm4TlvDq8ikWAM';
|
|
76
|
+
export class ElevenLabsProvider {
|
|
77
|
+
name = 'elevenlabs';
|
|
78
|
+
config;
|
|
79
|
+
constructor(config) {
|
|
80
|
+
this.config = config;
|
|
81
|
+
}
|
|
82
|
+
create(_model) {
|
|
83
|
+
throw new Error('[RudderJS AI] ElevenLabs does not support text generation. Use it for text-to-speech and speech-to-text.');
|
|
84
|
+
}
|
|
85
|
+
createTts(model) {
|
|
86
|
+
return new ElevenLabsTtsAdapter(this.config, model);
|
|
87
|
+
}
|
|
88
|
+
createStt(model) {
|
|
89
|
+
return new ElevenLabsSttAdapter(this.config, model);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// ─── TTS Adapter ─────────────────────────────────────────
|
|
93
|
+
class ElevenLabsTtsAdapter {
|
|
94
|
+
config;
|
|
95
|
+
modelOrVoiceId;
|
|
96
|
+
constructor(config,
|
|
97
|
+
/**
|
|
98
|
+
* Treated as a **voice id** (e.g. `21m00Tcm4TlvDq8ikWAM` for Rachel).
|
|
99
|
+
* The TTS model id ships from `ElevenLabsConfig.defaultTtsModelId`.
|
|
100
|
+
* Apps that want to vary the TTS model per-call should use multiple
|
|
101
|
+
* registered providers (one per model) — the model-string convention
|
|
102
|
+
* across @rudderjs/ai is `<provider>/<voice-or-model>`.
|
|
103
|
+
*/
|
|
104
|
+
modelOrVoiceId) {
|
|
105
|
+
this.config = config;
|
|
106
|
+
this.modelOrVoiceId = modelOrVoiceId;
|
|
107
|
+
}
|
|
108
|
+
async generate(options) {
|
|
109
|
+
const baseUrl = this.config.baseUrl ?? ELEVENLABS_BASE_URL;
|
|
110
|
+
const ttsModelId = this.config.defaultTtsModelId ?? DEFAULT_TTS_MODEL_ID;
|
|
111
|
+
// Per-call `voice` overrides whatever's encoded in the model string.
|
|
112
|
+
// Falls back to the model-string voice id, then DEFAULT_VOICE_ID.
|
|
113
|
+
const voiceId = options.voice ?? this.modelOrVoiceId ?? DEFAULT_VOICE_ID;
|
|
114
|
+
const ourFormat = options.format ?? 'mp3';
|
|
115
|
+
const elevenFormat = elevenLabsOutputFormat(ourFormat);
|
|
116
|
+
const url = `${baseUrl}/v1/text-to-speech/${encodeURIComponent(voiceId)}?output_format=${elevenFormat}`;
|
|
117
|
+
const response = await fetch(url, {
|
|
118
|
+
method: 'POST',
|
|
119
|
+
headers: {
|
|
120
|
+
'xi-api-key': this.config.apiKey,
|
|
121
|
+
'Content-Type': 'application/json',
|
|
122
|
+
'Accept': acceptForFormat(ourFormat),
|
|
123
|
+
},
|
|
124
|
+
body: JSON.stringify({
|
|
125
|
+
text: options.text,
|
|
126
|
+
model_id: ttsModelId,
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
if (!response.ok) {
|
|
130
|
+
const text = await safeText(response);
|
|
131
|
+
throw new Error(`[RudderJS AI] ElevenLabs TTS failed (${response.status}): ${text}`);
|
|
132
|
+
}
|
|
133
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
134
|
+
return {
|
|
135
|
+
audio: Buffer.from(arrayBuffer),
|
|
136
|
+
format: ourFormat,
|
|
137
|
+
// Returned as the voice id the caller used — that's the load-bearing
|
|
138
|
+
// discriminator for ElevenLabs (TTS model id is a deployment knob).
|
|
139
|
+
model: voiceId,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// ─── STT Adapter ─────────────────────────────────────────
|
|
144
|
+
class ElevenLabsSttAdapter {
|
|
145
|
+
config;
|
|
146
|
+
model;
|
|
147
|
+
constructor(config, model) {
|
|
148
|
+
this.config = config;
|
|
149
|
+
this.model = model;
|
|
150
|
+
}
|
|
151
|
+
async transcribe(options) {
|
|
152
|
+
const baseUrl = this.config.baseUrl ?? ELEVENLABS_BASE_URL;
|
|
153
|
+
const url = `${baseUrl}/v1/speech-to-text`;
|
|
154
|
+
// Multipart form with the audio Blob + the model id (+ optional language).
|
|
155
|
+
// ElevenLabs's only STT model today is `scribe_v1`; the field is
|
|
156
|
+
// required so we always send it.
|
|
157
|
+
const form = new FormData();
|
|
158
|
+
const audioBlob = new Blob([toUint8Array(options.audio)], { type: 'audio/mpeg' });
|
|
159
|
+
form.append('file', audioBlob, 'audio');
|
|
160
|
+
form.append('model_id', this.model);
|
|
161
|
+
if (options.language)
|
|
162
|
+
form.append('language_code', options.language);
|
|
163
|
+
const response = await fetch(url, {
|
|
164
|
+
method: 'POST',
|
|
165
|
+
headers: { 'xi-api-key': this.config.apiKey },
|
|
166
|
+
body: form,
|
|
167
|
+
});
|
|
168
|
+
if (!response.ok) {
|
|
169
|
+
const text = await safeText(response);
|
|
170
|
+
throw new Error(`[RudderJS AI] ElevenLabs STT failed (${response.status}): ${text}`);
|
|
171
|
+
}
|
|
172
|
+
const data = await response.json();
|
|
173
|
+
const text = typeof data.text === 'string' ? data.text : '';
|
|
174
|
+
const language = typeof data.language_code === 'string' ? data.language_code : undefined;
|
|
175
|
+
const duration = lastWordEnd(data.words);
|
|
176
|
+
const result = { text, model: this.model };
|
|
177
|
+
if (language !== undefined)
|
|
178
|
+
result.language = language;
|
|
179
|
+
if (duration !== undefined)
|
|
180
|
+
result.duration = duration;
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// ─── Helpers ─────────────────────────────────────────────
|
|
185
|
+
function elevenLabsOutputFormat(format) {
|
|
186
|
+
switch (format) {
|
|
187
|
+
case 'mp3': return 'mp3_44100_128';
|
|
188
|
+
case 'opus': return 'opus_48000_128';
|
|
189
|
+
case 'wav':
|
|
190
|
+
case 'aac':
|
|
191
|
+
case 'flac':
|
|
192
|
+
throw new Error(`[RudderJS AI] ElevenLabs TTS does not support format '${format}'. ` +
|
|
193
|
+
`Supported: 'mp3' (default), 'opus'. ` +
|
|
194
|
+
`Generate the source as mp3 and re-encode if you need ${format}, or use a provider with native ${format} support.`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function acceptForFormat(format) {
|
|
198
|
+
switch (format) {
|
|
199
|
+
case 'mp3': return 'audio/mpeg';
|
|
200
|
+
case 'opus': return 'audio/opus';
|
|
201
|
+
// The throwing cases above never reach here, but TypeScript doesn't
|
|
202
|
+
// know — return a neutral value so the type stays satisfied.
|
|
203
|
+
default: return 'application/octet-stream';
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function toUint8Array(audio) {
|
|
207
|
+
if (audio instanceof Uint8Array)
|
|
208
|
+
return audio;
|
|
209
|
+
if (audio instanceof ArrayBuffer)
|
|
210
|
+
return new Uint8Array(audio);
|
|
211
|
+
// Buffer is a Uint8Array — the typeof check above already handles it,
|
|
212
|
+
// but the function signature widens for safety.
|
|
213
|
+
return new Uint8Array(audio);
|
|
214
|
+
}
|
|
215
|
+
function lastWordEnd(words) {
|
|
216
|
+
if (!Array.isArray(words) || words.length === 0)
|
|
217
|
+
return undefined;
|
|
218
|
+
const last = words[words.length - 1]?.end;
|
|
219
|
+
return typeof last === 'number' ? last : undefined;
|
|
220
|
+
}
|
|
221
|
+
async function safeText(response) {
|
|
222
|
+
try {
|
|
223
|
+
return await response.text();
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return '<unreadable response body>';
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=elevenlabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;IAC9D,sEAAsE;IACtE,gDAAgD;IAChD,OAAO,IAAI,UAAU,CAAC,KAAwB,CAAC,CAAA;AACjD,CAAC;AAED,SAAS,WAAW,CAAC,KAA2C;IAC9D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,CAAA;IACzC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACpD,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,QAAkB;IACxC,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,4BAA4B,CAAA;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ProviderFactory, ProviderAdapter, ProviderRequestOptions, ProviderResponse, StreamChunk, EmbeddingAdapter, ImageGenerationAdapter, FileAdapter } from '../types.js';
|
|
1
|
+
import type { ProviderFactory, ProviderAdapter, ProviderRequestOptions, ProviderResponse, StreamChunk, EmbeddingAdapter, ImageGenerationAdapter, FileAdapter, VectorStoreAdapter, VectorStoreInfo, VectorStoreFileInfo } from '../types.js';
|
|
2
|
+
import type { FileSearchFilter } from '../file-search.js';
|
|
2
3
|
import { GoogleCacheRegistry } from './google-cache-registry.js';
|
|
3
4
|
export interface GoogleConfig {
|
|
4
5
|
apiKey: string;
|
|
@@ -12,6 +13,7 @@ export declare class GoogleProvider implements ProviderFactory {
|
|
|
12
13
|
createEmbedding(model: string): EmbeddingAdapter;
|
|
13
14
|
createImage(model: string): ImageGenerationAdapter;
|
|
14
15
|
createFiles(): FileAdapter;
|
|
16
|
+
createVectorStores(): VectorStoreAdapter;
|
|
15
17
|
}
|
|
16
18
|
export declare class GoogleAdapter implements ProviderAdapter {
|
|
17
19
|
private readonly config;
|
|
@@ -30,4 +32,84 @@ export declare class GoogleAdapter implements ProviderAdapter {
|
|
|
30
32
|
generate(options: ProviderRequestOptions): Promise<ProviderResponse>;
|
|
31
33
|
stream(options: ProviderRequestOptions): AsyncIterable<StreamChunk>;
|
|
32
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Translate a typed `FileSearchFilter` (OpenAI-shaped) into Gemini's
|
|
37
|
+
* `metadataFilter` string syntax (#B8.5).
|
|
38
|
+
*
|
|
39
|
+
* - `{ type: 'eq', key, value }` → `key = value`
|
|
40
|
+
* - `{ type: 'ne', key, value }` → `key != value`
|
|
41
|
+
* - `{ type: 'gt', key, value }` → `key > value`
|
|
42
|
+
* - `{ type: 'gte', key, value }` → `key >= value`
|
|
43
|
+
* - `{ type: 'lt', key, value }` → `key < value`
|
|
44
|
+
* - `{ type: 'lte', key, value }` → `key <= value`
|
|
45
|
+
* - `{ type: 'and', filters }` → `(f1) AND (f2) AND ...`
|
|
46
|
+
* - `{ type: 'or', filters }` → `(f1) OR (f2) OR ...`
|
|
47
|
+
*
|
|
48
|
+
* String values are wrapped in double quotes with `"` and `\` escaped.
|
|
49
|
+
* Numbers and booleans render bare.
|
|
50
|
+
*
|
|
51
|
+
* Exported for unit testing — see `google-vector-stores.test.ts`.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export declare function filterToGeminiString(filter: FileSearchFilter): string;
|
|
56
|
+
/**
|
|
57
|
+
* Map a Gemini `FileSearchStore` resource into the framework's
|
|
58
|
+
* `VectorStoreInfo` shape. `displayNameOverride` lets `create()` populate
|
|
59
|
+
* the human-friendly name from the user-supplied value when the API
|
|
60
|
+
* response omits it (some response variants do).
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare function fromGeminiFileSearchStore(raw: unknown, displayNameOverride?: string): VectorStoreInfo;
|
|
65
|
+
/**
|
|
66
|
+
* Map a Gemini `Document` resource into the framework's
|
|
67
|
+
* `VectorStoreFileInfo` shape. `DocumentState` enum values flatten to the
|
|
68
|
+
* shared `'in_progress' | 'completed' | 'failed' | 'cancelled'` union.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
export declare function fromGeminiDocument(raw: unknown, storeId: string): VectorStoreFileInfo;
|
|
73
|
+
/**
|
|
74
|
+
* Convert the framework's flat attribute map to Gemini's `CustomMetadata`
|
|
75
|
+
* array shape. Strings → `stringValue`, numbers → `numericValue`,
|
|
76
|
+
* booleans → `stringValue: 'true' | 'false'` (Gemini has no boolean
|
|
77
|
+
* variant — string is the safe lossless choice; filter-builders can
|
|
78
|
+
* still match on `key = "true"`).
|
|
79
|
+
*
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export declare function attributesToCustomMetadata(attrs: Record<string, string | number | boolean>): Array<{
|
|
83
|
+
key: string;
|
|
84
|
+
stringValue?: string;
|
|
85
|
+
numericValue?: number;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Inverse of {@link attributesToCustomMetadata}. Drops `stringListValue`
|
|
89
|
+
* variants (no flat-attribute representation; apps that need lists
|
|
90
|
+
* should read the raw Document via the SDK).
|
|
91
|
+
*
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export declare function customMetadataToAttributes(metadata: Array<{
|
|
95
|
+
key?: string;
|
|
96
|
+
stringValue?: string;
|
|
97
|
+
numericValue?: number;
|
|
98
|
+
stringListValue?: {
|
|
99
|
+
values?: string[];
|
|
100
|
+
};
|
|
101
|
+
}>): Record<string, string | number | boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* Best-effort MIME type from a filename extension. Gemini's
|
|
104
|
+
* `uploadToFileSearchStore` requires a mimeType on Blob uploads (it
|
|
105
|
+
* reads `blob.type`, which is empty on untyped `new Blob([data])`).
|
|
106
|
+
*
|
|
107
|
+
* Coverage matches Gemini's supported FileSearchStore document formats.
|
|
108
|
+
* Unknown extensions return `''` — the caller drops the field so the
|
|
109
|
+
* Gemini SDK's own error fires loudly rather than silently picking a
|
|
110
|
+
* wrong type.
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export declare function mimeTypeFromFilename(filename: string): string;
|
|
33
115
|
//# sourceMappingURL=google.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EAKX,gBAAgB,EAEhB,sBAAsB,EAGtB,WAAW,
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EAKX,gBAAgB,EAEhB,sBAAsB,EAGtB,WAAW,EAIX,kBAAkB,EAElB,eAAe,EACf,mBAAmB,EAKpB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EACL,mBAAmB,EAKpB,MAAM,4BAA4B,CAAA;AAEnC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,cAAe,YAAW,eAAe;IACpD,QAAQ,CAAC,IAAI,YAAW;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAqB;gBAExC,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,EAAE,mBAAmB;IAKrE,MAAM,CAAC,KAAK,EAAE,MAAM,GA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