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.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new OllamaBackendAdapter(
config):OllamaBackendAdapter
Defined in: backend/src/providers/ollama.ts:74
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”OllamaBackendAdapter
Properties
Section titled “Properties”metadata
Section titled “metadata”
readonlymetadata:AdapterMetadata
Defined in: backend/src/providers/ollama.ts:70
Adapter metadata for identification and capabilities.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”estimateCost()
Section titled “estimateCost()”estimateCost(
_request):Promise<number|null>
Defined in: backend/src/providers/ollama.ts:270
Optional: Estimate cost for a request.
Parameters
Section titled “Parameters”_request
Section titled “_request”IR request to estimate cost for
Returns
Section titled “Returns”Promise<number | null>
Estimated cost in USD (or null if unavailable)
Implementation of
Section titled “Implementation of”execute()
Section titled “execute()”execute(
request,signal?):Promise<IRChatResponse>
Defined in: backend/src/providers/ollama.ts:100
Execute non-streaming chat completion request.
Parameters
Section titled “Parameters”request
Section titled “request”Universal IR request
signal?
Section titled “signal?”AbortSignal
Optional AbortSignal for cancellation
Returns
Section titled “Returns”Promise<IRChatResponse>
Universal IR response
Throws
Section titled “Throws”If API key is invalid
Throws
Section titled “Throws”If request is invalid for this provider
Throws
Section titled “Throws”If provider API returns error
Throws
Section titled “Throws”If network request fails
Throws
Section titled “Throws”If response parsing fails
Implementation of
Section titled “Implementation of”executeStream()
Section titled “executeStream()”executeStream(
request,signal?):IRChatStream
Defined in: backend/src/providers/ollama.ts:136
Execute streaming chat completion request.
Parameters
Section titled “Parameters”request
Section titled “request”Universal IR request
signal?
Section titled “signal?”AbortSignal
Optional AbortSignal for cancellation
Returns
Section titled “Returns”Universal IR stream of chunks
Throws
Section titled “Throws”If API key is invalid
Throws
Section titled “Throws”If request is invalid for this provider
Throws
Section titled “Throws”If provider API returns error
Throws
Section titled “Throws”If network request fails
Throws
Section titled “Throws”If stream parsing or processing fails
Implementation of
Section titled “Implementation of”fromIR()
Section titled “fromIR()”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.
Parameters
Section titled “Parameters”request
Section titled “request”Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”healthCheck()
Section titled “healthCheck()”healthCheck():
Promise<boolean>
Defined in: backend/src/providers/ollama.ts:258
Optional: Health check to verify backend is available.
Returns
Section titled “Returns”Promise<boolean>
true if backend is healthy and available
Implementation of
Section titled “Implementation of”listModels()
Section titled “listModels()”listModels(
options?):Promise<ListModelsResult>
Defined in: backend/src/providers/ollama.ts:355
List locally available models from Ollama.
Priority order:
- Static config override (this.config.models)
- API fetch (http://localhost:11434/api/tags)
- 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.
Parameters
Section titled “Parameters”options?
Section titled “options?”Optional filter settings
Returns
Section titled “Returns”Promise<ListModelsResult>
Promise resolving to list of locally installed models
Implementation of
Section titled “Implementation of”toIR()
Section titled “toIR()”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.
Parameters
Section titled “Parameters”response
Section titled “response”originalRequest
Section titled “originalRequest”latencyMs
Section titled “latencyMs”number