@contentgrowth/llm-service 0.7.1 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentgrowth/llm-service",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Unified LLM Service for Content Growth",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -180,7 +180,7 @@ export class GeminiProvider extends BaseLLMProvider {
180
180
  }
181
181
  }
182
182
 
183
- console.log('[GeminiProvider] generateContent request:', JSON.stringify(requestOptions, null, 2));
183
+ // console.log('[GeminiProvider] generateContent request:', JSON.stringify(requestOptions, null, 2));
184
184
 
185
185
  let response;
186
186
  try {
@@ -228,7 +228,7 @@ export class GeminiProvider extends BaseLLMProvider {
228
228
  );
229
229
  }
230
230
 
231
- console.log('Gemini returns:', textContent);
231
+ // console.log('Gemini returns:', textContent);
232
232
  // Return with parsed JSON if applicable
233
233
  return {
234
234
  content: textContent,
@@ -265,7 +265,7 @@ export class GeminiProvider extends BaseLLMProvider {
265
265
  // Use responseSchema for strict structured output
266
266
  // Must convert to Gemini Schema format (Uppercase types)
267
267
  config.responseSchema = this._convertToGeminiSchema(schema);
268
- console.log('[GeminiProvider] Using Strict JSON mode with schema (responseSchema)');
268
+ // console.log('[GeminiProvider] Using Strict JSON mode with schema (responseSchema)');
269
269
  } else {
270
270
  console.warn('[GeminiProvider] Using legacy JSON mode without schema - may produce markdown wrappers');
271
271
  }
@@ -336,9 +336,7 @@ export class GeminiProvider extends BaseLLMProvider {
336
336
  // - Brace extraction as fallback
337
337
  const parsed = extractJsonFromResponse(content);
338
338
 
339
- if (parsed) {
340
- console.log('[GeminiProvider] Successfully parsed JSON from response');
341
- } else {
339
+ if (!parsed) {
342
340
  console.error('[GeminiProvider] Failed to extract valid JSON from response');
343
341
  console.error('[GeminiProvider] Content preview:', content.substring(0, 200));
344
342
  }
@@ -354,7 +352,7 @@ export class GeminiProvider extends BaseLLMProvider {
354
352
  const tool_call_id = `gemini-tool-call-${index}`;
355
353
  toolCall.id = tool_call_id;
356
354
 
357
- console.log(`[Tool Call] ${toolName} with arguments:`, toolCall.function.args);
355
+ // console.log(`[Tool Call] ${toolName} with arguments:`, toolCall.function.args);
358
356
 
359
357
  if (!tool) {
360
358
  console.error(`[Tool Error] Tool '${toolName}' not found`);
@@ -362,7 +360,7 @@ export class GeminiProvider extends BaseLLMProvider {
362
360
  }
363
361
  try {
364
362
  const output = await tool(toolCall.function.args, { env, tenantId });
365
- console.log(`[Tool Result] ${toolName} returned:`, output.substring(0, 200) + (output.length > 200 ? '...' : ''));
363
+ // console.log(`[Tool Result] ${toolName} returned:`, output.substring(0, 200) + (output.length > 200 ? '...' : ''));
366
364
  return { tool_call_id, output };
367
365
  } catch (error) {
368
366
  console.error(`[Tool Error] ${toolName} failed:`, error.message);
@@ -411,7 +409,7 @@ export class GeminiProvider extends BaseLLMProvider {
411
409
  requestOptions.config.systemInstruction = { parts: [{ text: systemPrompt }] };
412
410
  }
413
411
 
414
- console.log('[GeminiProvider] imageGeneration request:', JSON.stringify(requestOptions, null, 2));
412
+ // console.log('[GeminiProvider] imageGeneration request:', JSON.stringify(requestOptions, null, 2));
415
413
 
416
414
  const response = await this.client.models.generateContent(requestOptions);
417
415
 
@@ -449,9 +447,12 @@ export class GeminiProvider extends BaseLLMProvider {
449
447
 
450
448
  async startVideoGeneration(prompt, images, modelName, systemPrompt, options = {}) {
451
449
  // Use unified client for video generation
452
- const operation = await this.client.models.generateVideos({
450
+ // Prepend system prompt to user prompt if provided, as video models often expect instructions in the prompt
451
+ const effectivePrompt = systemPrompt ? `${systemPrompt}\n\n${prompt}` : prompt;
452
+
453
+ const requestConfig = {
453
454
  model: modelName,
454
- prompt: prompt,
455
+ prompt: effectivePrompt,
455
456
  config: {
456
457
  durationSeconds: options.durationSeconds || 6,
457
458
  aspectRatio: options.aspectRatio || '16:9',
@@ -459,15 +460,35 @@ export class GeminiProvider extends BaseLLMProvider {
459
460
  // Pass reference images if provided
460
461
  ...(images && images.length > 0 ? { referenceImages: images } : {}),
461
462
  }
462
- });
463
+ };
463
464
 
464
- // Store operation for later polling
465
- this._pendingOperations.set(operation.name, operation);
465
+ // Create a loggable copy of the config
466
+ const logConfig = JSON.parse(JSON.stringify(requestConfig));
467
+ if (logConfig.config && logConfig.config.referenceImages) {
468
+ logConfig.config.referenceImages = logConfig.config.referenceImages.map(img => ({
469
+ ...img,
470
+ data: `... (${img.data ? img.data.length : 0} bytes)` // Summarize data
471
+ }));
472
+ }
473
+
474
+ console.log('[GeminiProvider] startVideoGeneration request:', JSON.stringify(logConfig, null, 2));
475
+
476
+ try {
477
+ const operation = await this.client.models.generateVideos(requestConfig);
466
478
 
467
- return { operationName: operation.name };
479
+ // Store operation for later polling
480
+ this._pendingOperations.set(operation.name, operation);
481
+
482
+ return { operationName: operation.name };
483
+ } catch (error) {
484
+ console.error('[GeminiProvider] startVideoGeneration failed:', error);
485
+ throw error;
486
+ }
468
487
  }
469
488
 
470
489
  async getVideoGenerationStatus(operationName) {
490
+ console.log(`[GeminiProvider] Checking status for operation: ${operationName}`);
491
+
471
492
  // Get the operation from cache or fetch it
472
493
  let operation = this._pendingOperations.get(operationName);
473
494
 
@@ -488,6 +509,8 @@ export class GeminiProvider extends BaseLLMProvider {
488
509
  state: operation.metadata?.state || (operation.done ? 'COMPLETED' : 'PROCESSING'),
489
510
  };
490
511
 
512
+ console.log(`[GeminiProvider] Operation status: ${result.state}, Progress: ${result.progress}%`);
513
+
491
514
  if (operation.done) {
492
515
  // Clean up from cache
493
516
  this._pendingOperations.delete(operationName);