Documentation
¶
Overview ¶
Package message defines Lightcode's canonical conversation message model.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneRaw ¶
func CloneRaw(raw json.RawMessage) json.RawMessage
CloneRaw returns a copy of a raw JSON value.
Types ¶
type ContentPart ¶
type ContentPart struct {
Type ContentPartType
Text string
URL string
Extra Extra
}
ContentPart is one canonical content item. Opaque parts preserve the full provider wire object in Extra.
func (ContentPart) MarshalJSON ¶
func (p ContentPart) MarshalJSON() ([]byte, error)
MarshalJSON serializes content parts as OpenAI-compatible content objects.
func (*ContentPart) UnmarshalJSON ¶
func (p *ContentPart) UnmarshalJSON(data []byte) error
UnmarshalJSON loads a content part and keeps non-canonical fields in Extra.
type ContentPartType ¶
type ContentPartType string
ContentPartType is the canonical type of a message content part.
const ( ContentPartText ContentPartType = "text" ContentPartImageURL ContentPartType = "image_url" ContentPartOpaque ContentPartType = "opaque" )
type Extra ¶
type Extra map[string]json.RawMessage
Extra stores provider-specific JSON fields as raw wire values.
func (Extra) WithoutNulls ¶
WithoutNulls returns a copy without JSON null values.
type ExtraAccumulator ¶
type ExtraAccumulator struct {
// contains filtered or unexported fields
}
ExtraAccumulator accumulates streamed Extra values by first observed JSON kind.
func NewExtraAccumulator ¶
func NewExtraAccumulator() *ExtraAccumulator
NewExtraAccumulator returns an empty accumulator.
func (*ExtraAccumulator) Add ¶
func (a *ExtraAccumulator) Add(key string, value json.RawMessage) error
Add merges one raw JSON value into key's accumulated value.
func (*ExtraAccumulator) Extra ¶
func (a *ExtraAccumulator) Extra() Extra
Extra returns the accumulated values with JSON null entries removed.
type FunctionCall ¶
type FunctionCall struct {
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
}
FunctionCall is the OpenAI-compatible function call payload.
type Message ¶
type Message struct {
Role Role
Content []ContentPart
Refusal string
ToolCalls []ToolCall
ToolCallID string
Name string
Extra Extra
Source coremodel.ModelRef
InternalKind string
DisplayMetadata map[string]any
}
Message is Lightcode's provider-independent message shape.
func (*Message) AppendText ¶
AppendText appends text to the last text part, or creates one.
func (Message) MarshalJSON ¶
MarshalJSON serializes messages in the OpenAI-compatible shape, with Extra flattened as provider wire siblings and Lightcode private fields persisted.
func (Message) TextContent ¶
TextContent returns all text parts joined in order.
func (*Message) UnmarshalJSON ¶
UnmarshalJSON loads both canonical fields and unknown provider wire siblings.
type ToolCall ¶
type ToolCall struct {
ID string
Type string
Function FunctionCall
Extra Extra
}
ToolCall is an assistant tool call with optional provider-specific data.
func (ToolCall) MarshalJSON ¶
MarshalJSON serializes tool calls with Extra flattened as siblings.
func (*ToolCall) UnmarshalJSON ¶
UnmarshalJSON loads a tool call and keeps non-canonical fields in Extra.