Documentation ¶
Index ¶
- Constants
- Variables
- func GetPromptFromMessages(msg []*Message) string
- func GetPromptFromString(question string) string
- func GetPromptFromStringWithSystemMessage(system, human string) string
- type APIError
- type Client
- type ClientConfig
- type CompleteMetaData
- type CompleteRequest
- type CompleteResponse
- type CompletionStream
- type ErrorResponse
- type Message
- type RequestError
- type UserType
Constants ¶
View Source
const ( ClaudeV2Dot1 = "claude-2.1" ClaudeV2 = "claude-2" ClaudeV2Dot0 = "claude-2.0" ClaudeInstantV1 = "claude-instant-v1" ClaudeInstantV1Dot2 = "claude-instant-1.2" )
View Source
const ( MessageSenderSystem = "system" MessageSenderHuman = "\n\nHuman" MessageSenderAssistant = "\n\nAssistant" )
Variables ¶
View Source
var ( ErrCompleteStreamNotSupported = errors.New("streaming is not supported with this method, please use CreateCompletionStream") //nolint:lll ErrCompletePromptNotEmpty = errors.New("prompt is not empty") ErrCompleteMaxTokensToSmapleNotEmpty = errors.New("max_tokens_to_sample is not empty") )
View Source
var (
ErrTooManyEmptyStreamMessages = errors.New("stream has sent too many empty messages")
)
Functions ¶
func GetPromptFromMessages ¶
func GetPromptFromString ¶
Types ¶
type APIError ¶
type APIError struct { Message string `json:"message"` Type string `json:"type"` HTTPStatusCode int `json:"-"` }
APIError provides error information returned by the OpenAI API. InnerError struct is only valid for Azure OpenAI Service.
func (*APIError) UnmarshalJSON ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithConfig ¶
func NewClientWithConfig(config ClientConfig) *Client
func (*Client) CreateComplete ¶
func (c *Client) CreateComplete(ctx context.Context, request CompleteRequest) (response CompleteResponse, err error)
func (*Client) CreateCompleteStream ¶
func (c *Client) CreateCompleteStream( ctx context.Context, request CompleteRequest, ) (stream *CompletionStream, err error)
type ClientConfig ¶
type ClientConfig struct { ApiKey string Version string HTTPClient *http.Client EmptyMessagesLimit uint BaseURL string }
func DefaultConfig ¶
func DefaultConfig(apikey string) ClientConfig
type CompleteMetaData ¶
type CompleteMetaData struct {
UserId string `json:"user_id,omitempty"`
}
type CompleteRequest ¶
type CompleteRequest struct { Model string `json:"model"` Prompt string `json:"prompt"` MaxTokensToSample int `json:"max_tokens_to_sample"` StopSequences []string `json:"stop_sequences,omitempty"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` TopK int `json:"top_k,omitempty"` Metadata CompleteMetaData `json:"metadata,omitempty"` Stream bool `json:"stream,omitempty"` }
type CompleteResponse ¶
type CompletionStream ¶
type CompletionStream struct {
// contains filtered or unexported fields
}
type ErrorResponse ¶
type ErrorResponse struct {
Error *APIError `json:"error,omitempty"`
}
type RequestError ¶
RequestError provides informations about generic request errors.
func (*RequestError) Error ¶
func (e *RequestError) Error() string
func (*RequestError) Unwrap ¶
func (e *RequestError) Unwrap() error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.