Skip to content

Commit 9b38f80

Browse files
committed
better type checks on ollama context length
1 parent 0f042b9 commit 9b38f80

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/api/providers/fetchers/ollama.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ type OllamaModelInfoResponse = z.infer<typeof OllamaModelInfoResponseSchema>
3939

4040
export const parseOllamaModel = (rawModel: OllamaModelInfoResponse): ModelInfo => {
4141
const contextKey = Object.keys(rawModel.model_info).find((k) => k.includes("context_length"))
42-
const contextWindow = contextKey ? rawModel.model_info[contextKey] : undefined
42+
const contextWindow =
43+
contextKey && typeof rawModel.model_info[contextKey] === "number" ? rawModel.model_info[contextKey] : undefined
4344

4445
const modelInfo: ModelInfo = Object.assign({}, ollamaDefaultModelInfo, {
4546
description: `Family: ${rawModel.details.family}, Context: ${contextWindow}, Size: ${rawModel.details.parameter_size}`,

0 commit comments

Comments
 (0)