class

LLM::OllamaAdapter

Inherits LLM::Adapter < Reference < Object

Adapter for Ollama (LLM::Ollama).

Constructors

new(client : LLM::Ollama)
Source

Class methods

flatten_messages(messages : Messages) : Tuple(String | Nil, String)

/api/generate takes one prompt, so a conversation is flattened: system messages are joined into the system slot (nil when absent); user and assistant turns stay in order, assistant ones labelled so the agent loop still sees the actions it already took. Other roles are dropped.

Source

Instance methods

client
Source
request(prompt : String, format : String = "json") : String

Send a single prompt and get a response as a String.

Source
request_messages(messages : Messages, format : String = "json") : String

Send chat-style messages (system/user) and get a response as a String.

Source
request_with_context(system : String | Nil, user : String, format : String = "json") : String

A single system + user request.

Source