anthropic

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

Anthropic API Client

This package provides a client for the Anthropic API, which is used to interact with the Claude LLM.

References:

Documentation

Overview

anthropic implements an API client for anthropic (https://docs.anthropic.com/en/api/getting-started)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(schema.MessageChoice)

Stream response, which is called with each delta in the conversation or nil if the conversation is complete

type Client

type Client struct {
	*client.Client
}

func New

func New(ApiKey string, opts ...client.ClientOpt) (*Client, error)

Create a new client

func (*Client) Messages

func (c *Client) Messages(ctx context.Context, messages []*schema.Message, opts ...Opt) ([]*schema.Content, error)

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. Use a context to cancel the request, instead of the client-related timeout.

type Opt

type Opt func(*options) error

Opt is a function which can be used to set options on a request

func OptMaxTokens

func OptMaxTokens(v int) Opt

Maximum number of tokens to generate in the reply

func OptModel

func OptModel(v string) Opt

Set the model

func OptStop added in v1.0.6

func OptStop(value ...string) Opt

Custom text sequences that will cause the model to stop generating.

func OptStream

func OptStream(fn Callback) Opt

Set streaming response

func OptSystem

func OptSystem(prompt string) Opt

Set system prompt

func OptTemperature

func OptTemperature(v float32) Opt

Amount of randomness injected into the response.

func OptTool

func OptTool(value ...*schema.Tool) Opt

Add a tool

func OptUser

func OptUser(v string) Opt

An external identifier for the user who is associated with the request.

type Usage

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

Token usage for messages

Jump to

Keyboard shortcuts

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