Documentation ¶
Index ¶
- func IsClaudeEngine(engine string) bool
- 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 Event, error)
- type Content
- type ErrorDetail
- type ErrorResponse
- type Event
- type ImageContent
- type ImageSource
- type Message
- type MessageRequest
- type MessageResponse
- type Metadata
- type Request
- type Step
- type SuccessfulResponse
- type Tool
- type ToolUseContent
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsClaudeEngine ¶
Types ¶
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 ¶ added in v0.4.6
func (c *Client) SendMessage(ctx context.Context, req *MessageRequest) (*MessageResponse, error)
SendMessage sends a message request and returns the response.
func (*Client) StreamMessage ¶ added in v0.4.6
StreamMessage sends a message request and returns a channel of Events for streaming responses.
type Content ¶ added in v0.4.6
type Content struct { Type string `json:"type"` Text *string `json:"text,omitempty"` Image *ImageContent `json:"image,omitempty"` ToolUse *ToolUseContent `json:"tool_use,omitempty"` }
Content represents a single block of content, which can be of various types.
func NewImageContent ¶ added in v0.4.6
NewImageContent creates a new image content block with base64-encoded data.
func NewTextContent ¶ added in v0.4.6
NewTextContent creates a new text content block.
func NewToolUseContent ¶ added in v0.4.6
func NewToolUseContent(toolID, toolName string, toolInput json.RawMessage) Content
NewToolUseContent creates a new tool use content block.
type ErrorDetail ¶
ErrorDetail contains error details.
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
ErrorResponse represents the API's error response.
type ImageContent ¶ added in v0.4.6
type ImageContent struct {
Source ImageSource `json:"source"`
}
ImageContent represents an image content block.
type ImageSource ¶ added in v0.4.6
type ImageSource struct { Type string `json:"type"` // e.g., "base64" MediaType string `json:"media_type"` // e.g., "image/jpeg" Data string `json:"data"` }
ImageSource represents the source of an image, which can be a base64-encoded string.
type Message ¶ added in v0.4.6
type Message struct { Role string `json:"role"` Content json.RawMessage `json:"content"` // Can be a string or an array of content blocks }
Message represents a single message in the conversation.
type MessageRequest ¶ added in v0.4.6
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 ¶ added in v0.4.6
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.
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 Step ¶
type Step struct { Settings *settings.StepSettings // contains filtered or unexported fields }
func NewStep ¶ added in v0.2.24
func NewStep(settings *settings.StepSettings) *Step
func (*Step) AddPublishedTopic ¶ added in v0.4.1
func (*Step) Start ¶
func (csf *Step) Start( ctx context.Context, messages conversation.Conversation, ) (steps.StepResult[string], 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 Tool ¶ added in v0.4.6
type Tool struct { Name string `json:"name"` Description string `json:"description,omitempty"` InputSchema json.RawMessage `json:"input_schema"` // JSON schema for the tool input }
Tool represents a tool that the model can use.
type ToolUseContent ¶ added in v0.4.6
type ToolUseContent struct { ID string `json:"id"` Name string `json:"name"` Input json.RawMessage `json:"input"` // JSON structure for the tool input Result *string `json:"result,omitempty"` // Optional result of the tool use }
ToolUseContent represents a content block where the model uses a tool.