Documentation
¶
Index ¶
- Constants
- Variables
- type Claude
- func (c *Claude) CountInputTokens(ctx context.Context, chat pub_models.Chat) (int, error)
- func (c *Claude) RegisterTool(tool pub_models.LLMTool)
- func (c *Claude) Setup() error
- func (c *Claude) StreamCompletions(ctx context.Context, chat pub_models.Chat) (chan models.CompletionEvent, error)
- func (c *Claude) TokenUsage() *pub_models.Usage
- type ClaudeConvMessage
- type ClaudeMessage
- type ClaudeResponse
- type ContentBlockDelta
- type ContentBlockSuper
- type Delta
- type Root
- type SourceReader
- type TextContentBlock
- type TokenInfo
- type ToolResultContentBlock
- type ToolUseContentBlock
Constants ¶
const ClaudeURL = "https://api.anthropic.com/v1/messages"
Variables ¶
var Default = Claude{ Model: "claude-sonnet-4", URL: ClaudeURL, AnthropicVersion: "2023-06-01", AnthropicBeta: "", Temperature: 0.5, MaxTokens: 8192, StopSequences: make([]string, 0), }
Functions ¶
This section is empty.
Types ¶
type Claude ¶
type Claude struct {
Model string `json:"model"`
MaxTokens int `json:"max_tokens"`
URL string `json:"url"`
AnthropicVersion string `json:"anthropic-version"`
AnthropicBeta string `json:"anthropic-beta"`
Temperature float64 `json:"temperature"`
TopP float64 `json:"top_p"`
TopK int `json:"top_k"`
StopSequences []string `json:"stop_sequences"`
PrintInputCount bool `json:"print_input_count"`
// contains filtered or unexported fields
}
func (*Claude) CountInputTokens ¶
func (*Claude) RegisterTool ¶
func (c *Claude) RegisterTool(tool pub_models.LLMTool)
func (*Claude) StreamCompletions ¶
func (c *Claude) StreamCompletions(ctx context.Context, chat pub_models.Chat) (chan models.CompletionEvent, error)
func (*Claude) TokenUsage ¶
func (c *Claude) TokenUsage() *pub_models.Usage
TokenUsage implements models.UsageTokenCounter.
Claude exposes the (counted) input token usage via CountInputTokens. Anthropic's streaming API does not provide completion token usage in this implementation, so we only populate prompt tokens.
type ClaudeConvMessage ¶
type ClaudeMessage ¶
type ClaudeResponse ¶
type ContentBlockDelta ¶
type ContentBlockSuper ¶
type ContentBlockSuper struct {
Type string `json:"type"`
Index int `json:"index"`
ToolContentBlock ToolUseContentBlock `json:"content_block"`
}
type Root ¶
type Root struct {
Type string `json:"type"`
Index int `json:"index"`
ContentBlock ToolUseContentBlock `json:"content_block"`
}
type SourceReader ¶ added in v1.10.11
type SourceReader struct {
FS fs.FS
// Root is the absolute directory that contains the Claude projects.
// If empty, defaults to $HOME/.claude/projects.
//
// This exists primarily for tests; production code should leave it empty.
Root string
}
SourceReader reads Claude Code / Claude Desktop conversation logs from disk.
Storage (best-effort, observed): ~/.claude/projects/<project>/*.jsonl Each line is JSON with a "type" such as: user, assistant, system, queue-operation. Task-subagent transcripts live under <sessionId>/subagents/ and carry the parent's sessionId ("isSidechain": true) — they are never sessions themselves, so both the directory and sidechain lines are skipped everywhere.
This reader is intentionally conservative: discovery is bounded and skips rows with missing SourceID.
FS is injectable for tests; if nil, the host root filesystem is used. The host-path logic (HOME expansion, walking) stays outside the FS — it is only used for opening files.
clai never writes back to these sources.
func (SourceReader) Read ¶ added in v1.10.11
func (r SourceReader) Read(ctx context.Context, sourceID string) (pub_models.Chat, error)
func (SourceReader) Source ¶ added in v1.10.11
func (r SourceReader) Source() string