Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions providers/anthropic/anthropic.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func betaRequestOptions(flags []string) []option.RequestOption {
// by Generate and Stream: user-agent, raw tool injection, and any
// beta API flags.
func buildRequestOptions(call fantasy.Call, rawTools []json.RawMessage, betaFlags []string) []option.RequestOption {
providerOptions := &ProviderOptions{}
if v, ok := call.ProviderOptions[Name]; ok {
providerOptions, _ = v.(*ProviderOptions)
}

reqOpts := callUARequestOptions(call)
if len(rawTools) > 0 {
// Tools are injected as raw JSON rather than via params.Tools
Expand All @@ -50,6 +55,9 @@ func buildRequestOptions(call fantasy.Call, rawTools []json.RawMessage, betaFlag
// this will need updating.
reqOpts = append(reqOpts, option.WithJSONSet("tools", rawTools))
}
for k, v := range providerOptions.ExtraBody {
reqOpts = append(reqOpts, option.WithJSONSet(k, v))
}
if len(betaFlags) > 0 {
reqOpts = append(reqOpts, betaRequestOptions(betaFlags)...)
}
Expand Down
1 change: 1 addition & 0 deletions providers/anthropic/provider_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type ProviderOptions struct {
Thinking *ThinkingProviderOption `json:"thinking"`
Effort *Effort `json:"effort"`
DisableParallelToolUse *bool `json:"disable_parallel_tool_use"`
ExtraBody map[string]any `json:"extra_body,omitempty"`
}

// Options implements the ProviderOptions interface.
Expand Down
Loading