Documentation ¶
Index ¶
- Constants
- func ChatCompletion(params *ChatCompletionParams, callback CreateChatCompletionCallbackFunc) (err error)
- type ChatCompletionParams
- type CreateChatCompletionCallbackFunc
- type OpenaiClient
- type RequestChatParams
- type RequestChatParamsMessageItem
- type RequestChatParamsMessages
- type ResponseChat
- type ResponseChatChoices
- type ResponseChatChoicesItem
- type ResponseChatChoicesItemMessage
- type ResponseChatError
- type ResponseChatErrorData
- type ResponseChatUsage
Constants ¶
View Source
const ( ModelGPT35Turbo = "gpt-3.5-turbo" ModelGPT35Turbo16K = "gpt-3.5-turbo-16k" ModelGPT4 = "gpt-4" ModelGPT432K = "gpt-4-32k" )
View Source
const ApiUrl = "https://api.openai.com/v1/chat/completions"
Variables ¶
This section is empty.
Functions ¶
func ChatCompletion ¶
func ChatCompletion(params *ChatCompletionParams, callback CreateChatCompletionCallbackFunc) (err error)
Types ¶
type ChatCompletionParams ¶
type ChatCompletionParams struct { Model string Messages RequestChatParamsMessages }
type CreateChatCompletionCallbackFunc ¶
type CreateChatCompletionCallbackFunc func(originContent string, contentObj *ResponseChat) error
type OpenaiClient ¶
type OpenaiClient struct { }
OpenaiClient openai推送
func (*OpenaiClient) GetConfig ¶
func (c *OpenaiClient) GetConfig() (configData *entity.ConfigOpenai, err error)
GetConfig 获取配置
type RequestChatParams ¶
type RequestChatParams struct { Model string `json:"model"` Messages RequestChatParamsMessages `json:"messages"` MaxTokens int `json:"max_tokens"` Stream bool `json:"stream"` }
type RequestChatParamsMessages ¶
type RequestChatParamsMessages []*RequestChatParamsMessageItem
type ResponseChat ¶
type ResponseChat struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` Choices ResponseChatChoices `json:"choices"` Usage *ResponseChatUsage `json:"usage"` }
type ResponseChatChoices ¶
type ResponseChatChoices []*ResponseChatChoicesItem
type ResponseChatChoicesItem ¶
type ResponseChatChoicesItem struct { Index int `json:"index"` Message *ResponseChatChoicesItemMessage `json:"message"` Delta *ResponseChatChoicesItemMessage `json:"delta"` FinishReason string `json:"finish_reason"` }
type ResponseChatError ¶
type ResponseChatError struct {
Error *ResponseChatErrorData `json:"error"`
}
type ResponseChatErrorData ¶
type ResponseChatUsage ¶
Click to show internal directories.
Click to hide internal directories.