template

package
v0.0.0-...-92056dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatchingPreset = errors.New("шаблон: нет пресета, достаточно близкого к chat_template модели")

Functions

func Identifiers

func Identifiers(n parse.Node) ([]string, error)

func PresetStopSequences

func PresetStopSequences(p *MatchedPreset) []string

Types

type ImageData

type ImageData []byte

type MatchedPreset

type MatchedPreset struct {
	Name       string `json:"name"`
	IndexJinja string `json:"template"`
	Bytes      []byte `json:"-"`

	Parameters *struct {
		Stop []string `json:"stop"`
	}
}

func Named

func Named(modelChatTemplateJinja string) (*MatchedPreset, error)

func (*MatchedPreset) Reader

func (t *MatchedPreset) Reader() io.Reader

type Message

type Message struct {
	Role       string      `json:"role"`
	Content    string      `json:"content"`
	Thinking   string      `json:"thinking,omitempty"`
	Images     []ImageData `json:"images,omitempty"`
	ToolCalls  []ToolCall  `json:"tool_calls,omitempty"`
	ToolName   string      `json:"tool_name,omitempty"`
	ToolCallID string      `json:"tool_call_id,omitempty"`
}

type PropertyType

type PropertyType []string

func (PropertyType) MarshalJSON

func (pt PropertyType) MarshalJSON() ([]byte, error)

func (PropertyType) String

func (pt PropertyType) String() string

func (*PropertyType) UnmarshalJSON

func (pt *PropertyType) UnmarshalJSON(data []byte) error

type Template

type Template struct {
	*texttpl.Template
	// contains filtered or unexported fields
}

func Parse

func Parse(s string) (*Template, error)

func (*Template) Execute

func (t *Template) Execute(w io.Writer, v Values) error

func (*Template) Vars

func (t *Template) Vars() ([]string, error)

type Tool

type Tool struct {
	Type     string       `json:"type"`
	Items    any          `json:"items,omitempty"`
	Function ToolFunction `json:"function"`
}

type ToolCall

type ToolCall struct {
	ID       string           `json:"id,omitempty"`
	Function ToolCallFunction `json:"function"`
}

type ToolCallFunction

type ToolCallFunction struct {
	Index     int                       `json:"index"`
	Name      string                    `json:"name"`
	Arguments ToolCallFunctionArguments `json:"arguments"`
}

type ToolCallFunctionArguments

type ToolCallFunctionArguments struct {
	M map[string]any
}

func (ToolCallFunctionArguments) MarshalJSON

func (t ToolCallFunctionArguments) MarshalJSON() ([]byte, error)

func (ToolCallFunctionArguments) ToMap

func (t ToolCallFunctionArguments) ToMap() map[string]any

func (*ToolCallFunctionArguments) UnmarshalJSON

func (t *ToolCallFunctionArguments) UnmarshalJSON(data []byte) error

type ToolFunction

type ToolFunction struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description,omitempty"`
	Parameters  ToolFunctionParameters `json:"parameters"`
}

type ToolFunctionParameters

type ToolFunctionParameters struct {
	Type       string             `json:"type"`
	Defs       any                `json:"$defs,omitempty"`
	Items      any                `json:"items,omitempty"`
	Required   []string           `json:"required,omitempty"`
	Properties *ToolPropertiesMap `json:"properties"`
}

type ToolPropertiesMap

type ToolPropertiesMap struct {
	// contains filtered or unexported fields
}

func (ToolPropertiesMap) MarshalJSON

func (t ToolPropertiesMap) MarshalJSON() ([]byte, error)

func (*ToolPropertiesMap) ToMap

func (t *ToolPropertiesMap) ToMap() map[string]ToolProperty

func (*ToolPropertiesMap) UnmarshalJSON

func (t *ToolPropertiesMap) UnmarshalJSON(data []byte) error

type ToolProperty

type ToolProperty struct {
	AnyOf       []ToolProperty     `json:"anyOf,omitempty"`
	Type        PropertyType       `json:"type,omitempty"`
	Items       any                `json:"items,omitempty"`
	Description string             `json:"description,omitempty"`
	Enum        []any              `json:"enum,omitempty"`
	Properties  *ToolPropertiesMap `json:"properties,omitempty"`
}

func (ToolProperty) ToTypeScriptType

func (tp ToolProperty) ToTypeScriptType() string

type Tools

type Tools []Tool

type Values

type Values struct {
	Messages []Message
	Tools
	Prompt string
	Suffix string
	Think  bool

	ThinkLevel string
	IsThinkSet bool
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL