69 lines
1.6 KiB
Go
69 lines
1.6 KiB
Go
// Package llm definiert das providerunabhängige Nachrichten- und Event-Modell.
|
|
package llm
|
|
|
|
import "encoding/json"
|
|
|
|
type Role string
|
|
|
|
const (
|
|
RoleUser Role = "user"
|
|
RoleAssistant Role = "assistant"
|
|
)
|
|
|
|
type BlockKind string
|
|
|
|
const (
|
|
KindText BlockKind = "text"
|
|
KindThinking BlockKind = "thinking"
|
|
KindToolUse BlockKind = "tool_use"
|
|
KindToolResult BlockKind = "tool_result"
|
|
KindImage BlockKind = "image"
|
|
)
|
|
|
|
type Block struct {
|
|
Kind BlockKind `json:"kind"`
|
|
|
|
// text / thinking
|
|
Text string `json:"text,omitempty"`
|
|
|
|
// tool_use
|
|
ID string `json:"id,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
Input json.RawMessage `json:"input,omitempty"`
|
|
|
|
// tool_result
|
|
ToolUseID string `json:"tool_use_id,omitempty"`
|
|
Result []Block `json:"result,omitempty"`
|
|
IsError bool `json:"is_error,omitempty"`
|
|
|
|
// image
|
|
MediaType string `json:"media_type,omitempty"`
|
|
Data []byte `json:"data,omitempty"`
|
|
|
|
// Opaker Provider-Ballast (Anthropic-Signatures, reasoning-IDs).
|
|
// Muss unverändert zurückgesendet werden können.
|
|
Raw json.RawMessage `json:"raw,omitempty"`
|
|
|
|
// Cache-Breakpoint. Adapter ohne Cache-Steuerung ignorieren das Feld.
|
|
CacheMark bool `json:"cache_mark,omitempty"`
|
|
}
|
|
|
|
type Message struct {
|
|
Role Role `json:"role"`
|
|
Content []Block `json:"content"`
|
|
}
|
|
|
|
type Request struct {
|
|
Model string
|
|
System []Block // eigenes Feld, NICHT als Message in der Historie
|
|
Messages []Message
|
|
Tools []ToolDef
|
|
MaxTokens int
|
|
Temp *float64
|
|
}
|
|
|
|
type ToolDef struct {
|
|
Name string
|
|
Description string
|
|
Schema json.RawMessage // kanonisch: JSON Schema
|
|
}
|