oc_chat
Loading...
Searching...
No Matches
providers.ollama.provider Namespace Reference

Classes

class  OllamaProvider

Detailed Description

OllamaProvider — :class:`ProviderPlugin` implementation for Ollama.

Purpose
-------
Connects OC Chat to a local (or LAN) Ollama daemon via the native
``/api/chat`` endpoint. No API key required. Base URL defaults to
``http://localhost:11434`` and is overridable via ``OLLAMA_BASE_URL``.

Responsibilities
----------------
- :class:`OllamaProvider` — implement every abstract method on
  :class:`ProviderPlugin` for the Ollama provider.
- :meth:`build_client` — return an :class:`OllamaClient`.
- :meth:`models` / :meth:`tier` — surface the static registries.
- :meth:`build_extra_body` — always ``None`` (no thinking payload).
- :meth:`transform_outgoing_messages` — pass-through (no sentinel).
- :meth:`parse_usage` — read ``prompt_eval_count`` / ``eval_count``
  from the Ollama-shaped usage dict yielded by :class:`OllamaClient`.
- :meth:`fetch_live_models` — delegate to ``client.list_models()``.
- :meth:`default_caps` — permissive local defaults for any live model
  not in the curated registry.

Diagnostics
-----------
Domain: OC_CHAT.CLIENT
Levels:
    L2 — lifecycle events
    L3 — semantic details
    L4 — deep tracing

Contracts
---------
- ``api_key_env_var = ""`` — Ollama does not use API keys.
- ``transform_outgoing_messages`` is a true pass-through (no sentinel
  embedding — Ollama has no disk-based prefix cache that benefits from
  it).
- ``parse_usage`` handles both the Ollama-native field names
  (``prompt_eval_count`` / ``eval_count``) and the normalised names
  (``prompt_tokens`` / ``completion_tokens``) so it works regardless of
  which shape the caller passes.

Dependencies
------------
- oc_diagnostics (_dbg)
- providers.ollama.client (OllamaClient)
- providers.ollama.models (MODELS, TIER_MAP)
- option_c_agent_contracts (ProviderPlugin base class and the ModelCaps, ModelInfo, PerformanceStats, UsageStats and BaseClient types)