ContextWindowResolver

org.llm4s.llmconnect.config.ContextWindowResolver
See theContextWindowResolver companion object

Resolves context window and output-reserve token counts for a given model using the model registry.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def resolve(lookupProviders: Seq[String], modelName: String, defaultContextWindow: Int, defaultReserve: Int, fallbackResolver: String => (Int, Int), logPrefix: String): (Int, Int)

Looks up context-window size and output-token reserve for a model, falling back to provided defaults.

Looks up context-window size and output-token reserve for a model, falling back to provided defaults.

Value parameters

defaultContextWindow

fallback maximum context-window size in tokens

defaultReserve

fallback maximum output-token reserve

fallbackResolver

function returning (contextWindow, reserve) when the registry has no entry

logPrefix

optional string prepended to log messages for disambiguation

lookupProviders

ordered list of provider names to try when querying the registry

modelName

name of the model whose limits should be resolved

Attributes

Returns

pair of (contextWindow, reserveTokens) for the resolved model

def strictContextWindow(provider: String, modelName: String): Option[Int]

The context window (input limit) the registry holds for modelName among provider's own entries, and nothing else.

The context window (input limit) the registry holds for modelName among provider's own entries, and nothing else.

resolve is deliberately forgiving: the registry's own lookup falls back to a substring match over every provider's entries, and to the bare model name, so a name it does not know under provider can still pick up another provider's entry. That suits a dedicated client, whose model names are its vendor's own. It does not suit an endpoint that serves arbitrary names, where another provider's window is a wrong answer and no answer is better. This method is the strict form: an entry counts only when its provider is provider and its id is provider/modelName or modelName (case-insensitively); a partial name, another provider's entry for the same name, and an entry with no input limit all give None.

Value parameters

modelName

the model id as the provider's API names it, without the provider/ prefix

provider

the registry provider, e.g. groq or together_ai

Attributes

Returns

the entry's input limit when it is a positive number, otherwise None