types

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content added in v0.7.0

type Content struct {
	Raw        string
	Structured []ContentBlock
}

Content holds a message's content — either plain text or a list of multimodal blocks.

func (Content) MarshalJSON added in v0.7.0

func (c Content) MarshalJSON() ([]byte, error)

MarshalJSON serialises back to the original format.

func (Content) PlainText added in v0.7.0

func (c Content) PlainText() string

PlainText returns the plain text content, concatenating text blocks for multimodal messages.

func (*Content) UnmarshalJSON added in v0.7.0

func (c *Content) UnmarshalJSON(data []byte) error

UnmarshalJSON handles both the plain-string and block-list formats.

type ContentBlock added in v0.7.0

type ContentBlock struct {
	Type     string     `json:"type"`
	Text     string     `json:"text,omitempty"`
	ImageURL ImageBlock `json:"image_url,omitempty"`
}

ContentBlock represents a single part of a multimodal message.

type Conversation

type Conversation struct {
	Role      string        `json:"role"`
	Content   Content       `json:"content"`
	ToolCalls []interface{} `json:"tool_calls,omitempty"`
}

Conversation represents a single message in a conversation.

type ImageBlock added in v0.7.0

type ImageBlock struct {
	URL string `json:"url,omitempty"`
}

ImageBlock represents the image_url field in a multimodal content block.

type Offset

type Offset [2]uint

Offset represents a character offset range with [start, end] indices.

type RenderChatRequest

type RenderChatRequest struct {
	// The Python wrapper will handle converting this to a batched list if needed.
	Key                       string                 `json:"key"`
	Conversation              []Conversation         `json:"conversation"`
	Tools                     []interface{}          `json:"tools,omitempty"`
	Documents                 []interface{}          `json:"documents,omitempty"`
	ChatTemplate              string                 `json:"chat_template,omitempty"`
	ReturnAssistantTokensMask bool                   `json:"return_assistant_tokens_mask,omitempty"`
	ContinueFinalMessage      bool                   `json:"continue_final_message,omitempty"`
	AddGenerationPrompt       bool                   `json:"add_generation_prompt,omitempty"`
	TruncatePromptTokens      *int                   `json:"truncate_prompt_tokens,omitempty"`
	ChatTemplateKWArgs        map[string]interface{} `json:"chat_template_kwargs,omitempty"`
}

RenderChatRequest represents the request to render a chat template.

func (*RenderChatRequest) DeepCopy

func (req *RenderChatRequest) DeepCopy() (*RenderChatRequest, error)

DeepCopy creates a deep copy of the RenderChatRequest.

type RenderRequest

type RenderRequest struct {
	Key              string `json:"key"`
	Text             string `json:"text"`
	AddSpecialTokens bool   `json:"add_special_tokens,omitempty"`
}

func (*RenderRequest) DeepCopy

func (req *RenderRequest) DeepCopy() (*RenderRequest, error)

DeepCopy creates a deep copy of the RenderRequest.

type RenderResponse

type RenderResponse struct {
	TokenIDs       []uint32 `json:"input_ids"`
	OffsetMappings []Offset `json:"offset_mapping"`
}

Jump to

Keyboard shortcuts

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