@contentgrowth/llm-service 1.2.3 → 1.3.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/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import OpenAI from 'openai';
2
+ import Anthropic from '@anthropic-ai/sdk';
2
3
  import * as _google_genai from '@google/genai';
3
4
  import { GoogleGenAI } from '@google/genai';
4
5
 
@@ -158,35 +159,71 @@ declare class OpenAIProvider extends BaseLLMProvider {
158
159
  declare class AnthropicProvider extends BaseLLMProvider {
159
160
  models: any;
160
161
  defaultModel: any;
162
+ client: Anthropic;
161
163
  chat(userMessage: any, systemPrompt?: string, options?: {}): Promise<{
162
- text: any;
164
+ text: string;
163
165
  }>;
164
166
  chatCompletion(messages: any, systemPrompt: any, tools?: any, options?: {}): Promise<{
165
- content: any;
166
- tool_calls: any;
167
+ content: string;
168
+ tool_calls: {
169
+ id: string;
170
+ type: string;
171
+ function: {
172
+ name: string;
173
+ arguments: string;
174
+ };
175
+ }[];
167
176
  finishReason: string;
168
- _rawFinishReason: any;
177
+ _rawFinishReason: Anthropic.Messages.StopReason;
169
178
  _responseFormat: any;
170
179
  usage: {
171
- prompt_tokens: any;
172
- completion_tokens: any;
173
- total_tokens: any;
180
+ prompt_tokens: number;
181
+ completion_tokens: number;
182
+ total_tokens: number;
174
183
  };
175
184
  model: any;
176
185
  }>;
177
186
  _chatCompletionWithModel(messages: any, systemPrompt: any, tools: any, modelName: any, maxTokens: any, temperature: any, options?: {}): Promise<{
178
- content: any;
179
- tool_calls: any;
187
+ content: string;
188
+ tool_calls: {
189
+ id: string;
190
+ type: string;
191
+ function: {
192
+ name: string;
193
+ arguments: string;
194
+ };
195
+ }[];
180
196
  finishReason: string;
181
- _rawFinishReason: any;
197
+ _rawFinishReason: Anthropic.Messages.StopReason;
182
198
  _responseFormat: any;
183
199
  usage: {
184
- prompt_tokens: any;
185
- completion_tokens: any;
186
- total_tokens: any;
200
+ prompt_tokens: number;
201
+ completion_tokens: number;
202
+ total_tokens: number;
187
203
  };
188
204
  model: any;
189
205
  }>;
206
+ /**
207
+ * Convert standard {role, content, tool_calls, tool_call_id} messages
208
+ * to Anthropic's message format.
209
+ *
210
+ * Key differences from OpenAI:
211
+ * - No 'system' role in messages array (handled via top-level `system` param)
212
+ * - Tool results go as role:'user' with content type:'tool_result'
213
+ * - Assistant messages with tool calls use an array of content blocks
214
+ * - Roles must strictly alternate user/assistant
215
+ */
216
+ _formatMessages(messages: any): {
217
+ role: string;
218
+ content: any;
219
+ }[];
220
+ /**
221
+ * Convert OpenAI-style tool definitions to Anthropic format.
222
+ * OpenAI: { type: 'function', function: { name, description, parameters } }
223
+ * Anthropic: { name, description, input_schema }
224
+ */
225
+ _formatTools(tools: any): any;
226
+ executeTools(tool_calls: any, messages: any, tenantId: any, toolImplementations: any, env: any): Promise<void>;
190
227
  _getModelForTier(tier: any): any;
191
228
  _shouldAutoParse(options: any): boolean;
192
229
  _safeJsonParse(text: any): any;
@@ -365,6 +402,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
365
402
  getConfig(tenantId: any, env: any): Promise<{
366
403
  provider: any;
367
404
  apiKey: any;
405
+ baseURL: any;
368
406
  project: any;
369
407
  location: any;
370
408
  models: any;
@@ -373,6 +411,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
373
411
  } | {
374
412
  provider: any;
375
413
  apiKey: any;
414
+ baseURL: any;
376
415
  models: any;
377
416
  temperature: number;
378
417
  maxTokens: number;
@@ -384,6 +423,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
384
423
  provider: any;
385
424
  models: any;
386
425
  apiKey: any;
426
+ baseURL: any;
387
427
  project: any;
388
428
  location: any;
389
429
  temperature: number;
@@ -394,6 +434,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
394
434
  _getSystemConfig(env: any): {
395
435
  provider: any;
396
436
  apiKey: any;
437
+ baseURL: any;
397
438
  project: any;
398
439
  location: any;
399
440
  models: any;
@@ -402,6 +443,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
402
443
  } | {
403
444
  provider: any;
404
445
  apiKey: any;
446
+ baseURL: any;
405
447
  models: any;
406
448
  temperature: number;
407
449
  maxTokens: number;
@@ -472,6 +514,7 @@ declare class ConfigManager {
472
514
  static getConfig(tenantId: any, env: any): Promise<{
473
515
  provider: any;
474
516
  apiKey: any;
517
+ baseURL: any;
475
518
  project: any;
476
519
  location: any;
477
520
  models: any;
@@ -480,6 +523,7 @@ declare class ConfigManager {
480
523
  } | {
481
524
  provider: any;
482
525
  apiKey: any;
526
+ baseURL: any;
483
527
  models: any;
484
528
  temperature: number;
485
529
  maxTokens: number;
@@ -517,7 +561,10 @@ declare class GoogleProvider extends BaseLLMProvider {
517
561
  thought_signature: any;
518
562
  tool_calls: {
519
563
  type: string;
520
- function: _google_genai.FunctionCall;
564
+ function: {
565
+ name: string;
566
+ arguments: string;
567
+ };
521
568
  thought_signature: any;
522
569
  }[];
523
570
  finishReason: string;
@@ -536,7 +583,10 @@ declare class GoogleProvider extends BaseLLMProvider {
536
583
  thought_signature: any;
537
584
  tool_calls: {
538
585
  type: string;
539
- function: _google_genai.FunctionCall;
586
+ function: {
587
+ name: string;
588
+ arguments: string;
589
+ };
540
590
  thought_signature: any;
541
591
  }[];
542
592
  finishReason: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import OpenAI from 'openai';
2
+ import Anthropic from '@anthropic-ai/sdk';
2
3
  import * as _google_genai from '@google/genai';
3
4
  import { GoogleGenAI } from '@google/genai';
4
5
 
@@ -158,35 +159,71 @@ declare class OpenAIProvider extends BaseLLMProvider {
158
159
  declare class AnthropicProvider extends BaseLLMProvider {
159
160
  models: any;
160
161
  defaultModel: any;
162
+ client: Anthropic;
161
163
  chat(userMessage: any, systemPrompt?: string, options?: {}): Promise<{
162
- text: any;
164
+ text: string;
163
165
  }>;
164
166
  chatCompletion(messages: any, systemPrompt: any, tools?: any, options?: {}): Promise<{
165
- content: any;
166
- tool_calls: any;
167
+ content: string;
168
+ tool_calls: {
169
+ id: string;
170
+ type: string;
171
+ function: {
172
+ name: string;
173
+ arguments: string;
174
+ };
175
+ }[];
167
176
  finishReason: string;
168
- _rawFinishReason: any;
177
+ _rawFinishReason: Anthropic.Messages.StopReason;
169
178
  _responseFormat: any;
170
179
  usage: {
171
- prompt_tokens: any;
172
- completion_tokens: any;
173
- total_tokens: any;
180
+ prompt_tokens: number;
181
+ completion_tokens: number;
182
+ total_tokens: number;
174
183
  };
175
184
  model: any;
176
185
  }>;
177
186
  _chatCompletionWithModel(messages: any, systemPrompt: any, tools: any, modelName: any, maxTokens: any, temperature: any, options?: {}): Promise<{
178
- content: any;
179
- tool_calls: any;
187
+ content: string;
188
+ tool_calls: {
189
+ id: string;
190
+ type: string;
191
+ function: {
192
+ name: string;
193
+ arguments: string;
194
+ };
195
+ }[];
180
196
  finishReason: string;
181
- _rawFinishReason: any;
197
+ _rawFinishReason: Anthropic.Messages.StopReason;
182
198
  _responseFormat: any;
183
199
  usage: {
184
- prompt_tokens: any;
185
- completion_tokens: any;
186
- total_tokens: any;
200
+ prompt_tokens: number;
201
+ completion_tokens: number;
202
+ total_tokens: number;
187
203
  };
188
204
  model: any;
189
205
  }>;
206
+ /**
207
+ * Convert standard {role, content, tool_calls, tool_call_id} messages
208
+ * to Anthropic's message format.
209
+ *
210
+ * Key differences from OpenAI:
211
+ * - No 'system' role in messages array (handled via top-level `system` param)
212
+ * - Tool results go as role:'user' with content type:'tool_result'
213
+ * - Assistant messages with tool calls use an array of content blocks
214
+ * - Roles must strictly alternate user/assistant
215
+ */
216
+ _formatMessages(messages: any): {
217
+ role: string;
218
+ content: any;
219
+ }[];
220
+ /**
221
+ * Convert OpenAI-style tool definitions to Anthropic format.
222
+ * OpenAI: { type: 'function', function: { name, description, parameters } }
223
+ * Anthropic: { name, description, input_schema }
224
+ */
225
+ _formatTools(tools: any): any;
226
+ executeTools(tool_calls: any, messages: any, tenantId: any, toolImplementations: any, env: any): Promise<void>;
190
227
  _getModelForTier(tier: any): any;
191
228
  _shouldAutoParse(options: any): boolean;
192
229
  _safeJsonParse(text: any): any;
@@ -365,6 +402,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
365
402
  getConfig(tenantId: any, env: any): Promise<{
366
403
  provider: any;
367
404
  apiKey: any;
405
+ baseURL: any;
368
406
  project: any;
369
407
  location: any;
370
408
  models: any;
@@ -373,6 +411,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
373
411
  } | {
374
412
  provider: any;
375
413
  apiKey: any;
414
+ baseURL: any;
376
415
  models: any;
377
416
  temperature: number;
378
417
  maxTokens: number;
@@ -384,6 +423,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
384
423
  provider: any;
385
424
  models: any;
386
425
  apiKey: any;
426
+ baseURL: any;
387
427
  project: any;
388
428
  location: any;
389
429
  temperature: number;
@@ -394,6 +434,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
394
434
  _getSystemConfig(env: any): {
395
435
  provider: any;
396
436
  apiKey: any;
437
+ baseURL: any;
397
438
  project: any;
398
439
  location: any;
399
440
  models: any;
@@ -402,6 +443,7 @@ declare class DefaultConfigProvider extends BaseConfigProvider$1 {
402
443
  } | {
403
444
  provider: any;
404
445
  apiKey: any;
446
+ baseURL: any;
405
447
  models: any;
406
448
  temperature: number;
407
449
  maxTokens: number;
@@ -472,6 +514,7 @@ declare class ConfigManager {
472
514
  static getConfig(tenantId: any, env: any): Promise<{
473
515
  provider: any;
474
516
  apiKey: any;
517
+ baseURL: any;
475
518
  project: any;
476
519
  location: any;
477
520
  models: any;
@@ -480,6 +523,7 @@ declare class ConfigManager {
480
523
  } | {
481
524
  provider: any;
482
525
  apiKey: any;
526
+ baseURL: any;
483
527
  models: any;
484
528
  temperature: number;
485
529
  maxTokens: number;
@@ -517,7 +561,10 @@ declare class GoogleProvider extends BaseLLMProvider {
517
561
  thought_signature: any;
518
562
  tool_calls: {
519
563
  type: string;
520
- function: _google_genai.FunctionCall;
564
+ function: {
565
+ name: string;
566
+ arguments: string;
567
+ };
521
568
  thought_signature: any;
522
569
  }[];
523
570
  finishReason: string;
@@ -536,7 +583,10 @@ declare class GoogleProvider extends BaseLLMProvider {
536
583
  thought_signature: any;
537
584
  tool_calls: {
538
585
  type: string;
539
- function: _google_genai.FunctionCall;
586
+ function: {
587
+ name: string;
588
+ arguments: string;
589
+ };
540
590
  thought_signature: any;
541
591
  }[];
542
592
  finishReason: string;