anthropic

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIMessage

type APIMessage 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"`
	Usage        Usage          `json:"usage"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string, baseURL string) *Client

func (*Client) CreateMessage

func (c *Client) CreateMessage(ctx context.Context, req CreateRequest) (*APIMessage, error)

type ContentBlock

type ContentBlock struct {
	Type      string          `json:"type"`
	Text      string          `json:"text,omitempty"`
	ID        string          `json:"id,omitempty"`
	ToolUseID string          `json:"tool_use_id,omitempty"`
	Name      string          `json:"name,omitempty"`
	Input     json.RawMessage `json:"input,omitempty"`
	Content   interface{}     `json:"content,omitempty"`
}

type CreateRequest

type CreateRequest struct {
	Model     string         `json:"model"`
	Messages  []MessageParam `json:"messages"`
	MaxTokens int            `json:"max_tokens"`
	System    string         `json:"system,omitempty"`
	Tools     []Tool         `json:"tools,omitempty"`
}

type InputSchema

type InputSchema struct {
	Type       string                 `json:"type"`
	Properties map[string]interface{} `json:"properties"`
	Required   []string               `json:"required,omitempty"`
}

type Message

type Message struct {
	Msg APIMessage
}

Message implements the llm.Message interface

func (*Message) GetContent

func (m *Message) GetContent() string

func (*Message) GetRole

func (m *Message) GetRole() string

func (*Message) GetToolCalls

func (m *Message) GetToolCalls() []llm.ToolCall

func (*Message) GetToolResponseID

func (m *Message) GetToolResponseID() string

func (*Message) GetUsage

func (m *Message) GetUsage() (input int, output int)

func (*Message) IsToolResponse

func (m *Message) IsToolResponse() bool

type MessageParam

type MessageParam struct {
	Role    string         `json:"role"`
	Content []ContentBlock `json:"content"`
}

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(apiKey, baseURL, model, systemPrompt string) *Provider

func (*Provider) CreateMessage

func (p *Provider) CreateMessage(
	ctx context.Context,
	prompt string,
	messages []llm.Message,
	tools []llm.Tool,
) (llm.Message, error)

func (*Provider) CreateToolResponse

func (p *Provider) CreateToolResponse(
	toolCallID string,
	content interface{},
) (llm.Message, error)

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) SupportsTools

func (p *Provider) SupportsTools() bool

type Tool

type Tool struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	InputSchema InputSchema `json:"input_schema"`
}

type ToolCall

type ToolCall struct {
	// contains filtered or unexported fields
}

ToolCall implements the llm.ToolCall interface

func (*ToolCall) GetArguments

func (t *ToolCall) GetArguments() map[string]interface{}

func (*ToolCall) GetID

func (t *ToolCall) GetID() string

func (*ToolCall) GetName

func (t *ToolCall) GetName() string

type Usage

type Usage struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL