chatgptuno

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	EmailAddr string
	Passwd    string
	Proxy     string
}

type Authenticator

type Authenticator struct {
	SessionToken string
	CsrfToken    string
	// contains filtered or unexported fields
}

OpenAI Authentication Reverse Engineered

func NewAuthenticator

func NewAuthenticator(cfg *AuthConfig) *Authenticator

func (*Authenticator) AccessToken

func (auth *Authenticator) AccessToken() string

func (*Authenticator) GetAccessToken

func (auth *Authenticator) GetAccessToken() error

Gets access token

func (*Authenticator) Loin

func (auth *Authenticator) Loin() error

type Author

type Author struct {
	Role string      `json:"role"`
	Name interface{} `json:"name,omitempty"`
}

type ChatGPTUnoBot

type ChatGPTUnoBot struct {
	// contains filtered or unexported fields
}

func NewChatGPTUnoBot

func NewChatGPTUnoBot(cfg *ChatGPTUnoConfig) *ChatGPTUnoBot

func (*ChatGPTUnoBot) Ask

func (chat *ChatGPTUnoBot) Ask(prompt, conversationId, parentId, model string, timeout int, callback func(chatRes *Response, err error)) (err error)

The standard ChatGPT model: text-davinci-002-render-sha Turbo (Default for free users)

func (*ChatGPTUnoBot) BaseURL

func (chat *ChatGPTUnoBot) BaseURL() string

func (*ChatGPTUnoBot) ClearConversations

func (chat *ChatGPTUnoBot) ClearConversations() error

func (*ChatGPTUnoBot) DeleteConversation

func (chat *ChatGPTUnoBot) DeleteConversation(conversationId string) error

func (*ChatGPTUnoBot) Init

func (chat *ChatGPTUnoBot) Init() error

func (*ChatGPTUnoBot) Login

func (chat *ChatGPTUnoBot) Login() error

func (*ChatGPTUnoBot) SetAccessToken

func (chat *ChatGPTUnoBot) SetAccessToken(accessToken string)

type ChatGPTUnoConfig

type ChatGPTUnoConfig struct {
	EmailAddr    string
	Passwd       string
	AccessToken  string // https://chat.openai.com/api/auth/session
	SessionToken string
	Proxy        string
	Model        string // model: text-davinci-002-render-paid text-davinci-002-render-sha
	BaseUrl      string
}

type ConversationNode

type ConversationNode struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*ConversationNode) ConversationId

func (node *ConversationNode) ConversationId() string

func (*ConversationNode) CurrentNode

func (node *ConversationNode) CurrentNode() string

func (*ConversationNode) SetConversationId

func (node *ConversationNode) SetConversationId(conversationId string)

func (*ConversationNode) SetConversationInfo

func (node *ConversationNode) SetConversationInfo(info gjson.Result)

func (*ConversationNode) SetCurrentNode

func (node *ConversationNode) SetCurrentNode(parentId string)

func (*ConversationNode) SetHistory

func (node *ConversationNode) SetHistory(history gjson.Result)

func (*ConversationNode) SetTitle

func (node *ConversationNode) SetTitle(title string)

func (*ConversationNode) Title

func (node *ConversationNode) Title() string

type FinishDetail

type FinishDetail struct {
	Type string `json:"type"`
	Stop string `json:"stop"`
}

type Mapping

type Mapping struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMapping

func NewMapping() *Mapping

func (*Mapping) GetConversationNode

func (mapping *Mapping) GetConversationNode(convId string) *ConversationNode

func (*Mapping) SetConversationNode

func (mapping *Mapping) SetConversationNode(convId string, node *ConversationNode)

type Message

type Message struct {
	ID         string     `json:"id"`
	Author     Author     `json:"author"`
	CreateTime float64    `json:"create_time"`
	UpdateTime *float64   `json:"update_time,omitempty"`
	Content    ResContent `json:"content"`
	EndTurn    bool       `json:"end_turn"`
	Weight     float64    `json:"weight"`
	Metadata   Metadata   `json:"metadata"`
	Recipient  string     `json:"recipient"`
}

type Metadata

type Metadata struct {
	MessageType   string       `json:"message_type"`
	ModelSlug     string       `json:"model_slug"`
	FinishDetails FinishDetail `json:"finish_details"`
}

type NextAction

type NextAction struct {
	Action          string          `json:"action"`
	Messages        []PromptMessage `json:"messages"`
	ConversationID  *string         `json:"conversation_id,omitempty"`
	ParentMessageID string          `json:"parent_message_id"`
	Model           interface{}     `json:"model"`
}

func NewNextAction

func NewNextAction(prompt string, conversationId, parentId string, model string) *NextAction

func (*NextAction) Byte

func (nextAction *NextAction) Byte() []byte

func (*NextAction) String

func (nextAction *NextAction) String() string

type PromptMessage

type PromptMessage struct {
	ID      string            `json:"id"`
	Role    string            `json:"role"`
	Author  map[string]string `json:"author"`
	Content ReqContent        `json:"content"`
}

type ReqContent

type ReqContent struct {
	ContentType string   `json:"content_type"`
	Parts       []string `json:"parts"`
}

type Requests

type Requests struct {
	// contains filtered or unexported fields
}

func NewRequests

func NewRequests(jar http.CookieJar) *Requests

func (*Requests) Do

func (r *Requests) Do(method, baseUrl string) (*http.Response, error)

func (*Requests) Get

func (r *Requests) Get(baseUrl string) (*http.Response, error)

func (*Requests) Patch

func (r *Requests) Patch(baseUrl string) (*http.Response, error)

func (*Requests) Post

func (r *Requests) Post(baseUrl string) (*http.Response, error)

func (*Requests) SetBody

func (r *Requests) SetBody(reader io.Reader)

func (*Requests) SetCookie

func (r *Requests) SetCookie(name, value string)

func (*Requests) SetHeaders

func (r *Requests) SetHeaders(headers http.Header)

func (*Requests) SetNoRedirects

func (r *Requests) SetNoRedirects()

func (*Requests) SetProxy

func (r *Requests) SetProxy(proxy string)

func (*Requests) SetTimeout

func (r *Requests) SetTimeout(timeout int)

type ResContent

type ResContent struct {
	ContentType string   `json:"content_type"`
	Parts       []string `json:"parts"`
}

type Response

type Response struct {
	Message        Message `json:"message"`
	ConversationID string  `json:"conversation_id"`
	Error          *string `json:"error"`
	Raw            string
}

func NewResponse

func NewResponse(text string) *Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL