@@ -2,7 +2,10 @@ import { BaseTextAdapter } from '@tanstack/ai/adapters'
22
33import { createOllamaClient , generateId , getOllamaHostFromEnv } from '../utils'
44
5- import type { OLLAMA_TEXT_MODELS } from '../model-meta'
5+ import type {
6+ OLLAMA_TEXT_MODELS ,
7+ OllamaChatModelProviderOptionsByName ,
8+ } from '../model-meta'
69import type {
710 StructuredOutputOptions ,
811 StructuredOutputResult ,
@@ -22,6 +25,15 @@ export type OllamaTextModel =
2225 | ( typeof OLLAMA_TEXT_MODELS ) [ number ]
2326 | ( string & { } )
2427
28+ /**
29+ * Resolve provider options for a specific model.
30+ * If the model has explicit options in the map, use those; otherwise use base options.
31+ */
32+ type ResolveProviderOptions < TModel extends string > =
33+ TModel extends keyof OllamaChatModelProviderOptionsByName
34+ ? OllamaChatModelProviderOptionsByName [ TModel ]
35+ : ChatRequest
36+
2537/**
2638 * Ollama-specific provider options
2739 */
@@ -98,7 +110,7 @@ type OllamaMessageMetadataByModality = {
98110 */
99111export class OllamaTextAdapter < TModel extends string > extends BaseTextAdapter <
100112 TModel ,
101- OllamaTextProviderOptions ,
113+ ResolveProviderOptions < TModel > ,
102114 OllamaInputModalities ,
103115 OllamaMessageMetadataByModality
104116> {
@@ -131,7 +143,7 @@ export class OllamaTextAdapter<TModel extends string> extends BaseTextAdapter<
131143 * The outputSchema is already JSON Schema (converted in the ai layer).
132144 */
133145 async structuredOutput (
134- options : StructuredOutputOptions < OllamaTextProviderOptions > ,
146+ options : StructuredOutputOptions < ResolveProviderOptions < TModel > > ,
135147 ) : Promise < StructuredOutputResult < unknown > > {
136148 const { chatOptions, outputSchema } = options
137149
0 commit comments