@contentgrowth/llm-service 1.3.4 → 1.3.5
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/dist/index.cjs +48 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ import OpenAI from 'openai';
|
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
3
|
import * as _google_genai from '@google/genai';
|
|
4
4
|
import { GoogleGenAI } from '@google/genai';
|
|
5
|
+
export { Modality } from '@google/genai';
|
|
5
6
|
|
|
6
7
|
declare namespace FINISH_REASONS {
|
|
7
8
|
let COMPLETED: string;
|
|
@@ -101,6 +102,11 @@ declare class BaseLLMProvider {
|
|
|
101
102
|
* @param {Object} options - Options
|
|
102
103
|
*/
|
|
103
104
|
extractWithLLM(fileData: Buffer | string, mimeType: string, prompt: string, schema: any, options: any): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Connect to a bidirectional real-time Live session
|
|
107
|
+
* @param {Object} options - { model, config, callbacks }
|
|
108
|
+
*/
|
|
109
|
+
connectLive(options: any): Promise<void>;
|
|
104
110
|
/**
|
|
105
111
|
* Helper to get the last 6 digits of the API key for logging.
|
|
106
112
|
* @returns {string} "..." + last 6 chars, or "not_set"
|
|
@@ -401,6 +407,14 @@ declare class LLMService {
|
|
|
401
407
|
* @returns {Promise<any>} Extracted data
|
|
402
408
|
*/
|
|
403
409
|
extractWithLLM(fileData: Buffer | string, mimeType: string, prompt: string, tenantId: string | null, schema?: any | null, options?: any): Promise<any>;
|
|
410
|
+
/**
|
|
411
|
+
* Connect to a bidirectional real-time Live session
|
|
412
|
+
*
|
|
413
|
+
* @param {Object} params - { model, config, callbacks }
|
|
414
|
+
* @param {string|null} [tenantId] - Tenant ID
|
|
415
|
+
* @returns {Promise<any>} The active Live session
|
|
416
|
+
*/
|
|
417
|
+
connectLive(params: any, tenantId?: string | null): Promise<any>;
|
|
404
418
|
}
|
|
405
419
|
declare class LLMServiceException extends Error {
|
|
406
420
|
constructor(message: any, statusCode?: number, details?: any);
|
|
@@ -698,6 +712,20 @@ declare class GoogleProvider extends BaseLLMProvider {
|
|
|
698
712
|
voice: string;
|
|
699
713
|
model: string;
|
|
700
714
|
}): Promise<Buffer>;
|
|
715
|
+
/**
|
|
716
|
+
* Connect to Gemini Live bidirectional real-time audio/text session
|
|
717
|
+
*
|
|
718
|
+
* @param {Object} options
|
|
719
|
+
* @param {string} [options.model] - Model name (e.g. models/gemini-2.5-flash-native-audio-preview-09-2025)
|
|
720
|
+
* @param {Object} options.config - Live session configuration
|
|
721
|
+
* @param {Object} options.callbacks - Event callbacks (onopen, onmessage, onerror, onclose)
|
|
722
|
+
* @returns {Promise<any>} The active Live session
|
|
723
|
+
*/
|
|
724
|
+
connectLive({ model, config, callbacks }: {
|
|
725
|
+
model?: string;
|
|
726
|
+
config: any;
|
|
727
|
+
callbacks: any;
|
|
728
|
+
}): Promise<any>;
|
|
701
729
|
}
|
|
702
730
|
|
|
703
731
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import OpenAI from 'openai';
|
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
3
|
import * as _google_genai from '@google/genai';
|
|
4
4
|
import { GoogleGenAI } from '@google/genai';
|
|
5
|
+
export { Modality } from '@google/genai';
|
|
5
6
|
|
|
6
7
|
declare namespace FINISH_REASONS {
|
|
7
8
|
let COMPLETED: string;
|
|
@@ -101,6 +102,11 @@ declare class BaseLLMProvider {
|
|
|
101
102
|
* @param {Object} options - Options
|
|
102
103
|
*/
|
|
103
104
|
extractWithLLM(fileData: Buffer | string, mimeType: string, prompt: string, schema: any, options: any): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Connect to a bidirectional real-time Live session
|
|
107
|
+
* @param {Object} options - { model, config, callbacks }
|
|
108
|
+
*/
|
|
109
|
+
connectLive(options: any): Promise<void>;
|
|
104
110
|
/**
|
|
105
111
|
* Helper to get the last 6 digits of the API key for logging.
|
|
106
112
|
* @returns {string} "..." + last 6 chars, or "not_set"
|
|
@@ -401,6 +407,14 @@ declare class LLMService {
|
|
|
401
407
|
* @returns {Promise<any>} Extracted data
|
|
402
408
|
*/
|
|
403
409
|
extractWithLLM(fileData: Buffer | string, mimeType: string, prompt: string, tenantId: string | null, schema?: any | null, options?: any): Promise<any>;
|
|
410
|
+
/**
|
|
411
|
+
* Connect to a bidirectional real-time Live session
|
|
412
|
+
*
|
|
413
|
+
* @param {Object} params - { model, config, callbacks }
|
|
414
|
+
* @param {string|null} [tenantId] - Tenant ID
|
|
415
|
+
* @returns {Promise<any>} The active Live session
|
|
416
|
+
*/
|
|
417
|
+
connectLive(params: any, tenantId?: string | null): Promise<any>;
|
|
404
418
|
}
|
|
405
419
|
declare class LLMServiceException extends Error {
|
|
406
420
|
constructor(message: any, statusCode?: number, details?: any);
|
|
@@ -698,6 +712,20 @@ declare class GoogleProvider extends BaseLLMProvider {
|
|
|
698
712
|
voice: string;
|
|
699
713
|
model: string;
|
|
700
714
|
}): Promise<Buffer>;
|
|
715
|
+
/**
|
|
716
|
+
* Connect to Gemini Live bidirectional real-time audio/text session
|
|
717
|
+
*
|
|
718
|
+
* @param {Object} options
|
|
719
|
+
* @param {string} [options.model] - Model name (e.g. models/gemini-2.5-flash-native-audio-preview-09-2025)
|
|
720
|
+
* @param {Object} options.config - Live session configuration
|
|
721
|
+
* @param {Object} options.callbacks - Event callbacks (onopen, onmessage, onerror, onclose)
|
|
722
|
+
* @returns {Promise<any>} The active Live session
|
|
723
|
+
*/
|
|
724
|
+
connectLive({ model, config, callbacks }: {
|
|
725
|
+
model?: string;
|
|
726
|
+
config: any;
|
|
727
|
+
callbacks: any;
|
|
728
|
+
}): Promise<any>;
|
|
701
729
|
}
|
|
702
730
|
|
|
703
731
|
/**
|
package/dist/index.js
CHANGED
|
@@ -379,6 +379,13 @@ var BaseLLMProvider = class {
|
|
|
379
379
|
async extractWithLLM(fileData, mimeType, prompt, schema, options) {
|
|
380
380
|
throw new Error("This provider does not support extractWithLLM (Multimodal extraction)");
|
|
381
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Connect to a bidirectional real-time Live session
|
|
384
|
+
* @param {Object} options - { model, config, callbacks }
|
|
385
|
+
*/
|
|
386
|
+
async connectLive(options) {
|
|
387
|
+
throw new Error(`This provider (${this.constructor.name}) does not support live real-time sessions`);
|
|
388
|
+
}
|
|
382
389
|
/**
|
|
383
390
|
* Helper to get the last 6 digits of the API key for logging.
|
|
384
391
|
* @returns {string} "..." + last 6 chars, or "not_set"
|
|
@@ -1302,6 +1309,27 @@ ${prompt}` : prompt;
|
|
|
1302
1309
|
throw error;
|
|
1303
1310
|
}
|
|
1304
1311
|
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Connect to Gemini Live bidirectional real-time audio/text session
|
|
1314
|
+
*
|
|
1315
|
+
* @param {Object} options
|
|
1316
|
+
* @param {string} [options.model] - Model name (e.g. models/gemini-2.5-flash-native-audio-preview-09-2025)
|
|
1317
|
+
* @param {Object} options.config - Live session configuration
|
|
1318
|
+
* @param {Object} options.callbacks - Event callbacks (onopen, onmessage, onerror, onclose)
|
|
1319
|
+
* @returns {Promise<any>} The active Live session
|
|
1320
|
+
*/
|
|
1321
|
+
async connectLive({ model, config, callbacks }) {
|
|
1322
|
+
var _a, _b, _c;
|
|
1323
|
+
if (!((_b = (_a = this.client) == null ? void 0 : _a.live) == null ? void 0 : _b.connect)) {
|
|
1324
|
+
throw new LLMServiceException("The configured Google provider SDK does not support live sessions.", 500);
|
|
1325
|
+
}
|
|
1326
|
+
const resolvedModel = model || ((_c = this.models) == null ? void 0 : _c.live) || this.defaultModel || "models/gemini-2.5-flash-native-audio-preview-09-2025";
|
|
1327
|
+
return this.client.live.connect({
|
|
1328
|
+
model: resolvedModel,
|
|
1329
|
+
config,
|
|
1330
|
+
callbacks
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1305
1333
|
};
|
|
1306
1334
|
|
|
1307
1335
|
// src/llm/providers/anthropic-provider.js
|
|
@@ -1834,6 +1862,21 @@ var LLMService = class {
|
|
|
1834
1862
|
}
|
|
1835
1863
|
return provider.extractWithLLM(fileData, mimeType, prompt, schema, options);
|
|
1836
1864
|
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Connect to a bidirectional real-time Live session
|
|
1867
|
+
*
|
|
1868
|
+
* @param {Object} params - { model, config, callbacks }
|
|
1869
|
+
* @param {string|null} [tenantId] - Tenant ID
|
|
1870
|
+
* @returns {Promise<any>} The active Live session
|
|
1871
|
+
*/
|
|
1872
|
+
async connectLive(params, tenantId = null) {
|
|
1873
|
+
var _a;
|
|
1874
|
+
const provider = await this._getProvider(tenantId);
|
|
1875
|
+
if (typeof provider.connectLive !== "function") {
|
|
1876
|
+
throw new LLMServiceException(`Provider ${((_a = provider.config) == null ? void 0 : _a.provider) || provider.constructor.name} does not support live real-time sessions`, 400);
|
|
1877
|
+
}
|
|
1878
|
+
return provider.connectLive(params);
|
|
1879
|
+
}
|
|
1837
1880
|
};
|
|
1838
1881
|
var LLMServiceException = class extends Error {
|
|
1839
1882
|
constructor(message, statusCode = 500, details = null) {
|
|
@@ -2168,6 +2211,9 @@ function createSpeechHandler(app, getConfig) {
|
|
|
2168
2211
|
});
|
|
2169
2212
|
return app;
|
|
2170
2213
|
}
|
|
2214
|
+
|
|
2215
|
+
// src/index.js
|
|
2216
|
+
import { Modality } from "@google/genai";
|
|
2171
2217
|
export {
|
|
2172
2218
|
AnthropicProvider,
|
|
2173
2219
|
BaseConfigProvider,
|
|
@@ -2180,6 +2226,7 @@ export {
|
|
|
2180
2226
|
LLMService,
|
|
2181
2227
|
LLMServiceException,
|
|
2182
2228
|
MODEL_CONFIGS,
|
|
2229
|
+
Modality,
|
|
2183
2230
|
OpenAIProvider,
|
|
2184
2231
|
TranscriptionService,
|
|
2185
2232
|
TranscriptionServiceException,
|