@contentgrowth/llm-service 1.3.1 → 1.3.3

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 CHANGED
@@ -342,6 +342,15 @@ var BaseLLMProvider = class {
342
342
  async imageGeneration(prompt, systemPrompt, options = {}) {
343
343
  throw new Error("Image generation not supported by this provider");
344
344
  }
345
+ /**
346
+ * Text-to-Speech synthesis
347
+ * @param {string} text - Text to synthesize
348
+ * @param {Object} options - TTS options (voice, model, etc.)
349
+ * @returns {Promise<Buffer>} Audio data as Buffer
350
+ */
351
+ async textToSpeech(text, options = {}) {
352
+ throw new Error("Text-to-speech not supported by this provider");
353
+ }
345
354
  /**
346
355
  * Start video generation (returns operation name for polling)
347
356
  * @param {string} prompt
@@ -1003,13 +1012,21 @@ ${msg.content}`;
1003
1012
  const tool = toolImplementations[toolName];
1004
1013
  const tool_call_id = `gemini-tool-call-${index}`;
1005
1014
  toolCall.id = tool_call_id;
1006
- console.log(`[Tool Call] > ${toolName}:`, JSON.stringify(toolCall.function.args));
1015
+ let toolArgs = toolCall.function.args;
1016
+ if (toolArgs === void 0 && toolCall.function.arguments) {
1017
+ try {
1018
+ toolArgs = typeof toolCall.function.arguments === "string" ? JSON.parse(toolCall.function.arguments) : toolCall.function.arguments;
1019
+ } catch (e) {
1020
+ toolArgs = {};
1021
+ }
1022
+ }
1023
+ console.log(`[Tool Call] > ${toolName}:`, JSON.stringify(toolArgs));
1007
1024
  if (!tool) {
1008
1025
  console.error(`[Tool Error] Tool '${toolName}' not found`);
1009
1026
  return { tool_call_id, output: JSON.stringify({ error: `Tool '${toolName}' not found.` }) };
1010
1027
  }
1011
1028
  try {
1012
- const output = await tool(toolCall.function.args, { env, tenantId });
1029
+ const output = await tool(toolArgs, { env, tenantId });
1013
1030
  const preview = typeof output === "string" ? output.length > 200 ? output.substring(0, 200) + "..." : output : JSON.stringify(output).substring(0, 200) + "...";
1014
1031
  console.log(`[Tool Result] < ${toolName}: ${preview}`);
1015
1032
  return { tool_call_id, output };
@@ -1738,6 +1755,17 @@ var LLMService = class {
1738
1755
  const provider = await this._getProvider(tenantId);
1739
1756
  return provider.imageGeneration(prompt, systemPrompt, options);
1740
1757
  }
1758
+ /**
1759
+ * Text-to-Speech synthesis
1760
+ * @param {string} text - Text to synthesize
1761
+ * @param {string} tenantId - Tenant identifier
1762
+ * @param {Object} options - TTS options (voice, model, etc.)
1763
+ * @returns {Promise<Buffer>} Audio data as Buffer
1764
+ */
1765
+ async textToSpeech(text, tenantId, options = {}) {
1766
+ const provider = await this._getProvider(tenantId);
1767
+ return provider.textToSpeech(text, options);
1768
+ }
1741
1769
  /**
1742
1770
  * Start a Deep Research task
1743
1771
  * @param {string} prompt - Research prompt/query