protocolv2

package
v1.22.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "v2"

Variables

This section is empty.

Functions

func Validate

func Validate(req Request) error

Types

type Block

type Block struct {
	Type       BlockType   `json:"type"`
	Text       *Text       `json:"text,omitempty"`
	Thinking   *Thinking   `json:"thinking,omitempty"`
	ToolUse    *ToolUse    `json:"tool_use,omitempty"`
	ToolResult *ToolResult `json:"tool_result,omitempty"`
}

type BlockType

type BlockType string
const (
	BlockTypeText       BlockType = "text"
	BlockTypeThinking   BlockType = "thinking"
	BlockTypeToolUse    BlockType = "tool_use"
	BlockTypeToolResult BlockType = "tool_result"
)

type ContextEntity

type ContextEntity struct {
	EntityType ContextEntityType `json:"entity_type"`
	EntityID   string            `json:"entity_id"`
}

type ContextEntityType

type ContextEntityType string
const (
	ContextEntityTypeService  ContextEntityType = "service"
	ContextEntityTypeLogEvent ContextEntityType = "log_event"
)

type Message

type Message struct {
	Role       Role        `json:"role"`
	Content    []Block     `json:"content"`
	Model      string      `json:"model,omitempty"`
	StopReason *StopReason `json:"stop_reason,omitempty"`
}

type Request

type Request struct {
	ChatProtocolVersion string          `json:"chat_protocol_version"`
	ConversationID      string          `json:"conversation_id"`
	Messages            []Message       `json:"messages"`
	ContextEntities     []ContextEntity `json:"context_entities,omitempty"`
	Tools               []Tool          `json:"tools,omitempty"`
}

type Role

type Role string
const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
)

type StopReason

type StopReason string
const (
	StopReasonEndTurn StopReason = "end_turn"
	StopReasonToolUse StopReason = "tool_use"
)

type Text

type Text struct {
	Content string `json:"content"`
}

type Thinking

type Thinking struct {
	Content string `json:"content"`
}

type Tool

type Tool struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"input_schema"`
}

type ToolResult

type ToolResult struct {
	ToolUseID string          `json:"tool_use_id"`
	IsError   *bool           `json:"is_error"`
	Error     string          `json:"error,omitempty"`
	Content   json.RawMessage `json:"content,omitempty"`
}

type ToolUse

type ToolUse struct {
	ID    string          `json:"id"`
	Name  string          `json:"name"`
	Input json.RawMessage `json:"input"`
}

Jump to

Keyboard shortcuts

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