edge

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 24 Imported by: 1

README

edge-api

Golang 的 NewBing 逆向API库

使用方式请参考 examples

Documentation

Index

Constants

View Source
const (
	//DefaultCreate  = "https://www.bing.com/turing/conversation/create"
	DefaultCreate  = "https://copilot.microsoft.com/turing/conversation/create"
	DefaultChatHub = "wss://sydney.bing.com/sydney/ChatHub"

	ModelCreative = "Creative"
	ModelBalanced = "Balanced"
	ModelPrecise  = "Precise"
	ModelSydney   = "Sydney"

	PluginShop      = "Shop"
	PluginInstacart = "Instacart"
	PluginOpenTable = "OpenTable"
	PluginKlarna    = "Klarna"
	PluginSearch    = "Search"
	PluginKayak     = "Kayak"
)

Variables

View Source
var H = map[string]string{
	"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/120.0.0.0",
}
View Source
var Version = "1.1482.6"

Functions

func LoadEnvVar added in v1.0.3

func LoadEnvVar(key, defaultValue string) string

Types

type Chat

type Chat struct {
	Options
	// contains filtered or unexported fields
}

func New

func New(opts *Options) Chat

创建会话实例

func (*Chat) Delete added in v1.0.1

func (c *Chat) Delete() error

删除会话

func (*Chat) GetSession added in v1.0.3

func (c *Chat) GetSession() Conversation

func (*Chat) LoadImage added in v1.0.3

func (c *Chat) LoadImage(file string) (*KBlob, error)

func (*Chat) LoadPlugins added in v1.0.3

func (c *Chat) LoadPlugins(names ...string) (plugins []string, err error)

获取bing插件ID。需要包含Search,否则无效。 可用插件 Shop 、Instacart、OpenTable、Klarna、Search、Kayak

func (*Chat) Reply

func (c *Chat) Reply(ctx context.Context, prompt string, image *KBlob, previousMessages []ChatMessage) (chan ChatResponse, error)

对话并回复

ctx Context 控制器,promp string 当前对话,image KBlob 图片信息,previousMessages []map[string]string 历史记录

previousMessages:

[
	{
		"author": "user",
		"text": "hi"
	},
	{
		"author": "bot",
		"text": "Hello, this is Bing. I am a chat mode ..."
	}
]

type ChatError added in v1.0.3

type ChatError struct {
	Action  string
	Message error
}

func (ChatError) Error added in v1.0.3

func (c ChatError) Error() string

type ChatMessage added in v1.0.3

type ChatMessage = map[string]string

type ChatResponse added in v1.0.3

type ChatResponse struct {
	Text    string
	Error   *ChatError
	RawData []byte

	T *struct {
		Max  int
		Used int
	}
}

type Conversation

type Conversation struct {
	ConversationId string `json:"conversationId"`
	ClientId       string `json:"clientId"`

	Result struct {
		Value   string      `json:"value"`
		Message interface{} `json:"message"`
	} `json:"result"`
	// contains filtered or unexported fields
}

type KBlob added in v1.0.3

type KBlob struct {
	BlobId          string `json:"blobId"`
	ProcessedBlobId string `json:"processedBlobId"`
}

type Options

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

func NewDefaultOptions added in v1.0.2

func NewDefaultOptions(cookie, middle string) (*Options, error)

func (*Options) KievAuth added in v1.0.3

func (opts *Options) KievAuth(kievRPSSecAuth, rwBf string) *Options

func (*Options) Model

func (opts *Options) Model(model string) *Options

设置对话模式

func (*Options) Notebook added in v1.0.3

func (opts *Options) Notebook(flag bool) *Options

文档模式

func (*Options) Plugins added in v1.0.3

func (opts *Options) Plugins(plugins ...string) *Options

插件

func (*Options) Proxies added in v1.0.3

func (opts *Options) Proxies(proxies string) *Options

设置本地代理地址

func (*Options) Temperature added in v1.0.2

func (opts *Options) Temperature(temperature float32) *Options

温度调节 0.0~1.0, Sydney 模式生效

func (*Options) TopicToE added in v1.0.3

func (opts *Options) TopicToE(flag bool) *Options

topic警告是否作为错误返回,默认为false

Jump to

Keyboard shortcuts

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