Documentation ¶
Index ¶
- type BaseContent
- type Client
- func (c *Client) Complete(req *Request) (*SuccessfulResponse, error)
- func (c *Client) SendMessage(ctx context.Context, req *MessageRequest) (*MessageResponse, error)
- func (c *Client) StreamComplete(req *Request) (<-chan Event, error)
- func (c *Client) StreamMessage(ctx context.Context, req *MessageRequest) (<-chan StreamingEvent, error)
- type Content
- type ContentBlock
- type ContentType
- type Delta
- type Error
- type ErrorDetail
- type ErrorResponse
- type Event
- type ImageContent
- type ImageSource
- type Message
- type MessageRequest
- type MessageResponse
- type Metadata
- type Request
- type StreamingDeltaType
- type StreamingEvent
- type StreamingEventType
- type SuccessfulResponse
- type TextContent
- type Tool
- type ToolResultContent
- type ToolUseContent
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseContent ¶
type BaseContent struct {
Type_ ContentType `json:"type"`
}
func (BaseContent) MarshalZerologObject ¶
func (bc BaseContent) MarshalZerologObject(e *zerolog.Event)
type Client ¶
type Client struct { APIKey string APIVersion string BaseURL string // contains filtered or unexported fields }
Client represents the Claude API client.
func (*Client) Complete ¶
func (c *Client) Complete(req *Request) (*SuccessfulResponse, error)
Complete sends a completion request and returns the response.
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, req *MessageRequest) (*MessageResponse, error)
SendMessage sends a message request and returns the response.
func (*Client) StreamMessage ¶
func (c *Client) StreamMessage(ctx context.Context, req *MessageRequest) (<-chan StreamingEvent, error)
StreamMessage sends a message request and returns a channel of Events for streaming responses.
type Content ¶
type Content interface {
Type() ContentType
}
func NewImageContent ¶
func NewTextContent ¶
func NewToolResultContent ¶
func NewToolUseContent ¶
type ContentBlock ¶
type ContentBlock struct { Type ContentType `json:"type"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Input string `json:"input,omitempty"` Text string `json:"text,omitempty"` }
func (ContentBlock) MarshalZerologObject ¶
func (cb ContentBlock) MarshalZerologObject(e *zerolog.Event)
type ContentType ¶
type ContentType string
const ( ContentTypeText ContentType = "text" ContentTypeImage ContentType = "image" ContentTypeToolUse ContentType = "tool_use" ContentTypeToolResult ContentType = "tool_result" )
type Delta ¶
type Delta struct { Type StreamingDeltaType `json:"type"` Text string `json:"text,omitempty"` PartialJSON string `json:"partial_json"` StopReason string `json:"stop_reason,omitempty"` StopSequence string `json:"stop_sequence,omitempty"` }
func (Delta) MarshalZerologObject ¶
type Error ¶
func (Error) MarshalZerologObject ¶
type ErrorDetail ¶
ErrorDetail contains error details.
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
ErrorResponse represents the API's error response.
type ImageContent ¶
type ImageContent struct { BaseContent Source ImageSource `json:"source"` }
func (ImageContent) MarshalZerologObject ¶
func (ic ImageContent) MarshalZerologObject(e *zerolog.Event)
func (ImageContent) Type ¶
func (i ImageContent) Type() ContentType
type ImageSource ¶
type ImageSource struct { BaseContent Type string `json:"type"` MediaType string `json:"media_type"` Data string `json:"data"` }
func (ImageSource) MarshalZerologObject ¶
func (is ImageSource) MarshalZerologObject(e *zerolog.Event)
type Message ¶
type Message struct { Role string `json:"role"` Content []Content `json:"content"` // Can be a string or an array of content blocks }
Message represents a single message in the conversation.
func (*Message) UnmarshalJSON ¶
type MessageRequest ¶
type MessageRequest struct { Model string `json:"model"` Messages []Message `json:"messages"` MaxTokens int `json:"max_tokens"` Metadata *Metadata `json:"metadata,omitempty"` StopSequences []string `json:"stop_sequences,omitempty"` Stream bool `json:"stream"` System string `json:"system,omitempty"` Temperature *float64 `json:"temperature,omitempty"` Tools []Tool `json:"tools,omitempty"` TopK *int `json:"top_k,omitempty"` TopP *float64 `json:"top_p,omitempty"` }
MessageRequest represents the Messages API request payload.
type MessageResponse ¶
type MessageResponse struct { ID string `json:"id"` Type string `json:"type"` Role string `json:"role"` Content []Content `json:"content"` Model string `json:"model"` StopReason string `json:"stop_reason,omitempty"` StopSequence string `json:"stop_sequence,omitempty"` Usage Usage `json:"usage"` }
MessageResponse represents the Messages API response payload.
func (MessageResponse) FullText ¶
func (m MessageResponse) FullText() string
FullText is a way to quickly get the entire text of the message response, for our current streaming system which only deals with full strings.
func (MessageResponse) MarshalZerologObject ¶
func (s MessageResponse) MarshalZerologObject(e *zerolog.Event)
type Request ¶
type Request struct { Model string `json:"model"` Prompt string `json:"prompt"` MaxTokensToSample int `json:"max_tokens_to_sample"` StopSequences []string `json:"stop_sequences,omitempty"` Temperature *float64 `json:"temperature,omitempty"` TopP *float64 `json:"top_p,omitempty"` TopK *int `json:"top_k,omitempty"` Metadata *Metadata `json:"metadata,omitempty"` Stream bool `json:"stream"` }
Request represents the completion request payload.
type StreamingDeltaType ¶
type StreamingDeltaType string
const ( TextDeltaType StreamingDeltaType = "text_delta" InputJSONDeltaType StreamingDeltaType = "input_json_delta" )
type StreamingEvent ¶
type StreamingEvent struct { Type StreamingEventType `json:"type"` Message *MessageResponse `json:"message,omitempty"` Delta *Delta `json:"delta,omitempty"` Error *Error `json:"error,omitempty"` Index int `json:"index,omitempty"` Usage *Usage `json:"usage,omitempty"` ContentBlock *ContentBlock `json:"content_block,omitempty"` }
func (StreamingEvent) MarshalZerologObject ¶
func (s StreamingEvent) MarshalZerologObject(e *zerolog.Event)
type StreamingEventType ¶
type StreamingEventType string
const ( PingType StreamingEventType = "ping" MessageStartType StreamingEventType = "message_start" ContentBlockStartType StreamingEventType = "content_block_start" ContentBlockDeltaType StreamingEventType = "content_block_delta" ContentBlockStopType StreamingEventType = "content_block_stop" MessageDeltaType StreamingEventType = "message_delta" MessageStopType StreamingEventType = "message_stop" ErrorType StreamingEventType = "error" )
type SuccessfulResponse ¶
type SuccessfulResponse struct { Completion string `json:"completion"` StopReason string `json:"stop_reason"` Model string `json:"model"` }
SuccessfulResponse represents the API's successful response.
type TextContent ¶
type TextContent struct { BaseContent Text string `json:"text"` }
func (TextContent) MarshalZerologObject ¶
func (tc TextContent) MarshalZerologObject(e *zerolog.Event)
func (TextContent) Type ¶
func (t TextContent) Type() ContentType
type Tool ¶
type Tool struct { Name string `json:"name"` Description string `json:"description,omitempty"` InputSchema interface{} `json:"input_schema"` // JSON schema for the tool input }
Tool represents a tool that the model can use.
type ToolResultContent ¶
type ToolResultContent struct { BaseContent ToolUseID string `json:"tool_use_id"` Content string `json:"content"` }
func (ToolResultContent) MarshalZerologObject ¶
func (trc ToolResultContent) MarshalZerologObject(e *zerolog.Event)
func (ToolResultContent) Type ¶
func (t ToolResultContent) Type() ContentType
type ToolUseContent ¶
type ToolUseContent struct { BaseContent ID string `json:"id"` Name string `json:"name"` Input string `json:"input"` }
func (ToolUseContent) MarshalZerologObject ¶
func (tuc ToolUseContent) MarshalZerologObject(e *zerolog.Event)
func (ToolUseContent) Type ¶
func (t ToolUseContent) Type() ContentType