Documentation
¶
Index ¶
- func AnthropicComplete(model string, prompt string) (string, error)
- func AnthropicCompleteWithSystem(model string, system string, prompt string) (string, error)
- func Ask(c Client, prompt string) (string, error)
- func Complete(model string, prompt string) (string, error)
- func CompleteWithSystem(model string, systemPrompt string, prompt string) (string, error)
- func GetAnthropicText(resp AnthropicResponse) string
- func GetContent(comp Completion) string
- func GetResponseText(resp Response) string
- func GetThinking(resp AnthropicResponse) string
- func HasFunctionCalls(resp Response) bool
- func HasToolCalls(comp Completion) bool
- func HasToolUses(resp AnthropicResponse) bool
- func MAsk(c MessagesClient, prompt string) (string, error)
- func MSend(c MessagesClient) (string, error)
- func RAsk(c ResponseClient, prompt string) (string, error)
- func RSend(c ResponseClient) (string, error)
- func Respond(model string, prompt string) (string, error)
- func RespondWithInstructions(model string, instructions string, prompt string) (string, error)
- func Send(c Client) (string, error)
- type AnthropicDelta
- type AnthropicMessage
- type AnthropicResponse
- type AnthropicStreamEvent
- type AnthropicTool
- type AnthropicToolChoice
- type AnthropicUsage
- type Choice
- type Chunk
- type ChunkChoice
- type ChunkDelta
- type Client
- func APIKey(c Client, key string) Client
- func AddMessage(c Client, role string, content string) Client
- func AddTool(c Client, name string, description string, parameters any) Client
- func Assistant(c Client, content string) Client
- func BaseURL(c Client, url string) Client
- func FrequencyPenalty(c Client, penalty float64) Client
- func Gateway(c Client, url string) Client
- func JSONMode(c Client) Client
- func MaxTokens(c Client, max int) Client
- func Messages(c Client, msgs []Message) Client
- func New(model string) Client
- func Path(c Client, path string) Client
- func PresencePenalty(c Client, penalty float64) Client
- func Provider(c Client, provider string) Client
- func Retry(c Client, maxAttempts int, delayMs int) Client
- func Seed(c Client, seed int) Client
- func SetUser(c Client, user string) Client
- func Stop(c Client, sequences []string) Client
- func Stream(c Client, handler func(string)) Client
- func System(c Client, content string) Client
- func Temperature(c Client, temp float64) Client
- func ToolChoiceAuto(c Client) Client
- func ToolChoiceNone(c Client) Client
- func ToolChoiceRequired(c Client) Client
- func TopP(c Client, p float64) Client
- func User(c Client, content string) Client
- type Completion
- type CompletionRequest
- type ContentBlock
- type InputItem
- type InputTextContent
- type Message
- type MessagesClient
- func MAPIKey(c MessagesClient, key string) MessagesClient
- func MAPIVersion(c MessagesClient, version string) MessagesClient
- func MAdaptiveThinking(c MessagesClient) MessagesClient
- func MAddMessage(c MessagesClient, role string, content any) MessagesClient
- func MAddTool(c MessagesClient, name string, description string, inputSchema any) MessagesClient
- func MAssistant(c MessagesClient, content string) MessagesClient
- func MBaseURL(c MessagesClient, url string) MessagesClient
- func MEffort(c MessagesClient, effort string) MessagesClient
- func MInferenceGeo(c MessagesClient, geo string) MessagesClient
- func MMaxTokens(c MessagesClient, max int) MessagesClient
- func MOutputFormat(c MessagesClient, format any) MessagesClient
- func MPath(c MessagesClient, path string) MessagesClient
- func MRetry(c MessagesClient, maxAttempts int, delayMs int) MessagesClient
- func MStopSequences(c MessagesClient, sequences []string) MessagesClient
- func MStream(c MessagesClient, handler func(string)) MessagesClient
- func MStreamEvents(c MessagesClient, handler func(AnthropicStreamEvent)) MessagesClient
- func MSystem(c MessagesClient, system string) MessagesClient
- func MTemperature(c MessagesClient, temp float64) MessagesClient
- func MThinking(c MessagesClient, budgetTokens int) MessagesClient
- func MToolChoiceAny(c MessagesClient) MessagesClient
- func MToolChoiceAuto(c MessagesClient) MessagesClient
- func MToolChoiceTool(c MessagesClient, name string) MessagesClient
- func MToolResult(c MessagesClient, toolUseID string, result string) MessagesClient
- func MTopK(c MessagesClient, k int) MessagesClient
- func MTopP(c MessagesClient, p float64) MessagesClient
- func MUser(c MessagesClient, content string) MessagesClient
- func NewMessages(model string) MessagesClient
- type MessagesRequest
- type OutputConfig
- type OutputItem
- type OutputTextContent
- type RefusalContent
- type Response
- type ResponseClient
- func FunctionCallOutput(c ResponseClient, callID string, output string) ResponseClient
- func Instructions(c ResponseClient, instructions string) ResponseClient
- func NewResponse(model string) ResponseClient
- func PreviousResponse(c ResponseClient, id string) ResponseClient
- func RAPIKey(c ResponseClient, key string) ResponseClient
- func RAddInput(c ResponseClient, item InputItem) ResponseClient
- func RAddTool(c ResponseClient, name string, description string, parameters any) ResponseClient
- func RAssistantMessage(c ResponseClient, content string) ResponseClient
- func RBaseURL(c ResponseClient, url string) ResponseClient
- func RDeveloperMessage(c ResponseClient, content string) ResponseClient
- func RFrequencyPenalty(c ResponseClient, penalty float64) ResponseClient
- func RJSONMode(c ResponseClient) ResponseClient
- func RJSONSchema(c ResponseClient, name string, schema any) ResponseClient
- func RMaxOutputTokens(c ResponseClient, max int) ResponseClient
- func RMetadata(c ResponseClient, meta map[string]string) ResponseClient
- func RPath(c ResponseClient, path string) ResponseClient
- func RPresencePenalty(c ResponseClient, penalty float64) ResponseClient
- func RProvider(c ResponseClient, provider string) ResponseClient
- func RRetry(c ResponseClient, maxAttempts int, delayMs int) ResponseClient
- func RStore(c ResponseClient) ResponseClient
- func RStream(c ResponseClient, handler func(string)) ResponseClient
- func RStreamEvents(c ResponseClient, handler func(StreamEvent)) ResponseClient
- func RSystemMessage(c ResponseClient, content string) ResponseClient
- func RTemperature(c ResponseClient, temp float64) ResponseClient
- func RToolChoiceAuto(c ResponseClient) ResponseClient
- func RToolChoiceNone(c ResponseClient) ResponseClient
- func RToolChoiceRequired(c ResponseClient) ResponseClient
- func RTopP(c ResponseClient, p float64) ResponseClient
- func RTruncation(c ResponseClient, mode string) ResponseClient
- func RUserMessage(c ResponseClient, content string) ResponseClient
- type ResponseError
- type ResponseMessage
- type ResponseRequest
- type ResponseUsage
- type StreamEvent
- type ThinkingConfig
- type Tool
- type ToolCall
- type ToolCallFunction
- type ToolFunction
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompleteWithSystem ¶
func GetAnthropicText ¶
func GetAnthropicText(resp AnthropicResponse) string
func GetContent ¶
func GetContent(comp Completion) string
func GetResponseText ¶
func GetThinking ¶
func GetThinking(resp AnthropicResponse) string
func HasFunctionCalls ¶
func HasToolCalls ¶
func HasToolCalls(comp Completion) bool
func HasToolUses ¶
func HasToolUses(resp AnthropicResponse) bool
func MSend ¶
func MSend(c MessagesClient) (string, error)
func RSend ¶
func RSend(c ResponseClient) (string, error)
func RespondWithInstructions ¶
Types ¶
type AnthropicDelta ¶
type AnthropicMessage ¶
type AnthropicResponse ¶
type AnthropicResponse struct {
ID string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []ContentBlock `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason"`
StopSequence string `json:"stop_sequence,omitempty"`
Usage AnthropicUsage `json:"usage"`
}
func MAskRaw ¶
func MAskRaw(c MessagesClient, prompt string) (AnthropicResponse, error)
func MSendRaw ¶
func MSendRaw(c MessagesClient) (AnthropicResponse, error)
type AnthropicStreamEvent ¶
type AnthropicStreamEvent struct {
Type string `json:"type"`
Index int `json:"index,omitempty"`
Message AnthropicResponse `json:"message,omitempty"`
ContentBlock ContentBlock `json:"content_block,omitempty"`
Delta AnthropicDelta `json:"delta,omitempty"`
Usage AnthropicUsage `json:"usage,omitempty"`
}
type AnthropicTool ¶
type AnthropicToolChoice ¶
type AnthropicUsage ¶
type Choice ¶
type Choice struct {
Index int `json:"index"`
Message ResponseMessage `json:"message"`
FinishReason string `json:"finish_reason"`
}
type Chunk ¶
type Chunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
Choices []ChunkChoice `json:"choices"`
}
type ChunkChoice ¶
type ChunkChoice struct {
Index int `json:"index"`
Delta ChunkDelta `json:"delta"`
FinishReason string `json:"finish_reason,omitempty"`
}
type ChunkDelta ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func FrequencyPenalty ¶
func PresencePenalty ¶
func Temperature ¶
func ToolChoiceAuto ¶
func ToolChoiceNone ¶
func ToolChoiceRequired ¶
type Completion ¶
type Completion struct {
ID string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
Usage Usage `json:"usage"`
}
func SendRaw ¶
func SendRaw(c Client) (Completion, error)
type CompletionRequest ¶
type CompletionRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
TopP float64 `json:"top_p,omitempty"`
N int `json:"n,omitempty"`
Stop []string `json:"stop,omitempty"`
PresencePenalty float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
Seed int `json:"seed,omitempty"`
User string `json:"user,omitempty"`
Stream bool `json:"stream,omitempty"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
ResponseFormat any `json:"response_format,omitempty"`
}
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Thinking string `json:"thinking,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input any `json:"input,omitempty"`
ToolUseID string `json:"tool_use_id,omitempty"`
Content any `json:"content,omitempty"`
Source any `json:"source,omitempty"`
}
func GetToolUses ¶
func GetToolUses(resp AnthropicResponse) []ContentBlock
type InputItem ¶
type InputItem struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Role string `json:"role,omitempty"`
Content any `json:"content,omitempty"`
Status string `json:"status,omitempty"`
CallID string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Output string `json:"output,omitempty"`
}
type InputTextContent ¶
type MessagesClient ¶
type MessagesClient struct {
// contains filtered or unexported fields
}
func MAPIKey ¶
func MAPIKey(c MessagesClient, key string) MessagesClient
func MAPIVersion ¶
func MAPIVersion(c MessagesClient, version string) MessagesClient
func MAdaptiveThinking ¶
func MAdaptiveThinking(c MessagesClient) MessagesClient
func MAddMessage ¶
func MAddMessage(c MessagesClient, role string, content any) MessagesClient
func MAddTool ¶
func MAddTool(c MessagesClient, name string, description string, inputSchema any) MessagesClient
func MAssistant ¶
func MAssistant(c MessagesClient, content string) MessagesClient
func MBaseURL ¶
func MBaseURL(c MessagesClient, url string) MessagesClient
func MEffort ¶
func MEffort(c MessagesClient, effort string) MessagesClient
func MInferenceGeo ¶
func MInferenceGeo(c MessagesClient, geo string) MessagesClient
func MMaxTokens ¶
func MMaxTokens(c MessagesClient, max int) MessagesClient
func MOutputFormat ¶
func MOutputFormat(c MessagesClient, format any) MessagesClient
func MPath ¶
func MPath(c MessagesClient, path string) MessagesClient
func MRetry ¶ added in v0.0.6
func MRetry(c MessagesClient, maxAttempts int, delayMs int) MessagesClient
func MStopSequences ¶
func MStopSequences(c MessagesClient, sequences []string) MessagesClient
func MStream ¶
func MStream(c MessagesClient, handler func(string)) MessagesClient
func MStreamEvents ¶
func MStreamEvents(c MessagesClient, handler func(AnthropicStreamEvent)) MessagesClient
func MSystem ¶
func MSystem(c MessagesClient, system string) MessagesClient
func MTemperature ¶
func MTemperature(c MessagesClient, temp float64) MessagesClient
func MThinking ¶
func MThinking(c MessagesClient, budgetTokens int) MessagesClient
func MToolChoiceAny ¶
func MToolChoiceAny(c MessagesClient) MessagesClient
func MToolChoiceAuto ¶
func MToolChoiceAuto(c MessagesClient) MessagesClient
func MToolChoiceTool ¶
func MToolChoiceTool(c MessagesClient, name string) MessagesClient
func MToolResult ¶
func MToolResult(c MessagesClient, toolUseID string, result string) MessagesClient
func MTopK ¶
func MTopK(c MessagesClient, k int) MessagesClient
func MTopP ¶
func MTopP(c MessagesClient, p float64) MessagesClient
func MUser ¶
func MUser(c MessagesClient, content string) MessagesClient
func NewMessages ¶
func NewMessages(model string) MessagesClient
type MessagesRequest ¶
type MessagesRequest struct {
Model string `json:"model"`
Messages []AnthropicMessage `json:"messages"`
MaxTokens int `json:"max_tokens"`
System string `json:"system,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
Stream bool `json:"stream,omitempty"`
Tools []AnthropicTool `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
Metadata any `json:"metadata,omitempty"`
Thinking any `json:"thinking,omitempty"`
Effort string `json:"effort,omitempty"`
OutputConfig any `json:"output_config,omitempty"`
InferenceGeo string `json:"inference_geo,omitempty"`
}
type OutputConfig ¶
type OutputConfig struct {
Format any `json:"format,omitempty"`
}
type OutputItem ¶
type OutputItem struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Role string `json:"role,omitempty"`
Content []any `json:"content,omitempty"`
Status string `json:"status,omitempty"`
CallID string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Summary []any `json:"summary,omitempty"`
}
func GetFunctionCalls ¶
func GetFunctionCalls(resp Response) []OutputItem
type OutputTextContent ¶
type RefusalContent ¶
type Response ¶
type Response struct {
ID string `json:"id"`
Object string `json:"object"`
CreatedAt int `json:"created_at"`
CompletedAt int `json:"completed_at,omitempty"`
Status string `json:"status"`
Model string `json:"model"`
Output []OutputItem `json:"output"`
Error ResponseError `json:"error,omitempty"`
PreviousResponseID string `json:"previous_response_id,omitempty"`
Instructions string `json:"instructions,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Usage ResponseUsage `json:"usage,omitempty"`
Tools []any `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
Truncation string `json:"truncation,omitempty"`
Store bool `json:"store,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
func RSendRaw ¶
func RSendRaw(c ResponseClient) (Response, error)
type ResponseClient ¶
type ResponseClient struct {
// contains filtered or unexported fields
}
func FunctionCallOutput ¶
func FunctionCallOutput(c ResponseClient, callID string, output string) ResponseClient
func Instructions ¶
func Instructions(c ResponseClient, instructions string) ResponseClient
func NewResponse ¶
func NewResponse(model string) ResponseClient
func PreviousResponse ¶
func PreviousResponse(c ResponseClient, id string) ResponseClient
func RAPIKey ¶
func RAPIKey(c ResponseClient, key string) ResponseClient
func RAddInput ¶
func RAddInput(c ResponseClient, item InputItem) ResponseClient
func RAddTool ¶
func RAddTool(c ResponseClient, name string, description string, parameters any) ResponseClient
func RAssistantMessage ¶
func RAssistantMessage(c ResponseClient, content string) ResponseClient
func RBaseURL ¶
func RBaseURL(c ResponseClient, url string) ResponseClient
func RDeveloperMessage ¶
func RDeveloperMessage(c ResponseClient, content string) ResponseClient
func RFrequencyPenalty ¶
func RFrequencyPenalty(c ResponseClient, penalty float64) ResponseClient
func RJSONMode ¶
func RJSONMode(c ResponseClient) ResponseClient
func RJSONSchema ¶
func RJSONSchema(c ResponseClient, name string, schema any) ResponseClient
func RMaxOutputTokens ¶
func RMaxOutputTokens(c ResponseClient, max int) ResponseClient
func RMetadata ¶
func RMetadata(c ResponseClient, meta map[string]string) ResponseClient
func RPath ¶
func RPath(c ResponseClient, path string) ResponseClient
func RPresencePenalty ¶
func RPresencePenalty(c ResponseClient, penalty float64) ResponseClient
func RProvider ¶
func RProvider(c ResponseClient, provider string) ResponseClient
func RRetry ¶ added in v0.0.6
func RRetry(c ResponseClient, maxAttempts int, delayMs int) ResponseClient
func RStore ¶
func RStore(c ResponseClient) ResponseClient
func RStream ¶
func RStream(c ResponseClient, handler func(string)) ResponseClient
func RStreamEvents ¶
func RStreamEvents(c ResponseClient, handler func(StreamEvent)) ResponseClient
func RSystemMessage ¶
func RSystemMessage(c ResponseClient, content string) ResponseClient
func RTemperature ¶
func RTemperature(c ResponseClient, temp float64) ResponseClient
func RToolChoiceAuto ¶
func RToolChoiceAuto(c ResponseClient) ResponseClient
func RToolChoiceNone ¶
func RToolChoiceNone(c ResponseClient) ResponseClient
func RToolChoiceRequired ¶
func RToolChoiceRequired(c ResponseClient) ResponseClient
func RTopP ¶
func RTopP(c ResponseClient, p float64) ResponseClient
func RTruncation ¶
func RTruncation(c ResponseClient, mode string) ResponseClient
func RUserMessage ¶
func RUserMessage(c ResponseClient, content string) ResponseClient
type ResponseError ¶
type ResponseMessage ¶
type ResponseRequest ¶
type ResponseRequest struct {
Model string `json:"model"`
Input any `json:"input"`
Instructions string `json:"instructions,omitempty"`
PreviousResponseID string `json:"previous_response_id,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
PresencePenalty float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
Stream bool `json:"stream,omitempty"`
Store bool `json:"store,omitempty"`
Truncation string `json:"truncation,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Text any `json:"text,omitempty"`
}
type ResponseUsage ¶
type StreamEvent ¶
type StreamEvent struct {
Type string `json:"type"`
SequenceNumber int `json:"sequence_number"`
Response Response `json:"response,omitempty"`
OutputIndex int `json:"output_index,omitempty"`
ContentIndex int `json:"content_index,omitempty"`
ItemID string `json:"item_id,omitempty"`
Item OutputItem `json:"item,omitempty"`
Delta string `json:"delta,omitempty"`
Text string `json:"text,omitempty"`
Part any `json:"part,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
}
type ThinkingConfig ¶
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function ToolCallFunction `json:"function"`
}
func GetToolCalls ¶
func GetToolCalls(comp Completion) []ToolCall
type ToolCallFunction ¶
type ToolFunction ¶
Click to show internal directories.
Click to hide internal directories.