Documentation
¶
Overview ¶
Package chat renders the chat templates models ship, the Jinja Hugging Face tokenizer configs and GGUF files carry, into the text a conversation is sent to the model as: the template language with the filters, tests, methods and globals these templates use
Index ¶
Constants ¶
This section is empty.
Variables ¶
var HuggingFace = Options{TrimBlocks: true, LStripBlocks: true}
What transformers renders chat templates with: blocks trimmed and stripped
Functions ¶
Types ¶
type Conversation ¶
type Conversation struct {
// The messages, each with its role, content, and for an assistant's its tool calls, for a tool's result the call it answers
Messages []map[string]any
// Definitions of the tools the model may call, as JSON schemas of functions
Tools []map[string]any
// The template ends with what opens the assistant's reply
AddGenerationPrompt bool
// Special tokens by name, such as bos_token and eos_token
Tokens map[string]string
// Further variables a template reads, such as enable_thinking
Extra map[string]any
// The time strftime_now tells, the present when zero
Now time.Time
}
What a conversation is rendered with, as transformers' apply_chat_template hands it to a template
type Dict ¶
type Dict struct {
// contains filtered or unexported fields
}
A mapping in the order its keys were put in, as Python's dicts are
type List ¶
A list, shared by every name it is bound to so appending through one is seen through all, as Python's lists are
type Namespace ¶
type Namespace struct{ *Dict }
A namespace() object, whose attributes a set statement may change from inside a loop
type Options ¶
type Options struct {
// The first newline after a block or comment tag is removed
TrimBlocks bool
// Spaces and tabs from the start of a line to a block or comment tag are removed
LStripBlocks bool
// A newline ending the template is kept
KeepTrailingNewline bool
}
How a template treats the whitespace around its tags, as Jinja's environment options say
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
A parsed template
func (*Template) Conversation ¶
func (t *Template) Conversation(c Conversation) (string, error)
The text of a conversation as the template renders it
type TemplateError ¶
type TemplateError struct{ Message string }
An error a template raised itself through raise_exception, such as a role it does not take
func (*TemplateError) Error ¶
func (e *TemplateError) Error() string