Skip to main content

Crate agentkit_provider_ollama

Crate agentkit_provider_ollama 

Source
Expand description

Ollama model adapter for the agentkit agent loop.

This crate provides OllamaAdapter and OllamaConfig for connecting the agent loop to a local Ollama instance via its OpenAI-compatible chat completions endpoint. It is built on the generic agentkit_adapter_completions crate.

No API key is required — Ollama runs locally and does not authenticate requests by default.

§Quick start

use agentkit_loop::{Agent, SessionConfig};
use agentkit_provider_ollama::{OllamaAdapter, OllamaConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Ollama must be running locally (e.g. `ollama serve`).
    let config = OllamaConfig::new("llama3.1:8b");
    let adapter = OllamaAdapter::new(config)?;

    let agent = Agent::builder()
        .model(adapter)
        .build()?;

    let mut driver = agent
        .start(SessionConfig::new("demo"))
        .await?;
    Ok(())
}

Structs§

OllamaAdapter
Model adapter that connects the agentkit agent loop to a local Ollama instance.
OllamaConfig
Configuration for connecting to a local Ollama instance.
OllamaProvider
The Ollama provider, implementing CompletionsProvider.
OllamaRequestConfig
Request parameters serialized into the Ollama request body.

Enums§

OllamaError
Errors produced by the Ollama adapter.

Type Aliases§

OllamaSession
An active session with a local Ollama instance.
OllamaTurn
A completed turn from a local Ollama instance.