Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallChatGPT ¶
func CallChatGPT(cfg Config, inputMessages []ChatMessage, stream bool) (<-chan string, error)
func GetCommands ¶
GetCommands if enable, register the openai commands
Types ¶
type ChatChoice ¶
type ChatChoice struct { Index int `json:"index"` Message ChatMessage `json:"message"` FinishReason string `json:"finish_reason"` Delta ChatMessage `json:"delta"` }
type ChatMessage ¶
type ChatRequest ¶
type ChatRequest struct { Model string `json:"model"` Messages []ChatMessage `json:"messages"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` N int `json:"n,omitempty"` Stop []string `json:"stop,omitempty"` Stream bool `json:"stream,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` PresencePenalty float32 `json:"presence_penalty,omitempty"` FrequencyPenalty float32 `json:"frequency_penalty,omitempty"` LogitBias map[string]int `json:"logit_bias,omitempty"` User string `json:"user,omitempty"` }
https://platform.openai.com/docs/guides/chat/chat-completions-beta https://platform.openai.com/docs/api-reference/chat
type ChatResponse ¶
type ChatResponse struct { ID string `json:"id"` Object string `json:"object"` Created int64 `json:"created"` Choices []ChatChoice `json:"choices"` Error struct { Message string `json:"message"` Type string `json:"type"` } `json:"error"` Usage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } `json:"usage"` }
func (ChatResponse) GetDelta ¶
func (r ChatResponse) GetDelta() ChatMessage
func (ChatResponse) GetError ¶
func (r ChatResponse) GetError() error
func (ChatResponse) GetMessage ¶
func (r ChatResponse) GetMessage() ChatMessage
type Config ¶
type Config struct { APIKey string `mapstructure:"api_key"` APIHost string `mapstructure:"api_host"` InitialSystemMessage string `mapstructure:"initial_system_message"` Model string `mapstructure:"model"` Temperature float32 `mapstructure:"temperature"` UpdateInterval time.Duration `mapstructure:"update_interval"` }
Config configuration: API key to do API calls
Click to show internal directories.
Click to hide internal directories.