LLM#

class scikitplot.corpus.LLM(provider, model, *, client, max_tokens, options, cache, clock)[source]#

A language model behind one call shape; made by make_llm.

Attributes:
providerstr

"openai", "anthropic", "gemini" or "callable".

modelstr

Model name.

max_tokensint or None

Output-token limit sent with every request, if any.

Parameters:
  • provider (str)

  • model (str)

  • client (Any)

  • max_tokens (int | None)

  • options (Mapping[str, Any])

  • cache (MutableMapping | None)

  • clock (Callable[[], float])

See also

make_llm

The constructor to use.

cache_key(prompt, system=None)[source]#

Return the cache key of one request (hex SHA-256).

Parameters:
promptstr

User prompt.

systemstr or None, default=None

System instruction.

Returns:
str
Parameters:
  • prompt (str)

  • system (str | None)

Return type:

str

Notes

The key covers the provider, model, max_tokens, every option (unredacted, so two gateways’ headers never share an entry) and the client’s base_url where the client exposes one (OpenAI and Anthropic clients do), so two endpoints serving the same model name never share an entry. Only the hash is stored.

complete(prompt, *, system=None)[source]#

Send one prompt and return the response.

Parameters:
promptstr

User prompt.

systemstr or None, default=None

System instruction.

Returns:
Completion
Raises:
TypeError

If prompt or system is not a string, or a normally ended response holds no text.

IncompleteCompletionError

If the model stopped for any reason but a normal end, whether or not it returned text (the completion keeps its token counts).

CacheError

If the cache mapping fails.

Exception

Whatever the provider’s client raises (authentication, rate limit, network); it is not caught here.

Parameters:
  • prompt (str)

  • system (str | None)

Return type:

Completion

identity()[source]#

Return what identifies this judge model in a report.

Returns:
dict

provider, model, max_tokens (only when set, so the identity holds no None and survives every report format) and options, with the values of REDACTED_OPTIONS (extra_headers, extra_query) replaced by "<redacted>". The client, and so its API key, is never included.

Return type:

dict[str, Any]

property options: dict[str, Any]#

A copy of the extra request options.