Tinkex.Types.ModelInput (Tinkex v0.1.17)
View SourceModel input containing chunks of encoded text and/or images.
Mirrors Python tinker.types.ModelInput.
Summary
Functions
Create ModelInput from a list of token IDs.
Create ModelInput from raw text.
Create ModelInput from raw text, raising on failure.
Get the total length (token count) of the ModelInput.
Extract all token IDs from the ModelInput.
Types
@type chunk() :: Tinkex.Types.EncodedTextChunk.t() | Tinkex.Types.ImageChunk.t() | Tinkex.Types.ImageAssetPointerChunk.t()
@type t() :: %Tinkex.Types.ModelInput{chunks: [chunk()]}
Functions
Create ModelInput from a list of token IDs.
@spec from_text( String.t(), keyword() ) :: {:ok, t()} | {:error, Tinkex.Error.t()}
Create ModelInput from raw text.
Tokenizes the provided text via Tinkex.Tokenizer.encode/3 and returns a
tuple using the same {:ok, ...} | {:error, ...} contract. Chat templates
are not applied; callers must supply fully formatted prompts.
Options
:model_name(required) - Model name used to resolve the tokenizer.:training_client- Forwarded to tokenizer resolution.- Any other options supported by
Tinkex.Tokenizer.encode/3.
Create ModelInput from raw text, raising on failure.
See from_text/2 for options and behavior.
@spec length(t()) :: non_neg_integer()
Get the total length (token count) of the ModelInput.
For image chunks, expected_tokens must be set; otherwise length/1 will
raise to mirror Python SDK guardrails.
Extract all token IDs from the ModelInput.
Only works with EncodedTextChunk chunks. Raises for image chunks.