@heripo/document-processor 0.1.32 → 0.1.33

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.js CHANGED
@@ -86,6 +86,8 @@ function detectProvider(model) {
86
86
  if (providerId.includes("google")) return "google";
87
87
  if (providerId.includes("anthropic")) return "anthropic";
88
88
  if (providerId.includes("together")) return "togetherai";
89
+ if (providerId.includes("ollama")) return "ollama";
90
+ if (providerId.includes("lmstudio")) return "lmstudio";
89
91
  return "unknown";
90
92
  }
91
93
  var LLMCaller = class {
@@ -173,14 +175,18 @@ var LLMCaller = class {
173
175
  *
174
176
  * Strategy per provider:
175
177
  * - OpenAI / Anthropic / Google Gemini: `Output.object()` with schema retry
176
- * - Together AI / unknown: forced tool call pattern
178
+ * - Together AI / Ollama / unknown: forced tool call pattern
179
+ *
180
+ * Ollama uses tool-call because MLX backends ignore the `format` grammar
181
+ * that `Output.object()` relies on, and gguf's grammar is unstable once
182
+ * thinking is disabled. Applies to both text and vision paths.
177
183
  *
178
184
  * Retries up to MAX_STRUCTURED_OUTPUT_RETRIES times on NoObjectGeneratedError
179
185
  * (schema mismatch), re-throwing the last error if all attempts fail.
180
186
  */
181
187
  static async generateStructuredOutput(model, schema, promptParams) {
182
188
  const providerType = detectProvider(model);
183
- if (providerType === "togetherai" || providerType === "unknown") {
189
+ if (providerType === "togetherai" || providerType === "ollama" || providerType === "unknown") {
184
190
  return this.generateViaToolCall(model, schema, promptParams);
185
191
  }
186
192
  let lastError;