-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompat.go
More file actions
57 lines (47 loc) · 2.09 KB
/
compat.go
File metadata and controls
57 lines (47 loc) · 2.09 KB
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
package iteragent
// Compatibility stubs for iterate. These interfaces and functions existed in
// earlier iteragent versions and are still referenced by downstream consumers.
// TokenStreamer is implemented by providers that support token-level streaming.
type TokenStreamer interface {
CompleteStreamTokens(ctx interface{}, messages []Message, opts CompletionOptions) (<-chan string, error)
}
// ThinkingStreamer is implemented by providers that expose thinking/reasoning tokens.
type ThinkingStreamer interface {
CompleteWithThinking(ctx interface{}, messages []Message, opts CompletionOptions) (string, string, error)
}
// NativeToolCaller is implemented by providers that support native tool calling.
type NativeToolCaller interface {
CompleteWithTools(ctx interface{}, messages []Message, tools []ToolDefinition, opts CompletionOptions) (string, []ToolCall, error)
}
// ProviderContextWindow returns the context window size in tokens for the
// given provider, or 0 if unknown.
func ProviderContextWindow(p Provider) int {
// No providers currently expose their context window size.
return 0
}
// WithLLMCompaction enables LLM-assisted compaction at the given token threshold.
func (a *Agent) WithLLMCompaction(tokens int) *Agent {
// LLM compaction is not supported in this version.
return a
}
// SetPinnedMessages sets messages that should be preserved during compaction.
func (a *Agent) SetPinnedMessages(msgs []Message) {
// Pinned messages are not supported in this version.
}
// LLMCompactionStrategy uses an LLM to compact conversation history.
type LLMCompactionStrategy struct {
Provider Provider
KeepRecent int
}
// Compact reduces the message list to fit within maxTokens using LLM summarisation.
func (s *LLMCompactionStrategy) Compact(messages []Message, maxTokens int) []Message {
// LLM compaction is not supported; fall back to simple truncation.
if len(messages) > s.KeepRecent {
return messages[len(messages)-s.KeepRecent:]
}
return messages
}
// ArgStr extracts a string value from a map[string]string args map.
func ArgStr(args map[string]string, key string) string {
return args[key]
}