Documentation ¶
Index ¶
- Constants
- type ChatStream
- type ChatText
- type Client
- func (c *Client) AuthSession() (*gjson.Result, error)
- func (c *Client) GetChatStream(message string, args ...string) (*ChatStream, error)
- func (c *Client) GetChatText(message string, args ...string) (*ChatText, error)
- func (c *Client) GetModels() (*gjson.Result, []*http.Cookie, error)
- func (c *Client) WithModel(model string) *Client
- type MixMap
- type Option
- func WithAccessToken(accessToken string) Option
- func WithCookie(cookie string) Option
- func WithCookies(cookies []*http.Cookie) Option
- func WithDebug(debug bool) Option
- func WithModel(model string) Option
- func WithProxy(proxy string) Option
- func WithTimeout(timeout time.Duration) Option
- func WithUserAgent(userAgent string) Option
- type Options
Constants ¶
View Source
const ( BASE_URI = "https://chat.openai.com" AUTH_SESSION_URI = "https://chat.openai.com/api/auth/session" CONVERSATION_URI = "https://chat.openai.com/backend-api/conversation" GET_MODELS_URI = "https://chat.openai.com/backend-api/models" USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" EOF_TEXT = "[DONE]" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatStream ¶
ChatStream chat reply with sream
type ChatText ¶
type ChatText struct { ConversationID string `json:"conversation_id"` // conversation context id MessageID string `json:"message_id"` // current message id, can used as next chat's parent_message_id Content string `json:"content"` // text content Model string `json:"model"` // chat model CreatedAt int64 `json:"created_at"` // message create_time // contains filtered or unexported fields }
ChatText chat reply with text format
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a ChatGPT request client
func (*Client) AuthSession ¶ added in v1.4.0
AuthSession will check if session is expired and return a new accessToken
func (*Client) GetChatStream ¶ added in v1.1.0
func (c *Client) GetChatStream(message string, args ...string) (*ChatStream, error)
GetChatStream will return text stream
func (*Client) GetChatText ¶
GetChatText will return text message
type MixMap ¶
type MixMap = map[string]interface{}
MixMap is a type alias for map[string]interface{}
type Option ¶
type Option func(*Client)
Option is used to set custom option
func WithAccessToken ¶ added in v1.2.0
WithAccessToken is used to set accessToken
func WithCookie ¶ added in v1.2.0
WithCookie is used to set request cookies in header
func WithCookies ¶ added in v1.1.0
WithCookies is used to set request cookies
func WithTimeout ¶
WithTimeout is used to set request timeout
func WithUserAgent ¶ added in v1.1.0
WithUserAgent is used to set request user-agent
type Options ¶
type Options struct { // Debug is used to output debug message Debug bool // Timeout is used to end http request after timeout duration Timeout time.Duration // UserAgent is used for custom user-agent UserAgent string // Cookies is request cookies for each api Cookies []*http.Cookie // Cookie will set in request headers with string format Cookie string // Proxy is used to proxy request Proxy string // AccessToken is used to authorization AccessToken string // Model is the chat model Model string }
Options can set custom options for ChatGPT request client
Click to show internal directories.
Click to hide internal directories.