ai-sdk-ollama
Version:
Vercel AI SDK Provider for Ollama using official ollama-js library
63 lines • 2.21 kB
TypeScript
/**
* generateText - Enhanced generateText with Ollama-specific reliability
*
* This wrapper provides response synthesis and enhanced tool calling reliability
* that addresses the core Ollama limitation: tools execute but no final text is generated.
*/
import { generateText as _generateText } from 'ai';
/**
* Enhanced options for Ollama-specific reliability features
*/
export interface EnhancedOptions {
/**
* Enable response synthesis when tools are called but no text is generated
* @default true
*/
enableSynthesis?: boolean;
/**
* Custom synthesis prompt template
*/
synthesisPrompt?: string;
/**
* Maximum attempts for synthesis
* @default 2
*/
maxSynthesisAttempts?: number;
/**
* Minimum response length to consider valid
* @default 10
*/
minResponseLength?: number;
/**
* EXPERIMENTAL: Enable tool calling with structured output (output)
*
* The official AI SDK doesn't support combining toolChoice: 'required' with output.
* When enabled, this uses a two-phase approach:
* 1. Execute tools first (without output)
* 2. Generate structured output with tool results injected as context
*
* This is NOT standard AI SDK behavior - only enable if you need both features together.
*
* @default false
*/
enableToolsWithStructuredOutput?: boolean;
}
/**
* Enhanced generateText options that extend the official AI SDK options
*/
export type GenerateTextOptions = Parameters<typeof _generateText>[0] & {
/**
* Enhanced options for Ollama-specific reliability features
*/
enhancedOptions?: EnhancedOptions;
};
/**
* Enhanced generateText function with Ollama-specific reliability improvements
*
* This function applies synthesis by default when tools execute but return empty responses.
* The enhancement preserves the original response prototype and all methods/getters.
*
* Type parameters are inferred from the options, preserving AI SDK's type inference.
*/
export declare function generateText(options: GenerateTextOptions): Promise<Awaited<ReturnType<typeof _generateText>>>;
//# sourceMappingURL=generate-text.d.ts.map