claude

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsClaudeEngine

func IsClaudeEngine(engine string) bool

Types

type Client

type Client struct {
	APIKey     string
	APIVersion string
	BaseURL    string
	// contains filtered or unexported fields
}

Client represents the Claude API client.

func NewClient

func NewClient(apiKey string, baseURL string, apiVersion ...string) *Client

NewClient initializes and returns a new API client.

func (*Client) Complete

func (c *Client) Complete(req *Request) (*SuccessfulResponse, error)

Complete sends a completion request and returns the response.

func (*Client) StreamComplete

func (c *Client) StreamComplete(req *Request) (<-chan Event, error)

type ErrorDetail

type ErrorDetail struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

ErrorDetail contains error details.

type ErrorResponse

type ErrorResponse struct {
	Error ErrorDetail `json:"error"`
}

ErrorResponse represents the API's error response.

type Event

type Event struct {
	Data  string
	Event string
	ID    string
	Retry int
}

Event represents a server-sent event.

type Metadata

type Metadata struct {
}

Metadata represents the metadata object.

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 (csf *Step) AddPublishedTopic(publisher message.Publisher, topic string) error

func (*Step) Interrupt added in v0.2.24

func (csf *Step) Interrupt()

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.

Jump to

Keyboard shortcuts

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