anthropic

package module
v0.0.0-...-8577a82 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 5 Imported by: 0

README

anthropic-go

CI

NOTE: archived due to release of the official SDK https://github.com/anthropics/anthropic-sdk-go.

Anthropic API client for Go.

Installation

go get -u github.com/alexprogrammr/anthropic-go

Resources

License

Licensed under The MIT License, see LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(httpClient HTTPClient, apiKey string) *Client

func (*Client) CreateMessage

func (c *Client) CreateMessage(ctx context.Context, req *MessageRequest) (*MessageResponse, error)

type Content

type Content struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Message

type Message struct {
	Role    Role   `json:"role"`
	Content string `json:"content"`
}

type MessageRequest

type MessageRequest struct {
	Model       Model     `json:"model"`
	Messages    []Message `json:"messages"`
	MaxTokens   int       `json:"max_tokens"`
	System      string    `json:"system,omitempty"`
	Temperature float64   `json:"temperature,omitempty"`
	Metadata    Metadata  `json:"metadata,omitempty"`
}

type MessageResponse

type MessageResponse struct {
	Id      string    `json:"id"`
	Role    Role      `json:"role"`
	Content []Content `json:"content"`
	Model   Model     `json:"model"`
	Usage   Usage     `json:"usage"`
}

type Metadata

type Metadata struct {
	UserId string `json:"user_id,omitempty"`
}

type Model

type Model string
const (
	ModelHaiku  Model = "claude-3-haiku-20240307"
	ModelSonnet Model = "claude-3-sonnet-20240229"
	ModelOpus   Model = "claude-3-opus-20240229"
)

type Role

type Role string
const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
)

type Usage

type Usage struct {
	Input  int `json:"input_tokens"`
	Output int `json:"output_tokens"`
}

Jump to

Keyboard shortcuts

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