LlmCall.Capabilities.Input (llm_call v0.4.0)

Copy Markdown View Source

Where a codec can get the bytes for an image or a file part.

A single boolean cannot answer "can I send this part", because the canonical source has three kinds and the protocols disagree about them: OpenAI Responses takes a provider file_id, Anthropic takes one for a document but not for an image, Gemini takes neither, and a URL is not the same thing as a file the provider already has. Declaring true for all of them made the declaration wrong in one direction or the other, and false refused parts the codec could encode.

So a capability names the kinds it accepts, one boolean each:

KindCanonical sourceWho resolves it
:inline{:base64, data}the bytes travel in the request
:url{:url, url}, or a bare stringthe provider fetches it over HTTP
:uri{:uri, uri}the provider resolves a URI in its own namespace (s3://, gs://)
:file{:file_id, id}the provider resolves an opaque id it issued

:url and :uri are separate because they answer different questions. An HTTP URL is something any client could fetch; an s3:// or gs:// URI is only reachable by the provider, in its own account. A codec that accepts one and not the other can now say so, and one that accepts neither stops claiming it accepts both.

The default accepts nothing, which is what false meant before. accepts?/2 answers the question for a concrete part, and kinds/1 lists what a declaration allows.

%LlmCall.Capabilities{
  image_input: %LlmCall.Capabilities.Input{inline: true, url: true}
}

Summary

Types

One way of naming the bytes of a part.

t()

Functions

Whether a canonical source is one this declaration accepts.

The kind a canonical source belongs to.

The kinds a declaration accepts, in canonical order.

Types

kind()

@type kind() :: :inline | :url | :uri | :file

One way of naming the bytes of a part.

t()

@type t() :: %LlmCall.Capabilities.Input{
  file: boolean(),
  inline: boolean(),
  uri: boolean(),
  url: boolean()
}

Functions

accepts?(input, source)

@spec accepts?(t(), LlmCall.Content.source()) :: boolean()

Whether a canonical source is one this declaration accepts.

kind(url)

@spec kind(LlmCall.Content.source()) :: kind()

The kind a canonical source belongs to.

A bare string is a URL: it is the shorthand the HTTP codecs already read as one.

kinds(input)

@spec kinds(t()) :: [kind()]

The kinds a declaration accepts, in canonical order.