@contentgrowth/llm-service 1.3.3 → 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 +181 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -5
- package/dist/index.d.ts +73 -5
- package/dist/index.js +178 -48
- 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"
|
|
@@ -110,7 +116,7 @@ declare class BaseLLMProvider {
|
|
|
110
116
|
|
|
111
117
|
declare class OpenAIProvider extends BaseLLMProvider {
|
|
112
118
|
client: OpenAI;
|
|
113
|
-
models:
|
|
119
|
+
models: {};
|
|
114
120
|
defaultModel: any;
|
|
115
121
|
chat(userMessage: any, systemPrompt?: string, options?: {}): Promise<{
|
|
116
122
|
text: string;
|
|
@@ -129,6 +135,11 @@ declare class OpenAIProvider extends BaseLLMProvider {
|
|
|
129
135
|
total_tokens: number;
|
|
130
136
|
};
|
|
131
137
|
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Per-call model resolution: explicit options.model > options.tier > default
|
|
140
|
+
*/
|
|
141
|
+
_resolveModel(options?: {}): any;
|
|
142
|
+
_isReasoningModel(modelName: any): boolean;
|
|
132
143
|
_chatCompletionWithModel(messages: any, systemPrompt: any, tools: any, modelName: any, maxTokens: any, temperature: any, options?: {}): Promise<{
|
|
133
144
|
model: any;
|
|
134
145
|
parsedContent?: any;
|
|
@@ -164,7 +175,7 @@ declare class OpenAIProvider extends BaseLLMProvider {
|
|
|
164
175
|
}
|
|
165
176
|
|
|
166
177
|
declare class AnthropicProvider extends BaseLLMProvider {
|
|
167
|
-
models:
|
|
178
|
+
models: {};
|
|
168
179
|
defaultModel: any;
|
|
169
180
|
client: Anthropic;
|
|
170
181
|
chat(userMessage: any, systemPrompt?: string, options?: {}): Promise<{
|
|
@@ -232,6 +243,11 @@ declare class AnthropicProvider extends BaseLLMProvider {
|
|
|
232
243
|
_formatTools(tools: any): any;
|
|
233
244
|
executeTools(tool_calls: any, messages: any, tenantId: any, toolImplementations: any, env: any): Promise<void>;
|
|
234
245
|
_getModelForTier(tier: any): any;
|
|
246
|
+
/**
|
|
247
|
+
* Per-call model resolution: explicit options.model > options.tier > default
|
|
248
|
+
*/
|
|
249
|
+
_resolveModel(options?: {}): any;
|
|
250
|
+
_supportsSamplingParams(modelName: any): boolean;
|
|
235
251
|
_shouldAutoParse(options: any): boolean;
|
|
236
252
|
_safeJsonParse(text: any): any;
|
|
237
253
|
normalizeFinishReason(providerReason: any): string;
|
|
@@ -391,6 +407,14 @@ declare class LLMService {
|
|
|
391
407
|
* @returns {Promise<any>} Extracted data
|
|
392
408
|
*/
|
|
393
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>;
|
|
394
418
|
}
|
|
395
419
|
declare class LLMServiceException extends Error {
|
|
396
420
|
constructor(message: any, statusCode?: number, details?: any);
|
|
@@ -434,9 +458,17 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
|
|
|
434
458
|
location?: undefined;
|
|
435
459
|
}>;
|
|
436
460
|
_loadFromTenantDO(tenantId: any, env: any): Promise<any>;
|
|
461
|
+
/**
|
|
462
|
+
* Resolve the model map for a tenant.
|
|
463
|
+
* Precedence (highest first):
|
|
464
|
+
* 1. tenantConfig.model - single model chosen by the tenant (becomes `default`)
|
|
465
|
+
* 2. tenantConfig.models[tier] - per-tier overrides supplied by the tenant
|
|
466
|
+
* 3. MODEL_CONFIGS[provider] - library defaults
|
|
467
|
+
*/
|
|
468
|
+
_resolveTenantModels(tenantConfig: any): {};
|
|
437
469
|
_buildTenantConfig(tenantConfig: any, env: any): {
|
|
438
470
|
provider: any;
|
|
439
|
-
models:
|
|
471
|
+
models: {};
|
|
440
472
|
apiKey: any;
|
|
441
473
|
baseURL: any;
|
|
442
474
|
project: any;
|
|
@@ -467,6 +499,12 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
|
|
|
467
499
|
};
|
|
468
500
|
}
|
|
469
501
|
|
|
502
|
+
/**
|
|
503
|
+
* Map a known-invalid legacy model ID to a valid one. Unknown IDs pass through untouched.
|
|
504
|
+
* @param {string} model
|
|
505
|
+
* @returns {string}
|
|
506
|
+
*/
|
|
507
|
+
declare function normalizeModelId(model: string): string;
|
|
470
508
|
declare namespace MODEL_CONFIGS {
|
|
471
509
|
namespace openai {
|
|
472
510
|
let _default: string;
|
|
@@ -519,6 +557,22 @@ declare namespace MODEL_CONFIGS {
|
|
|
519
557
|
export { free_3 as free };
|
|
520
558
|
}
|
|
521
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Invalid model IDs that earlier versions of this library shipped as defaults.
|
|
562
|
+
* Consumers persisted some of them (e.g. saved BYOK key configs), so we map them
|
|
563
|
+
* to a valid equivalent instead of letting the provider return 404.
|
|
564
|
+
*/
|
|
565
|
+
declare const LEGACY_MODEL_ALIASES: {
|
|
566
|
+
'gpt-5.5-instant': string;
|
|
567
|
+
'gpt-5.5-thinking': string;
|
|
568
|
+
'gemini-3.5-pro': string;
|
|
569
|
+
'gemini-3.7-pro': string;
|
|
570
|
+
'gemini-3.5-pro-image-preview': string;
|
|
571
|
+
'gemini-3.7-pro-image-preview': string;
|
|
572
|
+
'claude-4.5-haiku': string;
|
|
573
|
+
'claude-4.6-sonnet': string;
|
|
574
|
+
'claude-4.8-opus': string;
|
|
575
|
+
};
|
|
522
576
|
declare class ConfigManager {
|
|
523
577
|
static _provider: DefaultConfigProvider;
|
|
524
578
|
/**
|
|
@@ -556,7 +610,7 @@ declare class ConfigManager {
|
|
|
556
610
|
* - Vertex + ADC/IAM: { vertexai: true, project, location } — no apiKey
|
|
557
611
|
*/
|
|
558
612
|
declare class GoogleProvider extends BaseLLMProvider {
|
|
559
|
-
models:
|
|
613
|
+
models: {};
|
|
560
614
|
defaultModel: any;
|
|
561
615
|
_pendingOperations: Map<any, any>;
|
|
562
616
|
client: GoogleGenAI;
|
|
@@ -658,6 +712,20 @@ declare class GoogleProvider extends BaseLLMProvider {
|
|
|
658
712
|
voice: string;
|
|
659
713
|
model: string;
|
|
660
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>;
|
|
661
729
|
}
|
|
662
730
|
|
|
663
731
|
/**
|
|
@@ -794,4 +862,4 @@ declare class TranscriptionServiceException extends Error {
|
|
|
794
862
|
statusCode: number;
|
|
795
863
|
}
|
|
796
864
|
|
|
797
|
-
export { AnthropicProvider, BaseConfigProvider$1 as BaseConfigProvider, ConfigManager, DefaultConfigProvider, FINISH_REASONS, GoogleProvider as GeminiProvider, GoogleProvider, LLMService, LLMServiceException, MODEL_CONFIGS, OpenAIProvider, TranscriptionService, TranscriptionServiceException, GoogleProvider as VertexProvider, createSpeechHandler, extractJsonFromResponse, extractTextAndJson, handleApiError, sanitizeError };
|
|
865
|
+
export { AnthropicProvider, BaseConfigProvider$1 as BaseConfigProvider, ConfigManager, DefaultConfigProvider, FINISH_REASONS, GoogleProvider as GeminiProvider, GoogleProvider, LEGACY_MODEL_ALIASES, LLMService, LLMServiceException, MODEL_CONFIGS, OpenAIProvider, TranscriptionService, TranscriptionServiceException, GoogleProvider as VertexProvider, createSpeechHandler, extractJsonFromResponse, extractTextAndJson, handleApiError, normalizeModelId, sanitizeError };
|
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"
|
|
@@ -110,7 +116,7 @@ declare class BaseLLMProvider {
|
|
|
110
116
|
|
|
111
117
|
declare class OpenAIProvider extends BaseLLMProvider {
|
|
112
118
|
client: OpenAI;
|
|
113
|
-
models:
|
|
119
|
+
models: {};
|
|
114
120
|
defaultModel: any;
|
|
115
121
|
chat(userMessage: any, systemPrompt?: string, options?: {}): Promise<{
|
|
116
122
|
text: string;
|
|
@@ -129,6 +135,11 @@ declare class OpenAIProvider extends BaseLLMProvider {
|
|
|
129
135
|
total_tokens: number;
|
|
130
136
|
};
|
|
131
137
|
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Per-call model resolution: explicit options.model > options.tier > default
|
|
140
|
+
*/
|
|
141
|
+
_resolveModel(options?: {}): any;
|
|
142
|
+
_isReasoningModel(modelName: any): boolean;
|
|
132
143
|
_chatCompletionWithModel(messages: any, systemPrompt: any, tools: any, modelName: any, maxTokens: any, temperature: any, options?: {}): Promise<{
|
|
133
144
|
model: any;
|
|
134
145
|
parsedContent?: any;
|
|
@@ -164,7 +175,7 @@ declare class OpenAIProvider extends BaseLLMProvider {
|
|
|
164
175
|
}
|
|
165
176
|
|
|
166
177
|
declare class AnthropicProvider extends BaseLLMProvider {
|
|
167
|
-
models:
|
|
178
|
+
models: {};
|
|
168
179
|
defaultModel: any;
|
|
169
180
|
client: Anthropic;
|
|
170
181
|
chat(userMessage: any, systemPrompt?: string, options?: {}): Promise<{
|
|
@@ -232,6 +243,11 @@ declare class AnthropicProvider extends BaseLLMProvider {
|
|
|
232
243
|
_formatTools(tools: any): any;
|
|
233
244
|
executeTools(tool_calls: any, messages: any, tenantId: any, toolImplementations: any, env: any): Promise<void>;
|
|
234
245
|
_getModelForTier(tier: any): any;
|
|
246
|
+
/**
|
|
247
|
+
* Per-call model resolution: explicit options.model > options.tier > default
|
|
248
|
+
*/
|
|
249
|
+
_resolveModel(options?: {}): any;
|
|
250
|
+
_supportsSamplingParams(modelName: any): boolean;
|
|
235
251
|
_shouldAutoParse(options: any): boolean;
|
|
236
252
|
_safeJsonParse(text: any): any;
|
|
237
253
|
normalizeFinishReason(providerReason: any): string;
|
|
@@ -391,6 +407,14 @@ declare class LLMService {
|
|
|
391
407
|
* @returns {Promise<any>} Extracted data
|
|
392
408
|
*/
|
|
393
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>;
|
|
394
418
|
}
|
|
395
419
|
declare class LLMServiceException extends Error {
|
|
396
420
|
constructor(message: any, statusCode?: number, details?: any);
|
|
@@ -434,9 +458,17 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
|
|
|
434
458
|
location?: undefined;
|
|
435
459
|
}>;
|
|
436
460
|
_loadFromTenantDO(tenantId: any, env: any): Promise<any>;
|
|
461
|
+
/**
|
|
462
|
+
* Resolve the model map for a tenant.
|
|
463
|
+
* Precedence (highest first):
|
|
464
|
+
* 1. tenantConfig.model - single model chosen by the tenant (becomes `default`)
|
|
465
|
+
* 2. tenantConfig.models[tier] - per-tier overrides supplied by the tenant
|
|
466
|
+
* 3. MODEL_CONFIGS[provider] - library defaults
|
|
467
|
+
*/
|
|
468
|
+
_resolveTenantModels(tenantConfig: any): {};
|
|
437
469
|
_buildTenantConfig(tenantConfig: any, env: any): {
|
|
438
470
|
provider: any;
|
|
439
|
-
models:
|
|
471
|
+
models: {};
|
|
440
472
|
apiKey: any;
|
|
441
473
|
baseURL: any;
|
|
442
474
|
project: any;
|
|
@@ -467,6 +499,12 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
|
|
|
467
499
|
};
|
|
468
500
|
}
|
|
469
501
|
|
|
502
|
+
/**
|
|
503
|
+
* Map a known-invalid legacy model ID to a valid one. Unknown IDs pass through untouched.
|
|
504
|
+
* @param {string} model
|
|
505
|
+
* @returns {string}
|
|
506
|
+
*/
|
|
507
|
+
declare function normalizeModelId(model: string): string;
|
|
470
508
|
declare namespace MODEL_CONFIGS {
|
|
471
509
|
namespace openai {
|
|
472
510
|
let _default: string;
|
|
@@ -519,6 +557,22 @@ declare namespace MODEL_CONFIGS {
|
|
|
519
557
|
export { free_3 as free };
|
|
520
558
|
}
|
|
521
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Invalid model IDs that earlier versions of this library shipped as defaults.
|
|
562
|
+
* Consumers persisted some of them (e.g. saved BYOK key configs), so we map them
|
|
563
|
+
* to a valid equivalent instead of letting the provider return 404.
|
|
564
|
+
*/
|
|
565
|
+
declare const LEGACY_MODEL_ALIASES: {
|
|
566
|
+
'gpt-5.5-instant': string;
|
|
567
|
+
'gpt-5.5-thinking': string;
|
|
568
|
+
'gemini-3.5-pro': string;
|
|
569
|
+
'gemini-3.7-pro': string;
|
|
570
|
+
'gemini-3.5-pro-image-preview': string;
|
|
571
|
+
'gemini-3.7-pro-image-preview': string;
|
|
572
|
+
'claude-4.5-haiku': string;
|
|
573
|
+
'claude-4.6-sonnet': string;
|
|
574
|
+
'claude-4.8-opus': string;
|
|
575
|
+
};
|
|
522
576
|
declare class ConfigManager {
|
|
523
577
|
static _provider: DefaultConfigProvider;
|
|
524
578
|
/**
|
|
@@ -556,7 +610,7 @@ declare class ConfigManager {
|
|
|
556
610
|
* - Vertex + ADC/IAM: { vertexai: true, project, location } — no apiKey
|
|
557
611
|
*/
|
|
558
612
|
declare class GoogleProvider extends BaseLLMProvider {
|
|
559
|
-
models:
|
|
613
|
+
models: {};
|
|
560
614
|
defaultModel: any;
|
|
561
615
|
_pendingOperations: Map<any, any>;
|
|
562
616
|
client: GoogleGenAI;
|
|
@@ -658,6 +712,20 @@ declare class GoogleProvider extends BaseLLMProvider {
|
|
|
658
712
|
voice: string;
|
|
659
713
|
model: string;
|
|
660
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>;
|
|
661
729
|
}
|
|
662
730
|
|
|
663
731
|
/**
|
|
@@ -794,4 +862,4 @@ declare class TranscriptionServiceException extends Error {
|
|
|
794
862
|
statusCode: number;
|
|
795
863
|
}
|
|
796
864
|
|
|
797
|
-
export { AnthropicProvider, BaseConfigProvider$1 as BaseConfigProvider, ConfigManager, DefaultConfigProvider, FINISH_REASONS, GoogleProvider as GeminiProvider, GoogleProvider, LLMService, LLMServiceException, MODEL_CONFIGS, OpenAIProvider, TranscriptionService, TranscriptionServiceException, GoogleProvider as VertexProvider, createSpeechHandler, extractJsonFromResponse, extractTextAndJson, handleApiError, sanitizeError };
|
|
865
|
+
export { AnthropicProvider, BaseConfigProvider$1 as BaseConfigProvider, ConfigManager, DefaultConfigProvider, FINISH_REASONS, GoogleProvider as GeminiProvider, GoogleProvider, LEGACY_MODEL_ALIASES, LLMService, LLMServiceException, MODEL_CONFIGS, OpenAIProvider, TranscriptionService, TranscriptionServiceException, GoogleProvider as VertexProvider, createSpeechHandler, extractJsonFromResponse, extractTextAndJson, handleApiError, normalizeModelId, sanitizeError };
|