Documentation
¶
Index ¶
- Constants
- type Claude
- func (c *Claude) Add(_ context.Context, prompt string, media ...chat.Media) error
- func (c *Claude) AddCached(_ context.Context, prompt string, media ...chat.Media) error
- func (c *Claude) ApplyPolicyNow(ctx context.Context, policy chat.HistoryPolicy) (int, error)
- func (c *Claude) Ask(ctx context.Context, question string, target any, media ...chat.Media) error
- func (c *Claude) Chat(ctx context.Context, prompt string, media ...chat.Media) (string, error)
- func (c *Claude) History() chat.History
- func (c *Claude) Model() string
- func (c *Claude) Provider() chat.Provider
- func (c *Claude) Restore(snapshot *chat.Snapshot) error
- func (c *Claude) Save() (*chat.Snapshot, error)
- func (c *Claude) SetTools(tools []chat.Tool) error
- func (c *Claude) StreamChat(ctx context.Context, prompt string, callback chat.StreamCallback, ...) (string, error)
- func (c *Claude) SupportsEffort()
- func (c *Claude) SupportsSampling()
- func (c *Claude) SupportsStateless()
Constants ¶
const EnvClaudeKey = "ANTHROPIC_API_KEY"
EnvClaudeKey is the well-known unprefixed environment variable used as the ecosystem fallback when no explicit credential is configured.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claude ¶
type Claude struct {
chat.UsageTracker
// contains filtered or unexported fields
}
Claude implements the chat.ChatClient interface using Anthropic's official Go SDK.
func (*Claude) AddCached ¶ added in v0.5.0
AddCached appends a user turn carrying a cache_control marker.
The marker goes on this block and no other. In particular it never lands on a per-call turn, which would write a cache entry keyed to content that changes every request — paying the write premium for something that can never be read back.
func (*Claude) ApplyPolicyNow ¶ added in v0.11.0
ApplyPolicyNow bounds the retained conversation immediately, rather than waiting for the next request to do it.
It is the same three steps this client already runs before every request — describe the turns, ask the policy, rewrite from the result — with the difference that there is no pending turn to hold out of the budget. Every retained turn is a candidate, because nothing is about to be answered.
A nil policy means the configured one. With none configured there is nothing to apply and it returns zero rather than an error: a caller typing /compact on a client with no policy has asked for something reasonable that happens to be a no-op.
func (*Claude) Ask ¶
Ask sends a question to the Claude chat client and expects a structured response.
func (*Claude) History ¶ added in v0.9.0
History reports the conversation this client will re-send, counting both the committed turns and any buffered by Add and not yet sent.
Known is true: this provider owns its transcript, so the count is authoritative. A stateless client retains nothing between calls and reports only what is currently buffered.
func (*Claude) Model ¶ added in v0.6.0
Model implements chat.ModelIdentifier, reporting the model this client will actually use — the configured one, or the default it fell back to.
func (*Claude) Restore ¶
Restore replaces the current conversation state with a previously saved snapshot.
func (*Claude) Save ¶
Save captures the current Claude conversation state as a snapshot.
A stateless client retains no conversation, so its snapshot carries an empty message list. That is honest rather than useless: the provider, model and system prompt still round-trip.
func (*Claude) StreamChat ¶
func (c *Claude) StreamChat(ctx context.Context, prompt string, callback chat.StreamCallback, media ...chat.Media) (string, error)
StreamChat implements StreamingChatClient.
func (*Claude) SupportsEffort ¶ added in v0.3.0
func (c *Claude) SupportsEffort()
SupportsEffort marks Claude as able to carry Config.Effort, via output_config.effort. The API's ladder is low/medium/high/xhigh/max, which is exactly the neutral ladder, so nothing is clamped or invented.
func (*Claude) SupportsSampling ¶ added in v0.3.0
func (c *Claude) SupportsSampling()
SupportsSampling marks Claude as able to carry Config.Temperature and TopP.
Structural only. Whether the selected *model* accepts them is a separate question that cannot be answered here — claude-opus-4-8 reports temperature as deprecated while claude-sonnet-4-5 accepts it — and surfaces as chat.ErrModelRejectedParameter when the request is made.
func (*Claude) SupportsStateless ¶ added in v0.2.0
func (c *Claude) SupportsStateless()
SupportsStateless marks Claude as honouring chat.Config.Stateless.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
detectmodels
command
Command detectmodels reports when Anthropic has shipped something the module's default model does not reflect.
|
Command detectmodels reports when Anthropic has shipped something the module's default model does not reflect. |
|
genmodels
command
Command genmodels regenerates the per-model capability table.
|
Command genmodels regenerates the per-model capability table. |