Documentation
¶
Overview ¶
Package simple contains the common adapter used by provider packages whose documented endpoint is OpenAI Chat-compatible and uses either bearer or no authentication.
Index ¶
- func New(selected model.Model, key auth.APIKey, definition Definition, ...) (inference.Client, error)
- func NewAnthropicCounter(provider llm.Provider) (contextcount.ContextCounter, error)
- func NewCounter(provider llm.Provider) (contextcount.ContextCounter, error)
- type Definition
- type Option
- func WithBodyField(name string, value any) Option
- func WithBodyPatch(patch func(map[string]json.RawMessage) error) Option
- func WithHeader(name, value string) Option
- func WithReasoningEffort(value string) Option
- func WithReasoningEnabled(enabled bool) Option
- func WithServiceTier(value string) Option
- func WithThinking(enabled bool) Option
- func WithThinkingBudget(budget int) Option
- func WithThinkingEnabled(enabled bool) Option
- type ThinkingBudgetError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAnthropicCounter ¶
func NewAnthropicCounter(provider llm.Provider) (contextcount.ContextCounter, error)
func NewCounter ¶
func NewCounter(provider llm.Provider) (contextcount.ContextCounter, error)
Types ¶
type Definition ¶
type Definition = compat.Definition
type Option ¶
func WithBodyField ¶
WithBodyField is kept in the internal adapter so provider packages can expose only the stable fields their upstream documents, without importing compat.
func WithBodyPatch ¶
func WithBodyPatch(patch func(map[string]json.RawMessage) error) Option
WithBodyPatch applies a provider-local patch after the common body fields are merged. Patches CHAIN in application order rather than replacing one another: compat.WithBodyPatch assigns, so the second of two patches silently discarded the first, and gitlab already relies on ordering it does not control (it appends its own model-rewriting patch AFTER the caller's options). Chaining here — the one place every provider package reaches WithBodyPatch through — makes an added patch additive, which is what a validating patch such as WithThinkingBudget's requires to be reliable.
func WithHeader ¶
func WithReasoningEffort ¶
func WithReasoningEnabled ¶
func WithServiceTier ¶
func WithThinking ¶
func WithThinkingBudget ¶
WithThinkingBudget injects a raw thinking.budget_tokens body field for the OpenAI-compatible and Anthropic-dialect targets that document it, and holds the result to Anthropic's rule that max_tokens must be GREATER than thinking.budget_tokens — violating it draws an HTTP 400 with that exact wording, confirmed live against api.anthropic.com.
The rule is enforced from a body patch rather than from the option itself because only the patch sees both numbers: the budget is fixed when the option is built, while the output cap is written by the codec when a request is encoded. The failure therefore surfaces from Invoke/Stream, but still before any bytes leave the process.
func WithThinkingEnabled ¶
type ThinkingBudgetError ¶
ThinkingBudgetError is a fail-closed rejection, before any I/O, of a request whose reasoning budget is not smaller than its output cap. Field names the body member that carried the cap, because the three dialects this adapter speaks spell it differently and the caller needs to know which one it set. Both numbers are on the error: a message naming only one of them would not say what to change.
func (*ThinkingBudgetError) Error ¶
func (e *ThinkingBudgetError) Error() string