module LLM::Adapter

Overview

A normalized adapter interface for LLM clients.

Implementations should return a String response (JSON text after any provider-specific cleanup).

Direct including types

Defined in:

llm/adapter.cr

Instance Method Summary

Instance Method Detail

abstract def request(prompt : String, format : String = "json") : String #

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


[View source]
abstract def request_messages(messages : Messages, format : String = "json") : String #

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


[View source]
def request_with_context(system : String | Nil, user : String, format : String = "json", cache_key : String | Nil = nil) : 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.


[View source]
def supports_context? : Bool #

Whether this adapter supports server-side KV context reuse across calls.


[View source]