chatgptuno

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

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 Author

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

type ChatUnoRequest

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

func NewRequests

func NewRequests(jar http.CookieJar) *ChatUnoRequest

func (*ChatUnoRequest) Do

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

func (*ChatUnoRequest) Get

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

func (*ChatUnoRequest) Patch

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

func (*ChatUnoRequest) Post

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

func (*ChatUnoRequest) SetBody

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

func (*ChatUnoRequest) SetCookie

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

func (*ChatUnoRequest) SetHeaders

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

func (*ChatUnoRequest) SetNoRedirects

func (r *ChatUnoRequest) SetNoRedirects()

func (*ChatUnoRequest) SetProxy

func (r *ChatUnoRequest) SetProxy(proxy string)

func (*ChatUnoRequest) SetTimeout

func (r *ChatUnoRequest) SetTimeout(timeout int)

type Config

type Config 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 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

type UnoBot

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

func NewChatGPTUnoBot

func NewChatGPTUnoBot(cfg *Config) *UnoBot

func (*UnoBot) Ask

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

func (*UnoBot) BaseURL

func (chat *UnoBot) BaseURL() string

Jump to

Keyboard shortcuts

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