Skip to content

OllamaBackendAdapter

Defined in: backend/src/providers/ollama.ts:69

Backend adapter interface.

Backend adapters handle actual API calls to AI providers. They transform universal IR into provider-specific API requests and normalize responses back to IR.

new OllamaBackendAdapter(config): OllamaBackendAdapter

Defined in: backend/src/providers/ollama.ts:74

BackendAdapterConfig

OllamaBackendAdapter

readonly metadata: AdapterMetadata

Defined in: backend/src/providers/ollama.ts:70

Adapter metadata for identification and capabilities.

BackendAdapter.metadata

estimateCost(_request): Promise<number | null>

Defined in: backend/src/providers/ollama.ts:270

Optional: Estimate cost for a request.

IRChatRequest

IR request to estimate cost for

Promise<number | null>

Estimated cost in USD (or null if unavailable)

BackendAdapter.estimateCost


execute(request, signal?): Promise<IRChatResponse>

Defined in: backend/src/providers/ollama.ts:100

Execute non-streaming chat completion request.

IRChatRequest

Universal IR request

AbortSignal

Optional AbortSignal for cancellation

Promise<IRChatResponse>

Universal IR response

If API key is invalid

If request is invalid for this provider

If provider API returns error

If network request fails

If response parsing fails

BackendAdapter.execute


executeStream(request, signal?): IRChatStream

Defined in: backend/src/providers/ollama.ts:136

Execute streaming chat completion request.

IRChatRequest

Universal IR request

AbortSignal

Optional AbortSignal for cancellation

IRChatStream

Universal IR stream of chunks

If API key is invalid

If request is invalid for this provider

If provider API returns error

If network request fails

If stream parsing or processing fails

BackendAdapter.executeStream


fromIR(request): OllamaRequest

Defined in: backend/src/providers/ollama.ts:279

Convert IR request to Ollama format.

Public method for testing and debugging - see what will be sent to Ollama.

IRChatRequest

OllamaRequest

BackendAdapter.fromIR


healthCheck(): Promise<boolean>

Defined in: backend/src/providers/ollama.ts:258

Optional: Health check to verify backend is available.

Promise<boolean>

true if backend is healthy and available

BackendAdapter.healthCheck


listModels(options?): Promise<ListModelsResult>

Defined in: backend/src/providers/ollama.ts:355

List locally available models from Ollama.

Priority order:

  1. Static config override (this.config.models)
  2. API fetch (http://localhost:11434/api/tags)
  3. Empty array (Ollama not running or no models installed)

Note: Unlike cloud providers, Ollama models are local and dynamic. No caching or fallback list - always fetches fresh from local server.

ListModelsOptions

Optional filter settings

Promise<ListModelsResult>

Promise resolving to list of locally installed models

BackendAdapter.listModels


toIR(response, originalRequest, latencyMs): IRChatResponse

Defined in: backend/src/providers/ollama.ts:313

Convert Ollama response to IR format.

Public method for testing and debugging - parse Ollama responses manually.

OllamaResponse

IRChatRequest

number

IRChatResponse

BackendAdapter.toIR