resp

package
v2.0.0-...-288f5f8 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Type    string `json:"type"`
	Message string `json:"message"`
	Code    int    `json:"-"` // HTTP status code, please do not parse
}

func Error

func Error(code int, v []byte) (*ErrorResponse, error)

func (*ErrorResponse) Err

func (e *ErrorResponse) Err() error

Return an error object

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Example:

func E() error {
	return &ErrorResponse{}
}

func (*ErrorResponse) IsStatusCode

func (e *ErrorResponse) IsStatusCode(code int) bool

Check if the HTTP status code matches the entered status code

func (*ErrorResponse) StatusCode

func (e *ErrorResponse) StatusCode() int

Return HTTP status code

type MetaData

type MetaData struct {
	UserID string `json:"user_id,omitempty"` // (optional) A uuid, hash value, or other external identifier for the user who is associated with the request. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.
}

type R

type R struct {
	Error *ErrorResponse `json:"error"`
}

type Response

type Response struct {
	Completion string `json:"completion"`          // The resulting completion up to and excluding the stop sequences.
	StopReason string `json:"stop_reason"`         // The reason we stopped sampling, either if we reached one of your provided , or if we exceeded `.stop_sequencestop_sequencesmax_tokensmax_tokens_to_sample`
	Stop       string `json:"stop"`                // If the is , this contains the actual stop sequence (of the list passed-in) that was `seenstop_reasonstop_sequencestop_sequences`
	LogID      string `json:"log_id"`              // The ID of the log that generated the response
	Exception  string `json:"exception,omitempty"` // exception
	Model      string `json:"model"`               // Model
	Truncated  bool   `json:"truncated"`           // truncated
}

func (Response) String

func (resp Response) String() string

type Sender

type Sender struct {
	Prompt        string   `json:"prompt"`                   // (required) The prompt you want Claude to complete. For proper response generation you will most likely want to format your prompt as follows:See [our comments on prompts](https://console.anthropic.com/docs/prompt-design#what-is-a-prompt) for more context.
	Model         string   `json:"model"`                    // (required) As we improve Claude, we develop new versions of it that you can query. This controls which version of Claude answers your request
	StopSequences []string `json:"stop_sequences,omitempty"` // (optional) A list of strings upon which to stop generating. You probably want , as that's the cue for the next turn in the dialog agent. Our client libraries provide a constant for this value (see examples below["\n\nHuman:"])
	Stream        bool     `json:"stream"`                   // (optional) Amount of randomness injected into the response. Ranges from 0 to 1. Use temp closer to 0 for analytical / multiple choice, and temp closer to 1 for creative and generative tasks.
	Temperature   float64  `json:"temperature,omitempty"`    // (required) Amount of randomness injected into the response. Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical / multiple choice, and closer to 1 for creative and generative tasks.
	TopK          float64  `json:"top_k,omitempty"`          // (optional) Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. Defaults to -1, which disables it.
	TopP          uint     `json:"top_p,omitempty"`          // (optional) Does nucleus sampling, in which we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by . Defaults to -1, which disables it. Note that you should either alter or , but not both.`top_ptemperaturetop_p“
	MaxToken      uint     `json:"max_tokens_to_sample"`     // (required) A maximum number of tokens to generate before stopping.
	MetaData      MetaData `json:"metadata,omitempty"`       // (optional) An object describing metadata about the request.
}

func (*Sender) Build

func (s *Sender) Build(next string, d *data.MessageModule) error

func (*Sender) Set

func (s *Sender) Set(d *data.MessageModule) error

func (*Sender) SetUserID

func (s *Sender) SetUserID(userID string)

A uuid, hash value, or other external identifier for the user who is associated with the request. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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