@contentgrowth/llm-service 0.6.91 → 0.6.92

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.6.91",
3
+ "version": "0.6.92",
4
4
  "description": "Unified LLM Service for Content Growth",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -135,43 +135,29 @@ export class GeminiProvider extends BaseLLMProvider {
135
135
  tools: tools ? [{ functionDeclarations: tools.map(t => t.function) }] : undefined,
136
136
  });
137
137
 
138
- // New SDK returns result directly, not result.response
139
- // Debug log to understand structure
140
- console.log('[GeminiProvider] Result structure:', JSON.stringify(Object.keys(result), null, 2));
141
-
142
- // Handle both old (result.response) and new (direct result) structures
143
- const response = result.response || result;
144
-
145
- // Extract function calls - try multiple possible locations
138
+ // New SDK returns candidates directly on result
139
+ // Extract function calls from parts
146
140
  let toolCalls = null;
147
- if (typeof response.functionCalls === 'function') {
148
- toolCalls = response.functionCalls();
149
- } else if (response.functionCalls) {
150
- toolCalls = response.functionCalls;
151
- } else if (response.candidates?.[0]?.content?.parts) {
152
- // Check parts for function calls
153
- const functionCallParts = response.candidates[0].content.parts.filter(p => p.functionCall);
141
+ if (result.candidates?.[0]?.content?.parts) {
142
+ const functionCallParts = result.candidates[0].content.parts.filter(p => p.functionCall);
154
143
  if (functionCallParts.length > 0) {
155
144
  toolCalls = functionCallParts.map(p => p.functionCall);
156
145
  }
157
146
  }
158
147
 
159
- // Extract text content - try multiple possible locations
148
+ // Extract text content from parts
160
149
  let textContent = '';
161
150
  try {
162
- if (typeof response.text === 'function') {
163
- textContent = response.text();
164
- } else if (typeof response.text === 'string') {
165
- textContent = response.text;
166
- } else if (response.candidates?.[0]?.content?.parts) {
151
+ if (result.candidates?.[0]?.content?.parts) {
167
152
  // Concatenate text from parts
168
- textContent = response.candidates[0].content.parts
153
+ textContent = result.candidates[0].content.parts
169
154
  .filter(p => p.text)
170
155
  .map(p => p.text)
171
156
  .join('');
157
+ } else if (result.text) {
158
+ textContent = typeof result.text === 'function' ? result.text() : result.text;
172
159
  }
173
160
  } catch (e) {
174
- // response.text() throws if there is no text content (e.g. only tool calls)
175
161
  // This is expected behavior for tool-only responses
176
162
  }
177
163
 
@@ -372,12 +358,13 @@ export class GeminiProvider extends BaseLLMProvider {
372
358
  generationConfig
373
359
  });
374
360
 
375
- const response = result.response;
376
- const imagePart = response.candidates?.[0]?.content?.parts?.find(
361
+ // New SDK returns candidates directly on result, not result.response
362
+ const imagePart = result.candidates?.[0]?.content?.parts?.find(
377
363
  part => part.inlineData && part.inlineData.mimeType?.startsWith('image/')
378
364
  );
379
365
 
380
366
  if (!imagePart || !imagePart.inlineData) {
367
+ console.error('[GeminiProvider] No image in response. Result:', JSON.stringify(result, null, 2));
381
368
  throw new Error('No image data in response');
382
369
  }
383
370