Documentation ¶
Index ¶
- Constants
- type ChatStream
- type ChatText
- type Client
- type MixMap
- type Option
- func WithAccessToken(accessToken string) Option
- func WithBaseURI(baseURI 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://freechat.xyhelper.cn" // AUTH_SESSION_URI = "https://chat.openai.com/api/auth/session" // CONVERSATION_URI = "https://chat.openai.lidong.xin/backend-api/conversation" 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 // conversation context id MessageID string // current message id, can used as next chat's parent_message_id Content string // text content // 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) GetChatStream ¶
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 ¶
WithAccessToken is used to set accessToken
func WithCookie ¶
WithCookie is used to set request cookies in header
func WithCookies ¶
WithCookies is used to set request cookies
func WithTimeout ¶
WithTimeout is used to set request timeout
func WithUserAgent ¶
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.