edgegpt

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DELIMITER = "\x1e"
View Source
var HEADERS = map[string]string{
	"accept":                      "application/json",
	"accept-language":             "en-US,en;q=0.9",
	"content-type":                "application/json",
	"sec-ch-ua":                   `"Not_A Brand";v="99", "Microsoft Edge";v="110", "Chromium";v="110"`,
	"sec-ch-ua-arch":              `"x86"`,
	"sec-ch-ua-bitness":           `"64"`,
	"sec-ch-ua-full-version":      `"109.0.1518.78"`,
	"sec-ch-ua-full-version-list": `"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"`,
	"sec-ch-ua-mobile":            "?0",
	"sec-ch-ua-model":             "",
	"sec-ch-ua-platform":          `"Windows"`,
	"sec-ch-ua-platform-version":  `"15.0.0"`,
	"sec-fetch-dest":              "empty",
	"sec-fetch-mode":              "cors",
	"sec-fetch-site":              "same-origin",
	"x-ms-client-request-id":      GetUuidV4(),
	"x-ms-useragent":              "azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/Win32",
	"Referer":                     "https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx",
	"Referrer-Policy":             "origin-when-cross-origin",
	"x-forwarded-for":             GetRandomIp(),
}

HEADERS http.Header{}

View Source
var HEADERS_INIT_CONVER = map[string]string{
	"authority":                   "edgeservices.bing.com",
	"accept":                      "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
	"accept-language":             "en-US,en;q=0.9",
	"cache-control":               "max-age=0",
	"sec-ch-ua":                   `"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"`,
	"sec-ch-ua-arch":              `"x86"`,
	"sec-ch-ua-bitness":           `"64"`,
	"sec-ch-ua-full-version":      `"110.0.1587.69"`,
	"sec-ch-ua-full-version-list": `"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"`,
	"sec-ch-ua-mobile":            "?0",
	"sec-ch-ua-model":             `""`,
	"sec-ch-ua-platform":          `"Windows"`,
	"sec-ch-ua-platform-version":  `"15.0.0"`,
	"sec-fetch-dest":              "document",
	"sec-fetch-mode":              "navigate",
	"sec-fetch-site":              "none",
	"sec-fetch-user":              "?1",
	"upgrade-insecure-requests":   "1",
	"user-agent":                  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.69",
	"x-edge-shopping-flag":        "1",
	"x-forwarded-for":             "1.1.1.1",
}

Functions

func GetRandomHex

func GetRandomHex(n int, allowedChars ...[]rune) string

GetRandomHex Returns random hex string

func GetRandomIp

func GetRandomIp() string

GetRandomIp Generate random IP between range 13.104.0.0/14

func GetUuidV4

func GetUuidV4() string

Types

type Answer

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

func NewAnswer

func NewAnswer(msg string) *Answer

func (*Answer) IsDone

func (answer *Answer) IsDone() bool

func (*Answer) MaxNumUserMessages

func (answer *Answer) MaxNumUserMessages() int64

func (*Answer) NumUserMessages

func (answer *Answer) NumUserMessages() int64

func (*Answer) Raw

func (answer *Answer) Raw() string

func (*Answer) SetDone

func (answer *Answer) SetDone()

func (*Answer) SuggestedRes

func (answer *Answer) SuggestedRes() []SuggestedResponses

func (*Answer) Text

func (answer *Answer) Text() string

func (*Answer) Type

func (answer *Answer) Type() int64

type ChatBot

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

ChatBot Combines everything to make it seamless

func NewChatBot

func NewChatBot(cookiePath string, cookies []map[string]interface{}, proxy string) *ChatBot

func (*ChatBot) Ask

func (bot *ChatBot) Ask(prompt string, conversationStyle ConversationStyle, callback func(answer *Answer)) error

func (*ChatBot) Close

func (bot *ChatBot) Close() error

func (*ChatBot) Init

func (bot *ChatBot) Init() error

func (*ChatBot) Reset

func (bot *ChatBot) Reset() error

Reset the conversation

type ChatHub

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

ChatHub Chat API

func NewChatHub

func NewChatHub(addr, path string, conversation *Conversation) *ChatHub

func (*ChatHub) Close

func (chathub *ChatHub) Close() error

type ChatHubRequest

type ChatHubRequest struct {
	Struct                map[string]interface{}
	ConversationSignature string
	ClientId              string
	ConversationId        string
	InvocationId          int
}

ChatHubRequest Request object for ChatHub

func NewChatHubRequest

func NewChatHubRequest(conversationSignature, clientId, conversationId string, invocationId int) *ChatHubRequest

func (*ChatHubRequest) Update

func (req *ChatHubRequest) Update(prompt string, conversation_style ConversationStyle, options ...string)

Update Updates request object

type Conversation

type Conversation struct {
	Struct  map[string]interface{}
	Session *resty.Request
	// contains filtered or unexported fields
}

Conversation API

func NewConversation

func NewConversation(cookiePath string, cookies []map[string]interface{}, proxy string) *Conversation

func (*Conversation) Init

func (con *Conversation) Init() error

type ConversationStyle

type ConversationStyle string
const (
	Creative ConversationStyle = "h3relaxedimg"
	Balanced ConversationStyle = "galileo"
	Precise  ConversationStyle = "h3precise"
)

type SuggestedResponses

type SuggestedResponses struct {
	Text        string    `json:"text"`
	Author      string    `json:"author"`
	CreatedAt   time.Time `json:"createdAt"`
	Timestamp   time.Time `json:"timestamp"`
	MessageID   string    `json:"messageId"`
	MessageType string    `json:"messageType"`
	Offense     string    `json:"offense"`
	Feedback    struct {
		Tag       interface{} `json:"tag"`
		UpdatedOn interface{} `json:"updatedOn"`
		Type      string      `json:"type"`
	} `json:"feedback"`
	ContentOrigin string      `json:"contentOrigin"`
	Privacy       interface{} `json:"privacy"`
}

Jump to

Keyboard shortcuts

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