MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / parseOllamaModel

Function parseOllamaModel

src/api/providers/fetchers/ollama.ts:40–60  ·  view source on GitHub ↗
(rawModel: OllamaModelInfoResponse)

Source from the content-addressed store, hash-verified

38type OllamaModelInfoResponse = z.infer<typeof OllamaModelInfoResponseSchema>
39
40export const parseOllamaModel = (rawModel: OllamaModelInfoResponse): ModelInfo | null => {
41 const contextKey = Object.keys(rawModel.model_info).find((k) => k.includes("context_length"))
42 const contextWindow =
43 contextKey && typeof rawModel.model_info[contextKey] === "number" ? rawModel.model_info[contextKey] : undefined
44
45 // Filter out models that don't support tools. Models without tool capability won't work.
46 const supportsTools = rawModel.capabilities?.includes("tools") ?? false
47 if (!supportsTools) {
48 return null
49 }
50
51 const modelInfo: ModelInfo = Object.assign({}, ollamaDefaultModelInfo, {
52 description: `Family: ${rawModel.details.family}, Context: ${contextWindow}, Size: ${rawModel.details.parameter_size}`,
53 contextWindow: contextWindow || ollamaDefaultModelInfo.contextWindow,
54 supportsPromptCache: true,
55 supportsImages: rawModel.capabilities?.includes("vision"),
56 maxTokens: contextWindow || ollamaDefaultModelInfo.contextWindow,
57 })
58
59 return modelInfo
60}
61
62export async function getOllamaModels(
63 baseUrl = "http://localhost:11434",

Callers 2

ollama.test.tsFile · 0.90
getOllamaModelsFunction · 0.85

Calls 1

keysMethod · 0.65

Tested by

no test coverage detected