Documentation
¶
Overview ¶
Package anthropic implements the Anthropic provider.
Index ¶
Constants ¶
View Source
const Name = "anthropic"
Name of the provider.
Variables ¶
This section is empty.
Functions ¶
func ProcessResponse ¶
func ProcessResponse(resp ResponseBody) (string, error)
ProcessResponse processes the response from the API.
Types ¶
type Anthropic ¶
type Anthropic struct {
*provider.Provider
// Endpoint of the LLM provider.
Endpoint string `json:"url" validate:"required"`
// Token of the LLM provider.
Token string `json:"-" validate:"required"`
// contains filtered or unexported fields
}
Anthropic provider definition.
func New ¶
func New( options ...provider.ClientFunc, ) (*Anthropic, error)
New creates a new Anthropic provider.
func NewDefault ¶
func NewDefault(options ...provider.ClientFunc) (*Anthropic, error)
NewDefault creates a new Anthropic provider with default values.
func (*Anthropic) Completion ¶
Completion generates a completion using the provider API. Optionally pass WithResponseBody to unmarshal the response body. It will always return the original, unparsed response body, if no error.
NOTE: Not all options are available for all providers.
type RequestBody ¶
type RequestBody struct {
Messages []message.Message `json:"messages"`
Model string `json:"model"`
Stream bool `json:"stream"`
MaxTokens int `json:"max_tokens,omitempty"`
System string `json:"system,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopK int `json:"top_k,omitempty"`
TopP float64 `json:"top_p,omitempty"`
}
RequestBody represents the request body for the API.
type ResponseBody ¶
type ResponseBody struct {
Content []Content `json:"content"`
ID string `json:"id"`
Model string `json:"model"`
Role string `json:"role"`
StopReason string `json:"stop_reason"`
StopSequence any `json:"stop_sequence"`
Type string `json:"type"`
Usage Usage `json:"usage"`
}
ResponseBody represents the response body from the API.
Click to show internal directories.
Click to hide internal directories.