getpatter 0.5.0 → 0.5.2
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 +25 -1
- package/dist/banner-FLR2HE5Z.mjs +19 -0
- package/dist/{chunk-757NVN4L.mjs → chunk-7SDDK2AO.mjs} +61 -46
- package/dist/{chunk-JO5C35FM.mjs → chunk-AKQFOFLG.mjs} +1 -1
- package/dist/cli.js +7 -2
- package/dist/index.d.mts +363 -56
- package/dist/index.d.ts +363 -56
- package/dist/index.js +728 -870
- package/dist/index.mjs +640 -7
- package/dist/{test-mode-YFOL2HYH.mjs → test-mode-K2TTPRGE.mjs} +1 -1
- package/dist/{tunnel-BL7A7GXW.mjs → tunnel-O7ICMSTP.mjs} +1 -1
- package/package.json +1 -1
- package/dist/lib-4WCAS54J.mjs +0 -830
package/dist/index.d.ts
CHANGED
|
@@ -240,6 +240,61 @@ interface TTSAdapter {
|
|
|
240
240
|
synthesizeStream(text: string): AsyncIterable<Buffer>;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Built-in LLM loop for pipeline mode when no onMessage handler is provided.
|
|
245
|
+
*
|
|
246
|
+
* Uses a pluggable ``LLMProvider`` interface so callers can supply OpenAI,
|
|
247
|
+
* Anthropic, Gemini, or any custom provider. The default provider is
|
|
248
|
+
* ``OpenAILLMProvider`` which preserves full backward compatibility.
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/** A single streaming chunk yielded by an LLM provider. */
|
|
252
|
+
interface LLMChunk {
|
|
253
|
+
type: 'text' | 'tool_call' | 'done';
|
|
254
|
+
content?: string;
|
|
255
|
+
index?: number;
|
|
256
|
+
id?: string;
|
|
257
|
+
name?: string;
|
|
258
|
+
arguments?: string;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Interface that any LLM provider must satisfy.
|
|
262
|
+
*
|
|
263
|
+
* Implementors yield streaming ``LLMChunk`` objects:
|
|
264
|
+
* - ``{ type: "text", content: "..." }`` — a text token.
|
|
265
|
+
* - ``{ type: "tool_call", index, id?, name?, arguments? }`` — a (partial) tool
|
|
266
|
+
* invocation. Chunks with the same ``index`` are concatenated.
|
|
267
|
+
* - ``{ type: "done" }`` — signals the end of the stream (optional).
|
|
268
|
+
*/
|
|
269
|
+
interface LLMProvider {
|
|
270
|
+
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
271
|
+
}
|
|
272
|
+
/** LLM provider backed by OpenAI Chat Completions (streaming). */
|
|
273
|
+
declare class OpenAILLMProvider implements LLMProvider {
|
|
274
|
+
private readonly apiKey;
|
|
275
|
+
private readonly model;
|
|
276
|
+
constructor(apiKey: string, model: string);
|
|
277
|
+
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
278
|
+
}
|
|
279
|
+
declare class LLMLoop {
|
|
280
|
+
private readonly provider;
|
|
281
|
+
private readonly systemPrompt;
|
|
282
|
+
private readonly tools;
|
|
283
|
+
private readonly openaiTools;
|
|
284
|
+
private readonly toolMap;
|
|
285
|
+
constructor(apiKey: string, model: string, systemPrompt: string, tools?: ToolDefinition[] | null, llmProvider?: LLMProvider);
|
|
286
|
+
/**
|
|
287
|
+
* Stream LLM response tokens, handling tool calls automatically.
|
|
288
|
+
* Yields text tokens as they arrive from the LLM.
|
|
289
|
+
*/
|
|
290
|
+
run(userText: string, history: Array<{
|
|
291
|
+
role: string;
|
|
292
|
+
text: string;
|
|
293
|
+
}>, callContext: Record<string, unknown>): AsyncGenerator<string, void, unknown>;
|
|
294
|
+
private executeTool;
|
|
295
|
+
private buildMessages;
|
|
296
|
+
}
|
|
297
|
+
|
|
243
298
|
interface IncomingMessage {
|
|
244
299
|
readonly text: string;
|
|
245
300
|
readonly callId: string;
|
|
@@ -460,6 +515,13 @@ interface AgentOptions {
|
|
|
460
515
|
stt?: STTAdapter;
|
|
461
516
|
/** Pre-instantiated TTS adapter (e.g. ``new ElevenLabsTTS({ apiKey })``). */
|
|
462
517
|
tts?: TTSAdapter;
|
|
518
|
+
/**
|
|
519
|
+
* Pipeline-mode LLM provider (e.g. ``new AnthropicLLM()``). When set, the
|
|
520
|
+
* built-in LLM loop uses this provider instead of the OpenAI default.
|
|
521
|
+
* Mutually exclusive with ``onMessage`` passed to ``serve()``. Ignored
|
|
522
|
+
* when ``engine`` is set (realtime mode bypasses the pipeline LLM).
|
|
523
|
+
*/
|
|
524
|
+
llm?: LLMProvider;
|
|
463
525
|
/** Dynamic variables for ``{placeholder}`` substitution in systemPrompt at call time. */
|
|
464
526
|
variables?: Record<string, string>;
|
|
465
527
|
/** Output guardrails — ``Guardrail`` class instances from ``getpatter``. */
|
|
@@ -1151,61 +1213,6 @@ declare function mountApi(app: Express, store: MetricsStore, token?: string): vo
|
|
|
1151
1213
|
*/
|
|
1152
1214
|
declare function notifyDashboard(callData: Record<string, unknown>, port?: number): void;
|
|
1153
1215
|
|
|
1154
|
-
/**
|
|
1155
|
-
* Built-in LLM loop for pipeline mode when no onMessage handler is provided.
|
|
1156
|
-
*
|
|
1157
|
-
* Uses a pluggable ``LLMProvider`` interface so callers can supply OpenAI,
|
|
1158
|
-
* Anthropic, Gemini, or any custom provider. The default provider is
|
|
1159
|
-
* ``OpenAILLMProvider`` which preserves full backward compatibility.
|
|
1160
|
-
*/
|
|
1161
|
-
|
|
1162
|
-
/** A single streaming chunk yielded by an LLM provider. */
|
|
1163
|
-
interface LLMChunk {
|
|
1164
|
-
type: 'text' | 'tool_call' | 'done';
|
|
1165
|
-
content?: string;
|
|
1166
|
-
index?: number;
|
|
1167
|
-
id?: string;
|
|
1168
|
-
name?: string;
|
|
1169
|
-
arguments?: string;
|
|
1170
|
-
}
|
|
1171
|
-
/**
|
|
1172
|
-
* Interface that any LLM provider must satisfy.
|
|
1173
|
-
*
|
|
1174
|
-
* Implementors yield streaming ``LLMChunk`` objects:
|
|
1175
|
-
* - ``{ type: "text", content: "..." }`` — a text token.
|
|
1176
|
-
* - ``{ type: "tool_call", index, id?, name?, arguments? }`` — a (partial) tool
|
|
1177
|
-
* invocation. Chunks with the same ``index`` are concatenated.
|
|
1178
|
-
* - ``{ type: "done" }`` — signals the end of the stream (optional).
|
|
1179
|
-
*/
|
|
1180
|
-
interface LLMProvider {
|
|
1181
|
-
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
1182
|
-
}
|
|
1183
|
-
/** LLM provider backed by OpenAI Chat Completions (streaming). */
|
|
1184
|
-
declare class OpenAILLMProvider implements LLMProvider {
|
|
1185
|
-
private readonly apiKey;
|
|
1186
|
-
private readonly model;
|
|
1187
|
-
constructor(apiKey: string, model: string);
|
|
1188
|
-
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
1189
|
-
}
|
|
1190
|
-
declare class LLMLoop {
|
|
1191
|
-
private readonly provider;
|
|
1192
|
-
private readonly systemPrompt;
|
|
1193
|
-
private readonly tools;
|
|
1194
|
-
private readonly openaiTools;
|
|
1195
|
-
private readonly toolMap;
|
|
1196
|
-
constructor(apiKey: string, model: string, systemPrompt: string, tools?: ToolDefinition[] | null, llmProvider?: LLMProvider);
|
|
1197
|
-
/**
|
|
1198
|
-
* Stream LLM response tokens, handling tool calls automatically.
|
|
1199
|
-
* Yields text tokens as they arrive from the LLM.
|
|
1200
|
-
*/
|
|
1201
|
-
run(userText: string, history: Array<{
|
|
1202
|
-
role: string;
|
|
1203
|
-
text: string;
|
|
1204
|
-
}>, callContext: Record<string, unknown>): AsyncGenerator<string, void, unknown>;
|
|
1205
|
-
private executeTool;
|
|
1206
|
-
private buildMessages;
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
1216
|
/**
|
|
1210
1217
|
* Fallback LLM provider that tries multiple providers in sequence.
|
|
1211
1218
|
*
|
|
@@ -2166,6 +2173,306 @@ declare class TTS extends LMNTTTS {
|
|
|
2166
2173
|
constructor(opts?: LMNTTTSOptions);
|
|
2167
2174
|
}
|
|
2168
2175
|
|
|
2176
|
+
/** OpenAI LLM for Patter pipeline mode. */
|
|
2177
|
+
|
|
2178
|
+
interface OpenAILLMOptions {
|
|
2179
|
+
/** API key. Falls back to OPENAI_API_KEY env var when omitted. */
|
|
2180
|
+
apiKey?: string;
|
|
2181
|
+
/** Chat Completions model id. Defaults to ``"gpt-4o-mini"``. */
|
|
2182
|
+
model?: string;
|
|
2183
|
+
}
|
|
2184
|
+
/**
|
|
2185
|
+
* OpenAI Chat Completions LLM provider.
|
|
2186
|
+
*
|
|
2187
|
+
* @example
|
|
2188
|
+
* ```ts
|
|
2189
|
+
* import * as openai from "getpatter/llm/openai";
|
|
2190
|
+
* const llm = new openai.LLM(); // reads OPENAI_API_KEY
|
|
2191
|
+
* const llm = new openai.LLM({ apiKey: "sk-...", model: "gpt-4o-mini" });
|
|
2192
|
+
* ```
|
|
2193
|
+
*/
|
|
2194
|
+
declare class LLM$4 extends OpenAILLMProvider {
|
|
2195
|
+
constructor(opts?: OpenAILLMOptions);
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
/**
|
|
2199
|
+
* Anthropic Claude LLM provider for Patter's pipeline mode.
|
|
2200
|
+
*
|
|
2201
|
+
* Implements the ``LLMProvider`` interface from ``../llm-loop`` on top
|
|
2202
|
+
* of Anthropic's Messages API with streaming via Server-Sent Events.
|
|
2203
|
+
* OpenAI-style ``messages`` / ``tools`` inputs are translated into the
|
|
2204
|
+
* Anthropic shape and the vendor event stream is normalised back into
|
|
2205
|
+
* Patter's ``{ type: 'text' | 'tool_call' | 'done' }`` chunk protocol.
|
|
2206
|
+
*
|
|
2207
|
+
* Portions adapted from LiveKit Agents
|
|
2208
|
+
* (https://github.com/livekit/agents, commit
|
|
2209
|
+
* 78a66bcf79c5cea82989401c408f1dff4b961a5b,
|
|
2210
|
+
* file livekit-plugins/livekit-plugins-anthropic/livekit/plugins/anthropic/llm.py),
|
|
2211
|
+
* licensed under Apache License 2.0. Copyright 2023 LiveKit, Inc.
|
|
2212
|
+
*
|
|
2213
|
+
* Adaptations from the LiveKit source:
|
|
2214
|
+
* * Ported the Python async class pair (``llm.LLM`` /
|
|
2215
|
+
* ``llm.LLMStream``) into a single TypeScript class that satisfies
|
|
2216
|
+
* Patter's ``LLMProvider`` interface.
|
|
2217
|
+
* * Uses native ``fetch`` + SSE parsing instead of the official
|
|
2218
|
+
* ``@anthropic-ai/sdk`` to keep Patter's runtime dependencies lean
|
|
2219
|
+
* (mirrors how ``OpenAILLMProvider`` is implemented in
|
|
2220
|
+
* ``llm-loop.ts``).
|
|
2221
|
+
* * Maps Anthropic event types (``content_block_start``,
|
|
2222
|
+
* ``content_block_delta``, ``content_block_stop``) to the Patter
|
|
2223
|
+
* chunk protocol.
|
|
2224
|
+
*/
|
|
2225
|
+
|
|
2226
|
+
interface AnthropicLLMOptions$1 {
|
|
2227
|
+
apiKey: string;
|
|
2228
|
+
model?: string;
|
|
2229
|
+
maxTokens?: number;
|
|
2230
|
+
temperature?: number;
|
|
2231
|
+
baseUrl?: string;
|
|
2232
|
+
anthropicVersion?: string;
|
|
2233
|
+
}
|
|
2234
|
+
/** LLM provider backed by Anthropic's Messages API (streaming). */
|
|
2235
|
+
declare class AnthropicLLMProvider implements LLMProvider {
|
|
2236
|
+
private readonly apiKey;
|
|
2237
|
+
private readonly model;
|
|
2238
|
+
private readonly maxTokens;
|
|
2239
|
+
private readonly temperature?;
|
|
2240
|
+
private readonly url;
|
|
2241
|
+
private readonly anthropicVersion;
|
|
2242
|
+
constructor(options: AnthropicLLMOptions$1);
|
|
2243
|
+
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
/** Anthropic Claude LLM for Patter pipeline mode. */
|
|
2247
|
+
|
|
2248
|
+
interface AnthropicLLMOptions {
|
|
2249
|
+
/** API key. Falls back to ANTHROPIC_API_KEY env var when omitted. */
|
|
2250
|
+
apiKey?: string;
|
|
2251
|
+
/** Anthropic Messages API model id (e.g. ``"claude-3-5-sonnet-20241022"``). */
|
|
2252
|
+
model?: string;
|
|
2253
|
+
/** Maximum number of tokens to sample. Defaults to the adapter default. */
|
|
2254
|
+
maxTokens?: number;
|
|
2255
|
+
/** Sampling temperature. */
|
|
2256
|
+
temperature?: number;
|
|
2257
|
+
/** Override the Messages API base URL (rarely needed). */
|
|
2258
|
+
baseUrl?: string;
|
|
2259
|
+
/** ``anthropic-version`` header override. */
|
|
2260
|
+
anthropicVersion?: string;
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Anthropic Claude LLM provider (Messages API, streaming).
|
|
2264
|
+
*
|
|
2265
|
+
* @example
|
|
2266
|
+
* ```ts
|
|
2267
|
+
* import * as anthropic from "getpatter/llm/anthropic";
|
|
2268
|
+
* const llm = new anthropic.LLM(); // reads ANTHROPIC_API_KEY
|
|
2269
|
+
* const llm = new anthropic.LLM({ apiKey: "sk-ant-...", model: "claude-3-5-sonnet-20241022" });
|
|
2270
|
+
* ```
|
|
2271
|
+
*/
|
|
2272
|
+
declare class LLM$3 extends AnthropicLLMProvider {
|
|
2273
|
+
constructor(opts?: AnthropicLLMOptions);
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
/**
|
|
2277
|
+
* Groq LLM provider for Patter's pipeline mode.
|
|
2278
|
+
*
|
|
2279
|
+
* Groq exposes an OpenAI-compatible Chat Completions API. We reuse the
|
|
2280
|
+
* streaming code path by implementing the same SSE parser as
|
|
2281
|
+
* ``OpenAILLMProvider`` but pointed at ``api.groq.com``.
|
|
2282
|
+
*
|
|
2283
|
+
* Portions adapted from LiveKit Agents
|
|
2284
|
+
* (https://github.com/livekit/agents, commit
|
|
2285
|
+
* 78a66bcf79c5cea82989401c408f1dff4b961a5b,
|
|
2286
|
+
* file livekit-plugins/livekit-plugins-groq/livekit/plugins/groq/services.py),
|
|
2287
|
+
* licensed under Apache License 2.0. Copyright LiveKit, Inc.
|
|
2288
|
+
*
|
|
2289
|
+
* Adaptations from the LiveKit source:
|
|
2290
|
+
* * Ported the Python ``groq.LLM`` subclass (which subclasses the
|
|
2291
|
+
* LiveKit OpenAI plugin) into a tiny TypeScript wrapper that swaps
|
|
2292
|
+
* the base URL and defaults to ``llama-3.3-70b-versatile``.
|
|
2293
|
+
*/
|
|
2294
|
+
|
|
2295
|
+
interface GroqLLMOptions$1 {
|
|
2296
|
+
apiKey: string;
|
|
2297
|
+
model?: string;
|
|
2298
|
+
baseUrl?: string;
|
|
2299
|
+
}
|
|
2300
|
+
/** LLM provider backed by Groq's OpenAI-compatible Chat Completions API. */
|
|
2301
|
+
declare class GroqLLMProvider implements LLMProvider {
|
|
2302
|
+
private readonly apiKey;
|
|
2303
|
+
private readonly model;
|
|
2304
|
+
private readonly baseUrl;
|
|
2305
|
+
constructor(options: GroqLLMOptions$1);
|
|
2306
|
+
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
/** Groq LLM for Patter pipeline mode. */
|
|
2310
|
+
|
|
2311
|
+
interface GroqLLMOptions {
|
|
2312
|
+
/** API key. Falls back to GROQ_API_KEY env var when omitted. */
|
|
2313
|
+
apiKey?: string;
|
|
2314
|
+
/** Model id (e.g. ``"llama-3.3-70b-versatile"``). */
|
|
2315
|
+
model?: string;
|
|
2316
|
+
/** Override the OpenAI-compatible base URL (rarely needed). */
|
|
2317
|
+
baseUrl?: string;
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Groq LLM provider (OpenAI-compatible Chat Completions, streaming).
|
|
2321
|
+
*
|
|
2322
|
+
* @example
|
|
2323
|
+
* ```ts
|
|
2324
|
+
* import * as groq from "getpatter/llm/groq";
|
|
2325
|
+
* const llm = new groq.LLM(); // reads GROQ_API_KEY
|
|
2326
|
+
* const llm = new groq.LLM({ apiKey: "gsk_...", model: "llama-3.3-70b-versatile" });
|
|
2327
|
+
* ```
|
|
2328
|
+
*/
|
|
2329
|
+
declare class LLM$2 extends GroqLLMProvider {
|
|
2330
|
+
constructor(opts?: GroqLLMOptions);
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
/**
|
|
2334
|
+
* Cerebras LLM provider for Patter's pipeline mode.
|
|
2335
|
+
*
|
|
2336
|
+
* Cerebras exposes an OpenAI-compatible Chat Completions API at
|
|
2337
|
+
* ``https://api.cerebras.ai/v1``. This provider reuses the OpenAI SSE
|
|
2338
|
+
* parser from ``groq-llm.ts`` and optionally enables gzip request-body
|
|
2339
|
+
* compression to reduce TTFT for requests with large prompts
|
|
2340
|
+
* (see https://inference-docs.cerebras.ai/payload-optimization).
|
|
2341
|
+
*
|
|
2342
|
+
* Portions adapted from LiveKit Agents
|
|
2343
|
+
* (https://github.com/livekit/agents, commit
|
|
2344
|
+
* 78a66bcf79c5cea82989401c408f1dff4b961a5b,
|
|
2345
|
+
* file livekit-plugins/livekit-plugins-cerebras/livekit/plugins/cerebras/llm.py),
|
|
2346
|
+
* licensed under Apache License 2.0. Copyright 2026 LiveKit, Inc.
|
|
2347
|
+
*
|
|
2348
|
+
* Adaptations from the LiveKit source:
|
|
2349
|
+
* * LiveKit's ``cerebras.LLM`` subclasses the LiveKit OpenAI plugin.
|
|
2350
|
+
* Patter's analogue is a tiny wrapper around ``fetch`` that swaps
|
|
2351
|
+
* the base URL and default model.
|
|
2352
|
+
* * The msgpack payload optimisation from LiveKit is Python-only
|
|
2353
|
+
* (msgpack in Node land isn't as standard); only gzip compression
|
|
2354
|
+
* is ported. Enable with ``gzipCompression: true``.
|
|
2355
|
+
*/
|
|
2356
|
+
|
|
2357
|
+
interface CerebrasLLMOptions$1 {
|
|
2358
|
+
apiKey: string;
|
|
2359
|
+
model?: string;
|
|
2360
|
+
baseUrl?: string;
|
|
2361
|
+
/** Gzip request payloads for faster TTFT on large prompts. */
|
|
2362
|
+
gzipCompression?: boolean;
|
|
2363
|
+
}
|
|
2364
|
+
/** LLM provider backed by Cerebras's OpenAI-compatible Inference API. */
|
|
2365
|
+
declare class CerebrasLLMProvider implements LLMProvider {
|
|
2366
|
+
private readonly apiKey;
|
|
2367
|
+
private readonly model;
|
|
2368
|
+
private readonly baseUrl;
|
|
2369
|
+
private readonly gzipCompression;
|
|
2370
|
+
constructor(options: CerebrasLLMOptions$1);
|
|
2371
|
+
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
/** Cerebras LLM for Patter pipeline mode. */
|
|
2375
|
+
|
|
2376
|
+
interface CerebrasLLMOptions {
|
|
2377
|
+
/** API key. Falls back to CEREBRAS_API_KEY env var when omitted. */
|
|
2378
|
+
apiKey?: string;
|
|
2379
|
+
/** Model id (e.g. ``"llama3.1-8b"``). */
|
|
2380
|
+
model?: string;
|
|
2381
|
+
/** Override the OpenAI-compatible base URL (rarely needed). */
|
|
2382
|
+
baseUrl?: string;
|
|
2383
|
+
/** Gzip request payloads for faster TTFT on large prompts. */
|
|
2384
|
+
gzipCompression?: boolean;
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
* Cerebras LLM provider (OpenAI-compatible Inference API, streaming).
|
|
2388
|
+
*
|
|
2389
|
+
* @example
|
|
2390
|
+
* ```ts
|
|
2391
|
+
* import * as cerebras from "getpatter/llm/cerebras";
|
|
2392
|
+
* const llm = new cerebras.LLM(); // reads CEREBRAS_API_KEY
|
|
2393
|
+
* const llm = new cerebras.LLM({ apiKey: "csk-...", model: "llama3.1-8b" });
|
|
2394
|
+
* ```
|
|
2395
|
+
*/
|
|
2396
|
+
declare class LLM$1 extends CerebrasLLMProvider {
|
|
2397
|
+
constructor(opts?: CerebrasLLMOptions);
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
/**
|
|
2401
|
+
* Google Gemini LLM provider for Patter's pipeline mode.
|
|
2402
|
+
*
|
|
2403
|
+
* Implements the ``LLMProvider`` interface against the Gemini Developer
|
|
2404
|
+
* API's streaming endpoint (``:streamGenerateContent?alt=sse``).
|
|
2405
|
+
* OpenAI-style messages/tools are translated into Gemini's ``contents``
|
|
2406
|
+
* and ``tools`` shapes, and streamed response parts are normalised to
|
|
2407
|
+
* Patter's ``{ type: 'text' | 'tool_call' | 'done' }`` chunks.
|
|
2408
|
+
*
|
|
2409
|
+
* Portions adapted from LiveKit Agents
|
|
2410
|
+
* (https://github.com/livekit/agents, commit
|
|
2411
|
+
* 78a66bcf79c5cea82989401c408f1dff4b961a5b,
|
|
2412
|
+
* file livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py),
|
|
2413
|
+
* licensed under Apache License 2.0. Copyright 2023 LiveKit, Inc.
|
|
2414
|
+
*
|
|
2415
|
+
* Adaptations from the LiveKit source:
|
|
2416
|
+
* * LiveKit uses the ``google-genai`` Python SDK. The TypeScript port
|
|
2417
|
+
* uses native ``fetch`` against the REST SSE endpoint so we don't
|
|
2418
|
+
* pull in a large SDK dependency.
|
|
2419
|
+
* * Collapsed the Python ``llm.LLM`` / ``llm.LLMStream`` pair into a
|
|
2420
|
+
* single class that satisfies Patter's ``LLMProvider`` interface.
|
|
2421
|
+
* * Dropped Vertex AI support (which requires GCP auth) — only the
|
|
2422
|
+
* Developer API (API key) path is ported. Vertex can be added by a
|
|
2423
|
+
* follow-up PR once credential plumbing is in place.
|
|
2424
|
+
*/
|
|
2425
|
+
|
|
2426
|
+
interface GoogleLLMOptions$1 {
|
|
2427
|
+
apiKey: string;
|
|
2428
|
+
model?: string;
|
|
2429
|
+
baseUrl?: string;
|
|
2430
|
+
temperature?: number;
|
|
2431
|
+
maxOutputTokens?: number;
|
|
2432
|
+
}
|
|
2433
|
+
/** LLM provider backed by Google Gemini (Developer API, streaming SSE). */
|
|
2434
|
+
declare class GoogleLLMProvider implements LLMProvider {
|
|
2435
|
+
private readonly apiKey;
|
|
2436
|
+
private readonly model;
|
|
2437
|
+
private readonly baseUrl;
|
|
2438
|
+
private readonly temperature?;
|
|
2439
|
+
private readonly maxOutputTokens?;
|
|
2440
|
+
constructor(options: GoogleLLMOptions$1);
|
|
2441
|
+
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
/** Google Gemini LLM for Patter pipeline mode. */
|
|
2445
|
+
|
|
2446
|
+
interface GoogleLLMOptions {
|
|
2447
|
+
/**
|
|
2448
|
+
* API key. Falls back to ``GEMINI_API_KEY`` first, then ``GOOGLE_API_KEY``.
|
|
2449
|
+
* (Google's CLI tooling uses ``GEMINI_API_KEY``; ``GOOGLE_API_KEY`` is the
|
|
2450
|
+
* legacy/alt name accepted for parity with other SDKs.)
|
|
2451
|
+
*/
|
|
2452
|
+
apiKey?: string;
|
|
2453
|
+
/** Model id (e.g. ``"gemini-2.5-flash"``). */
|
|
2454
|
+
model?: string;
|
|
2455
|
+
/** Override the Generative Language API base URL (rarely needed). */
|
|
2456
|
+
baseUrl?: string;
|
|
2457
|
+
/** Sampling temperature. */
|
|
2458
|
+
temperature?: number;
|
|
2459
|
+
/** Maximum output tokens. */
|
|
2460
|
+
maxOutputTokens?: number;
|
|
2461
|
+
}
|
|
2462
|
+
/**
|
|
2463
|
+
* Google Gemini LLM provider (Developer API, streaming SSE).
|
|
2464
|
+
*
|
|
2465
|
+
* @example
|
|
2466
|
+
* ```ts
|
|
2467
|
+
* import * as google from "getpatter/llm/google";
|
|
2468
|
+
* const llm = new google.LLM(); // reads GEMINI_API_KEY or GOOGLE_API_KEY
|
|
2469
|
+
* const llm = new google.LLM({ apiKey: "AIza...", model: "gemini-2.5-flash" });
|
|
2470
|
+
* ```
|
|
2471
|
+
*/
|
|
2472
|
+
declare class LLM extends GoogleLLMProvider {
|
|
2473
|
+
constructor(opts?: GoogleLLMOptions);
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2169
2476
|
/**
|
|
2170
2477
|
* Audio transcoding utilities for Patter TypeScript SDK.
|
|
2171
2478
|
*
|
|
@@ -2527,4 +2834,4 @@ declare class BackgroundAudioPlayer implements BackgroundAudioPlayer$1 {
|
|
|
2527
2834
|
private resampleTo;
|
|
2528
2835
|
}
|
|
2529
2836
|
|
|
2530
|
-
export { type Agent, type AgentOptions, AllProvidersFailedError, type AnthropicConversion, type AnthropicMessage, type AssemblyAIEncoding, type AssemblyAIModel, STT as AssemblyAISTT, type AssemblyAISTTOptions, type AudioConfig, type AudioSource, AuthenticationError, type BackgroundAudioOptions, BackgroundAudioPlayer, BuiltinAudioClip, type BuiltinAudioClipName, type BuiltinPcmSource, type Call, type CallControl, type CallEventHandler, type CallMetrics, CallMetricsAccumulator, type CallOptions, type CallRecord, type CartesiaEncoding, STT$2 as CartesiaSTT, type CartesiaSTTOptions, TTS$2 as CartesiaTTS, type CartesiaTTSOptions, ChatContext, type ChatMessage, type ChatRole, CloudflareTunnel, type ConnectOptions, type CostBreakdown, type CreateAgentOptions, DEFAULT_MIN_SENTENCE_LEN, DEFAULT_PRICING, DTMF_EVENTS, STT$4 as DeepgramSTT, type DeepgramSTTOptions, type DefineToolInput, type DtmfEvent, ConvAI as ElevenLabsConvAI, ElevenLabsConvAIAdapter, type ConvAIOptions as ElevenLabsConvAIOptions, TTS$4 as ElevenLabsTTS, type ElevenLabsTTSOptions, FallbackLLMProvider, type FallbackLLMProviderOptions, type FilePcmSource, GEMINI_DEFAULT_INPUT_SR, GEMINI_DEFAULT_OUTPUT_SR, GeminiLiveAdapter, type GeminiLiveEventHandler, Guardrail$1 as Guardrail, type GuardrailOptions, type HookContext, IVRActivity, type IVRActivityOptions, type IVRToolDefinition, type IncomingMessage, type JobCallback, type LLMChunk, LLMLoop, type LLMProvider, type LMNTAudioFormat, type LMNTModel, type LMNTSampleRate, TTS as LMNTTTS, type LMNTTTSOptions, type LatencyBreakdown, type LocalCallOptions, type LocalConfig, type LocalOptions, type Logger, type LoopCallback, type MessageHandler, MetricsStore, OpenAILLMProvider, type OpenAIMessage, Realtime as OpenAIRealtime, OpenAIRealtimeAdapter, type RealtimeOptions as OpenAIRealtimeOptions, TTS$3 as OpenAITTS, type OpenAITTSOptions, type ParamSpec, PartialStreamError, Patter, PatterConnectionError, PatterError, type PatterOptions, type PhoneNumber, PipelineHookExecutor, type PipelineHooks, type PipelineMessageHandler, type ProviderPricing, ProvisionError, type RawPcmSource, RemoteMessageHandler, TTS$1 as RimeTTS, type RimeTTSOptions, type SSEEvent, type STTConfig, type ScheduleHandle, SentenceChunker, type ServeOptions, type SilenceCallback, STT$1 as SonioxSTT, type SonioxSTTOptions$1 as SonioxSTTOptions, Static as StaticTunnel, type TTSConfig, Carrier as Telnyx, type TelnyxCarrierOptions, TestSession, TfidfLoopDetector, type TfidfLoopDetectorOptions, Tool, type ToolDefinition, type ToolHandler, type ToolOptions, type TunnelHandle, type TurnMetrics, Carrier$1 as Twilio, type TwilioCarrierOptions, ULTRAVOX_DEFAULT_API_BASE, ULTRAVOX_DEFAULT_SR, type UltravoxEventHandler, UltravoxRealtimeAdapter, STT$3 as WhisperSTT, type WhisperSTTOptions, builtinClipPath, calculateRealtimeCost, calculateSttCost, calculateTelephonyCost, calculateTtsCost, callsToCsv, callsToJson, deepgram, defineTool, elevenlabs, filterEmoji, filterForTTS, filterMarkdown, formatDtmf, getLogger, guardrail, isRemoteUrl, isWebSocketUrl, makeAuthMiddleware, mergePricing, mixPcm, mountApi, mountDashboard, mulawToPcm16, notifyDashboard, openaiTts, pcm16ToMulaw, resample16kTo8k, resample24kTo16k, resample8kTo16k, resamplePcm, scheduleCron, scheduleInterval, scheduleOnce, selectSoundFromList, setLogger, startTunnel, tool, whisper };
|
|
2837
|
+
export { type Agent, type AgentOptions, AllProvidersFailedError, type AnthropicConversion, LLM$3 as AnthropicLLM, type AnthropicLLMOptions, type AnthropicMessage, type AssemblyAIEncoding, type AssemblyAIModel, STT as AssemblyAISTT, type AssemblyAISTTOptions, type AudioConfig, type AudioSource, AuthenticationError, type BackgroundAudioOptions, BackgroundAudioPlayer, BuiltinAudioClip, type BuiltinAudioClipName, type BuiltinPcmSource, type Call, type CallControl, type CallEventHandler, type CallMetrics, CallMetricsAccumulator, type CallOptions, type CallRecord, type CartesiaEncoding, STT$2 as CartesiaSTT, type CartesiaSTTOptions, TTS$2 as CartesiaTTS, type CartesiaTTSOptions, LLM$1 as CerebrasLLM, type CerebrasLLMOptions, ChatContext, type ChatMessage, type ChatRole, CloudflareTunnel, type ConnectOptions, type CostBreakdown, type CreateAgentOptions, DEFAULT_MIN_SENTENCE_LEN, DEFAULT_PRICING, DTMF_EVENTS, STT$4 as DeepgramSTT, type DeepgramSTTOptions, type DefineToolInput, type DtmfEvent, ConvAI as ElevenLabsConvAI, ElevenLabsConvAIAdapter, type ConvAIOptions as ElevenLabsConvAIOptions, TTS$4 as ElevenLabsTTS, type ElevenLabsTTSOptions, FallbackLLMProvider, type FallbackLLMProviderOptions, type FilePcmSource, GEMINI_DEFAULT_INPUT_SR, GEMINI_DEFAULT_OUTPUT_SR, GeminiLiveAdapter, type GeminiLiveEventHandler, LLM as GoogleLLM, type GoogleLLMOptions, LLM$2 as GroqLLM, type GroqLLMOptions, Guardrail$1 as Guardrail, type GuardrailOptions, type HookContext, IVRActivity, type IVRActivityOptions, type IVRToolDefinition, type IncomingMessage, type JobCallback, type LLMChunk, LLMLoop, type LLMProvider, type LMNTAudioFormat, type LMNTModel, type LMNTSampleRate, TTS as LMNTTTS, type LMNTTTSOptions, type LatencyBreakdown, type LocalCallOptions, type LocalConfig, type LocalOptions, type Logger, type LoopCallback, type MessageHandler, MetricsStore, LLM$4 as OpenAILLM, type OpenAILLMOptions, OpenAILLMProvider, type OpenAIMessage, Realtime as OpenAIRealtime, OpenAIRealtimeAdapter, type RealtimeOptions as OpenAIRealtimeOptions, TTS$3 as OpenAITTS, type OpenAITTSOptions, type ParamSpec, PartialStreamError, Patter, PatterConnectionError, PatterError, type PatterOptions, type PhoneNumber, PipelineHookExecutor, type PipelineHooks, type PipelineMessageHandler, type ProviderPricing, ProvisionError, type RawPcmSource, RemoteMessageHandler, TTS$1 as RimeTTS, type RimeTTSOptions, type SSEEvent, type STTConfig, type ScheduleHandle, SentenceChunker, type ServeOptions, type SilenceCallback, STT$1 as SonioxSTT, type SonioxSTTOptions$1 as SonioxSTTOptions, Static as StaticTunnel, type TTSConfig, Carrier as Telnyx, type TelnyxCarrierOptions, TestSession, TfidfLoopDetector, type TfidfLoopDetectorOptions, Tool, type ToolDefinition, type ToolHandler, type ToolOptions, type TunnelHandle, type TurnMetrics, Carrier$1 as Twilio, type TwilioCarrierOptions, ULTRAVOX_DEFAULT_API_BASE, ULTRAVOX_DEFAULT_SR, type UltravoxEventHandler, UltravoxRealtimeAdapter, STT$3 as WhisperSTT, type WhisperSTTOptions, builtinClipPath, calculateRealtimeCost, calculateSttCost, calculateTelephonyCost, calculateTtsCost, callsToCsv, callsToJson, deepgram, defineTool, elevenlabs, filterEmoji, filterForTTS, filterMarkdown, formatDtmf, getLogger, guardrail, isRemoteUrl, isWebSocketUrl, makeAuthMiddleware, mergePricing, mixPcm, mountApi, mountDashboard, mulawToPcm16, notifyDashboard, openaiTts, pcm16ToMulaw, resample16kTo8k, resample24kTo16k, resample8kTo16k, resamplePcm, scheduleCron, scheduleInterval, scheduleOnce, selectSoundFromList, setLogger, startTunnel, tool, whisper };
|