Versions in this module Expand all Collapse all v0 v0.10.1 Jul 18, 2024 Changes in this version + const ModelChatGPT4oMini v0.10.0 May 15, 2024 Changes in this version + const ModelChatGPT4o v0.9.0 Apr 11, 2024 Changes in this version + const ModelBaseDavinci + const ModelChatGPT35Turbo + const ModelChatGPT4 + const ModelChatGPT4Turbo + const ModelChatGPT4TurboPreview + const ModelChatGPT4With32k + const ModelDefaultChat + const ModelDefaultCompletion + const ModelEmbedding3Large + const ModelEmbedding3Small + const ModelEmbeddingAda002 + const ModelTextDavinci003 + func Chat(ctx context.Context, messages []Msg, opt Options, client *http.Client, ...) ([]Msg, Usage, error) + func ChatTokenCount(msgs []Msg, model string) int + func Complete(ctx context.Context, prompt string, opt Options, client *http.Client, ...) ([]Completion, Usage, error) + func Decode(tokens []int, model string) string + func Encode(text, model string) []int + func EncodeEnum(text, model string, f func(int)) + func MaxTokens(model string) int + func MsgTokenCount(msg Msg, model string) int + func TokenCount(text, model string) int + type Completion struct + FinishReason FinishReason + Text string + type Credentials struct + APIKey string + OrganizationID string + type Error struct + CallID string + Cause error + IsNetwork bool + Message string + PrintResponseBody bool + RawResponseBody []byte + StatusCode int + Type string + func (e *Error) Error() string + func (e *Error) Unwrap() error + type FinishReason string + const FinishReasonLength + const FinishReasonStop + type ForceFunctionCall struct + Name string + type FunctionCall struct + Arguments string + Name string + func (call *FunctionCall) UnmarshalArguments(out any) error + type Msg struct + Content string + FunctionCall *FunctionCall + Role Role + func AssistantMsg(content string) Msg + func DropChatHistoryIfNeeded(chat []Msg, fixedSuffixLen int, maxTokens int, model string) ([]Msg, int) + func FitChatContext(candidates []Msg, maxTokenCount int, model string) ([]Msg, int) + func StreamChat(ctx context.Context, messages []Msg, opt Options, client *http.Client, ...) (Msg, error) + func SystemMsg(content string) Msg + func UserMsg(content string) Msg + func (msg *Msg) UnmarshalCallArguments(out any) error + type Options struct + BestOf int + FrequencyPenalty float64 + FunctionCallMode any + Functions []any + MaxTokens int + Model string + N int + PresencePenalty float64 + Stop []string + Temperature float64 + ToolChoice any + Tools []any + TopP float64 + func DefaultChatOptions() Options + func DefaultCompleteOptions() Options + type Price int64 + func Cost(promptTokens, completionTokens int, model string) Price + func FineTuningCost(tokens int, model string) Price + func (p Price) String() string + type Role string + const Assistant + const System + const User + type Usage struct + CompletionTokens int + PromptTokens int + TotalTokens int + func ComputeEmbedding(ctx context.Context, input string, client *http.Client, creds Credentials) ([]float64, Usage, error)