Documentation
¶
Index ¶
- Constants
- func HasFinishReason(message Message, reason string) bool
- func RunReply(messages []Message, runID string) string
- type Compaction
- type FilePart
- type FinishPart
- type ImagePart
- type Message
- type MessagePart
- type MessagePartKind
- type MessageRole
- type Origin
- type ReasoningPart
- type TextPart
- type ToolCallPart
- type ToolResultPart
Constants ¶
const ( FinishReasonEndTurn = "end_turn" FinishReasonToolCalls = "tool_calls" FinishReasonMaxTokens = "max_tokens" FinishReasonError = "error" FinishReasonCanceled = "canceled" FinishReasonDaemonRestart = "daemon_restart" )
Finish reasons of assistant messages.
Variables ¶
This section is empty.
Functions ¶
func HasFinishReason ¶
HasFinishReason reports whether the message has a finish part with the reason; an empty reason matches any finish part.
Types ¶
type Compaction ¶
type Compaction struct {
Summary string `json:"summary,omitempty"`
Kept []string `json:"kept,omitempty"`
CoversThroughSeq int64 `json:"covers_through_seq"`
RunID string `json:"run_id,omitempty"`
TokensBefore int `json:"tokens_before,omitempty"`
TokensAfter int `json:"tokens_after,omitempty"`
Cleared bool `json:"cleared,omitempty"`
}
Compaction makes a message a context boundary: the model sees Summary and Kept instead of the session's messages up to CoversThroughSeq. Cleared marks a /clear, which keeps nothing. Tokens are estimates of the prompt around it.
type FilePart ¶ added in v0.2.4
type FilePart struct {
MIMEType string `json:"mime_type,omitempty"`
Name string `json:"name,omitempty"`
StoragePath string `json:"storage_path"`
Temporary bool `json:"temporary,omitempty"`
Size int64 `json:"size,omitempty"`
}
FilePart is an attached file the model is not shown inline, a document or a video; it reads it with tools by its storage path.
type FinishPart ¶
type FinishPart struct {
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
Details json.RawMessage `json:"details,omitempty"`
}
type Message ¶
type Message struct {
ID string `json:"id"`
Seq int64 `json:"seq,omitempty"`
SessionID string `json:"session_id"`
RunID string `json:"run_id"`
Role MessageRole `json:"role"`
Origin Origin `json:"origin,omitempty"`
Content string `json:"content"`
Parts []MessagePart `json:"parts,omitempty"`
Compaction *Compaction `json:"compaction,omitempty"`
Model string `json:"model,omitempty"`
Provider string `json:"provider,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func SealInterrupted ¶ added in v0.2.1
SealInterrupted ends message with a daemon_restart finish part, which keeps it out of every later request; note says why ("" for a daemon restart).
type MessagePart ¶
type MessagePart struct {
Kind MessagePartKind `json:"kind"`
Text *TextPart `json:"text,omitempty"`
Image *ImagePart `json:"image,omitempty"`
File *FilePart `json:"file,omitempty"`
Reasoning *ReasoningPart `json:"reasoning,omitempty"`
ToolCall *ToolCallPart `json:"tool_call,omitempty"`
ToolResult *ToolResultPart `json:"tool_result,omitempty"`
Finish *FinishPart `json:"finish,omitempty"`
}
func NormalizeMessageParts ¶
func NormalizeMessageParts(content string, parts []MessagePart) []MessagePart
type MessagePartKind ¶
type MessagePartKind string
const ( MessagePartKindText MessagePartKind = "text" MessagePartKindImage MessagePartKind = "image" MessagePartKindFile MessagePartKind = "file" MessagePartKindReasoning MessagePartKind = "reasoning" MessagePartKindToolCall MessagePartKind = "tool_call" MessagePartKindToolResult MessagePartKind = "tool_result" MessagePartKindFinish MessagePartKind = "finish" )
type MessageRole ¶
type MessageRole string
const ( MessageRoleUser MessageRole = "user" MessageRoleAssistant MessageRole = "assistant" MessageRoleSystem MessageRole = "system" MessageRoleTool MessageRole = "tool" )
type Origin ¶
type Origin string
Origin says who wrote a message when its role alone does not.
Engine notes reach the model as user text. Clients show OriginEngine notes as system notes and hide OriginEngineModel ones, which only the model needs.
type ReasoningPart ¶
type ToolCallPart ¶
type ToolResultPart ¶
type ToolResultPart struct {
ToolCallID string `json:"tool_call_id"`
Name string `json:"name"`
Content string `json:"content"`
MIMEType string `json:"mime_type,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
// Status is success, error or neutral; empty is success.
Status string `json:"status,omitempty"`
// OutputPath is the file holding the full output when Content was cut.
OutputPath string `json:"output_path,omitempty"`
}
func (ToolResultPart) IsError ¶
func (p ToolResultPart) IsError() bool
IsError reports whether the call failed.