Skip to content

Commit d1e32a2

Browse files
committed
chore: update types
1 parent fb43bae commit d1e32a2

File tree

3 files changed

+341
-68
lines changed

3 files changed

+341
-68
lines changed

packages/typescript/ai-ollama/src/adapters/text.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { BaseTextAdapter } from '@tanstack/ai/adapters'
22

33
import { 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'
69
import 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
*/
99111
export 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

packages/typescript/ai-ollama/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ export type {
3636
OllamaMessageMetadataByModality,
3737
} from './message-types'
3838

39-
export type { OllamaModelInputModalitiesByName } from './model-meta'
39+
export type {
40+
OllamaChatModelProviderOptionsByName,
41+
OllamaModelInputModalitiesByName,
42+
} from './model-meta'

0 commit comments

Comments
 (0)