class
LLM::OllamaAdapter
- LLM::OllamaAdapter
- Reference
- Object
Overview
Adapter for Ollama (LLM::Ollama) with optional context reuse.
Included Modules
Defined in:
llm/adapter.crConstructors
Class Method Summary
-
.flatten_messages(messages : Messages) : Tuple(String | Nil, String)
Promoted to a class-level pure function so the flattening rule (system messages joined with \n\n, non-system/non-user roles dropped, nil system when no system messages were present) is unit-testable without standing up a real Ollama client.
Instance Method Summary
- #client : LLM::Ollama
-
#request(prompt : String, format : String = "json") : String
Send a single prompt and get a response as a String.
-
#request_messages(messages : Messages, format : String = "json") : String
Send chat-style messages (system/user) and get a response as a String.
-
#request_with_context(system : String | Nil, user : String, format : String = "json", cache_key : String | Nil = nil) : String
Context-aware request.
-
#supports_context? : Bool
Whether this adapter supports server-side KV context reuse across calls.
Instance methods inherited from module LLM::Adapter
close : Nil
close,
request(prompt : String, format : String = "json") : String
request,
request_messages(messages : Messages, format : String = "json") : String
request_messages,
request_messages_with_tools(messages : Messages, _tools : String) : String
request_messages_with_tools,
request_with_context(system : String | Nil, user : String, format : String = "json", cache_key : String | Nil = nil) : String
request_with_context,
supports_context? : Bool
supports_context?,
supports_native_tool_calling? : Bool
supports_native_tool_calling?
Constructor Detail
Class Method Detail
Promoted to a class-level pure function so the flattening rule (system messages joined with \n\n, non-system/non-user roles dropped, nil system when no system messages were present) is unit-testable without standing up a real Ollama client.
Instance Method Detail
Send a single prompt and get a response as a String.
Send chat-style messages (system/user) and get a response as a String.
Context-aware request. Adapters that support provider-side context can reuse it using a cache_key. Default implementation falls back to request_messages without context reuse.
Whether this adapter supports server-side KV context reuse across calls.