chatgpt

package
v0.0.0-...-072871e Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Credits to https://github.com/rodjunger/chatgptauth

Credits to https://github.com/rodjunger/chatgptauth

Credits to https://github.com/rodjunger/chatgptauth

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	EmailAddress string
	Password     string
	// contains filtered or unexported fields
}

Auth contains the state for an authenticated user's session.

func NewAuthClient

func NewAuthClient(email, password, proxy string, logger *zerolog.Logger) (auth *Auth, err error)

NewAuthClient creates a new authenticator, performing valiation on the parameters. If the logger pointer is nil, a NOOP logger is used.

func (*Auth) Begin

func (a *Auth) Begin() (captcha Captcha, err error)

Begin starts the authentication process, up to the point where a captcha can be presented or not. if there's no captcha, Finish() can be called with an empty captcha answer, if not, the captcha must be solved and passed to finish. the Captcha type has some helpers to convert the captcha to a png or write it to a file (as png too)

func (*Auth) Finish

func (a *Auth) Finish(captcha string) (cred *Credentials, err error)

type AuthSessionResponse

type AuthSessionResponse struct {
	Expires     time.Time `json:"expires"`
	AccessToken string    `json:"accessToken"`
}

type Captcha

type Captcha string

func (Captcha) Available

func (c Captcha) Available() bool

Simple helper to check if there's a captcha

func (Captcha) ToFile

func (c Captcha) ToFile(path string) error

ToFile converts the captcha to png and writes in to disk

func (Captcha) ToPng

func (c Captcha) ToPng() ([]byte, error)

toPng returns the captcha converted to png in []byte format

type ChatGPT

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

func NewChatGPT

func NewChatGPT(email, password, sessionToken, userAgent, cfClearance string) *ChatGPT

func NewChatGPTWithClient

func NewChatGPTWithClient(email, password, sessionToken, userAgent, cfClearance string, httpClient *http.Client) *ChatGPT

func (*ChatGPT) NewConversation

func (c *ChatGPT) NewConversation(conversationId string) *Conversation

type Content

type Content struct {
	ContentType string   `json:"content_type,omitempty"`
	Parts       []string `json:"parts,omitempty"`
}

type Conversation

type Conversation struct {
	ChatGPT         *ChatGPT
	ConversationId  string
	ParentMessageId string
}

func (*Conversation) SendMessage

func (c *Conversation) SendMessage(ctx context.Context, message string) (string, error)

type ConversationRequest

type ConversationRequest struct {
	Action          string    `json:"action,omitempty"`
	Messages        []Message `json:"messages,omitempty"`
	ConversationID  string    `json:"conversation_id,omitempty"`
	ParentMessageID string    `json:"parent_message_id,omitempty"`
	Model           string    `json:"model,omitempty"`
}

type ConversationResponse

type ConversationResponse struct {
	Message        Message `json:"message"`
	ConversationID string  `json:"conversation_id"`
	Error          string  `json:"error"`
}

type Credentials

type Credentials struct {
	AccessToken string    `json:"accessToken"`
	ExpiresAt   time.Time `json:"expires"`
}

type Message

type Message struct {
	ID      string  `json:"id,omitempty"`
	Role    string  `json:"role,omitempty"`
	Content Content `json:"content,omitempty"`
}

type Task

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

func NewTask

func NewTask(id string, content string, timeout time.Duration, handler TaskHandler) *Task

type TaskHandler

type TaskHandler func(string, error)

type TaskManager

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

func NewTaskManager

func NewTaskManager(email, password, sessionToken, userAgent, cfClearance string) *TaskManager

func (*TaskManager) SendTask

func (tm *TaskManager) SendTask(task *Task)

Jump to

Keyboard shortcuts

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