-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.go
76 lines (57 loc) · 1.45 KB
/
message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package core
import (
"encoding/json"
"time"
)
type MessageRole string
const (
UserMessageRole MessageRole = "user"
AssistantMessageRole MessageRole = "assistant"
SystemMessageRole MessageRole = "system"
ToolMessageRole MessageRole = "tool"
)
// Message represents a single message in a LLM conversation flow with multimodal
// support.
type Message struct {
// ID is the incrementing internal integer identifier
ID uint32
// The role of the message sender
Role MessageRole
// The primary content of the message (usually text)
Content string
// A list of base64-encoded images (for multimodal models such as llava
// or llama3.2-vision)
Images []*Image
// Multiple tool calls
ToolCalls []*ToolCall
// Result from tool execution
ToolResult []*ToolResult
// Additional context
Metadata *Metadata
// Generally, message errors are recoverable
Error error
}
// For timestamps, source info, etc.
type Metadata struct {
Timestamp time.Time
Source string
RequestID int
ProviderProperties map[string]string
}
// ToolCall represents a specific tool invocation request
type ToolCall struct {
// Unique identifier for tracking
ID string
// Name of the tool being called
Name string
// Structured arguments
Arguments json.RawMessage
}
// ToolResult contains the output of a tool execution
type ToolResult struct {
// Reference to original call
ToolCallID string
// Structured result (usually JSON)
Content any
Error string
}