# All files / src/providers/ollama Models.ts

73.68% Statements 14/19
50% Branches 7/14
100% Functions 5/5
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32

    10x

    3x
    3x
    3x
    6x

    3x

    3x
    3x

    3x
    3x
    3x
    3x
    3x

     import { OpenAIModels } from "../openai/Models.js";
    import { OllamaCapabilities } from "./Capabilities.js";

    export class OllamaModels extends OpenAIModels {
      protected override getProviderName(): string {
        return "ollama";
      }

      protected override formatDisplayName(modelId: string): string {
        const model = OllamaCapabilities.findModel(modelId);
        Iif (model?.name && model.name !== modelId) return model.name;
        const baseId = modelId.split(":")[0] || modelId;
        return baseId.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
      }

      protected override getContextWindow(modelId: string): number | null {
        return OllamaCapabilities.getContextWindow(modelId);
      }

      protected override getCapabilities(modelId: string): string[] {
        const model = OllamaCapabilities.findModel(modelId);
        Iif (model) return model.capabilities;

        // Fallback for custom pulled models
        const caps = ["streaming"];
        Iif (OllamaCapabilities.supportsTools(modelId)) caps.push("tools");
        Iif (OllamaCapabilities.supportsVision(modelId)) caps.push("vision");
        Iif (OllamaCapabilities.supportsEmbeddings(modelId)) caps.push("embeddings");
        return caps;
      }
    }