Versions in this module Expand all Collapse all v0 v0.1.1 Mar 2, 2024 v0.1.0 Feb 29, 2024 Changes in this version + const DefaultCompletionModelPath + var ErrAccessTokenCode = errors.New("get access_token API returned unexpected status code") + var ErrCompletionCode = errors.New("completion API returned unexpected status code") + var ErrEmbeddingCode = errors.New("embedding API returned unexpected status code") + var ErrEmptyResponse = errors.New("empty response") + var ErrNotSetAuth = errors.New("both accessToken and apiKey secretKey are not set") + type ChatChoice struct + FinishReason string + Index int + Message ChatMessage + type ChatMessage struct + Content string + FunctionCall *schema.FunctionCall + Name string + Role string + type ChatRequest struct + FrequencyPenalty float64 + FunctionCallBehavior FunctionCallBehavior + Functions []FunctionDefinition + MaxTokens int + Messages []*ChatMessage + Model string + N int + PresencePenalty float64 + StopWords []string + Stream bool + StreamingFunc func(ctx context.Context, chunk []byte) error + System string + Temperature float64 + TopP float64 + type ChatResponse struct + Created int + FunctionCall *FunctionCallRes + ID string + IsTruncated bool + NeedClearHistory bool + Object string + Result string + Usage struct{ ... } + type ChatUsage struct + CompletionTokens int + PromptTokens int + TotalTokens int + type Client struct + Model string + ModelPath ModelPath + func New(opts ...Option) (*Client, error) + func (c *Client) CreateChat(ctx context.Context, r *ChatRequest) (*ChatResponse, error) + func (c *Client) CreateCompletion(ctx context.Context, modelPath ModelPath, r *CompletionRequest) (*Completion, error) + func (c *Client) CreateEmbedding(ctx context.Context, texts []string) (*EmbeddingResponse, error) + type Completion struct + Created int + ErrorCode int + ErrorMsg string + ID string + IsEnd bool + IsTruncated bool + NeedClearHistory bool + Object string + Result string + SentenceID int + Usage struct{ ... } + type CompletionRequest struct + Messages []Message + PenaltyScore float64 + Stream bool + StreamingFunc func(ctx context.Context, chunk []byte) error + Temperature float64 + TopP float64 + UserID string + type Doer interface + Do func(req *http.Request) (*http.Response, error) + type EmbeddingResponse struct + Created int + Data []struct{ ... } + ErrorCode int + ErrorMsg string + ID string + Object string + Usage struct{ ... } + type FunctionCall struct + Arguments string + Name string + type FunctionCallBehavior string + const FunctionCallBehaviorAuto + const FunctionCallBehaviorNone + const FunctionCallBehaviorUnspecified + type FunctionCallRes struct + Arguments string + Name string + Thoughts string + type FunctionDefinition struct + Description string + Name string + Parameters any + type Message struct + Content string + Role string + type ModelPath string + type Option func(*Client) error + func WithAKSK(apiKey, secretKey string) Option + func WithAccessToken(accessToken string) Option + func WithHTTPClient(client Doer) Option + type StreamedChatResponsePayload struct + Created int + FunctionCall *FunctionCallRes + ID string + IsEnd bool + IsTruncated bool + NeedClearHistory bool + Object string + Result string + SentenceID int + Usage struct{ ... }