sydney

package
v0.0.0-...-bcb1c7f Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeSearchQuery        = "search_query"
	MessageTypeSearchResult       = "search_result"
	MessageTypeLoading            = "loading"
	MessageTypeGenerativeImage    = "generative_image"
	MessageTypeGenerativeMusic    = "generative_music"
	MessageTypeExecutingTask      = "executing_task"
	MessageTypeOpenAPICall        = "openapi_call"
	MessageTypeGeneratedCode      = "generated_code"
	MessageTypeResolvingCaptcha   = "resolving_captcha"
	MessageTypeMessageText        = "message"
	MessageTypeSuggestedResponses = "suggested_responses"
	MessageTypeError              = "error"
)
View Source
const ImageGeneratorContext = `` /* 404-byte string literal not displayed */

Variables

View Source
var (
	ErrMissingPrompt     = errors.New("user prompt is missing (last message is not sent by user)")
	FinishReasonStop     = "stop"
	FinishReasonLength   = "length"
	MessageRoleUser      = "user"
	MessageRoleAssistant = "assistant"
	MessageRoleSystem    = "system"
)
View Source
var (
	ErrMessageRevoke   = errors.New("message revoke detected")
	ErrMessageFiltered = errors.New("message triggered the Bing filter")
)
View Source
var BingAllowedFileExtensions = []string{
	"rtf",
	"txt",
	"py",
	"ipynb",
	"js",
	"jsx",
	"html",
	"css",
	"java",
	"cs",
	"php",
	"c",
	"cpp",
	"cxx",
	"h",
	"hpp",
	"rs",
	"R",
	"Rmd",
	"swift",
	"go",
	"rb",
	"kt",
	"kts",
	"ts",
	"tsx",
	"m",
	"scala",
	"rs",
	"dart",
	"lua",
	"pl",
	"pm",
	"t",
	"sh",
	"bash",
	"zsh",
	"csv",
	"log",
	"ini",
	"config",
	"json",
	"yaml",
	"yml",
	"toml",
	"lua",
	"sql",
	"md",
	"coffee",
	"tex",
	"latex",
	"pdf",
	"docx",
	"xlsx",
	"pptx",
	"html",
	"wav",
}
View Source
var PluginList = []Plugin{
	{
		Name:        "Suno",
		OptionsSets: []string{"014CB21D"},
		ArgumentPlugin: ArgumentPlugin{
			Id:       "c310c353-b9f0-4d76-ab0d-1dd5e979cf68",
			Category: 1,
		},
	},
}

Functions

func ParseOpenAIMessageContent

func ParseOpenAIMessageContent(content interface{}) (text, imageUrl string)

Types

type Argument

type Argument struct {
	OptionsSets           []string          `json:"optionsSets"`
	Source                string            `json:"source"`
	AllowedMessageTypes   []string          `json:"allowedMessageTypes"`
	SliceIds              []string          `json:"sliceIds"`
	Verbosity             string            `json:"verbosity"`
	Scenario              string            `json:"scenario"`
	Plugins               []ArgumentPlugin  `json:"plugins"`
	TraceId               string            `json:"traceId"`
	RequestId             string            `json:"requestId"`
	IsStartOfSession      bool              `json:"isStartOfSession"`
	Message               ArgumentMessage   `json:"message"`
	Tone                  string            `json:"tone"`
	ConversationSignature any               `json:"conversationSignature"`
	Participant           Participant       `json:"participant"`
	SpokenTextMode        string            `json:"spokenTextMode"`
	ConversationId        string            `json:"conversationId"`
	PreviousMessages      []PreviousMessage `json:"previousMessages"`
	GptId                 string            `json:"gptId"`
}

type ArgumentAttachedFilesInfo

type ArgumentAttachedFilesInfo struct {
	FileName string `json:"fileName"`
	FileType string `json:"fileType"`
}

type ArgumentMessage

type ArgumentMessage struct {
	Locale             string                      `json:"locale"`
	Market             string                      `json:"market"`
	Region             string                      `json:"region"`
	Location           string                      `json:"location"`
	LocationHints      []LocationHint              `json:"locationHints"`
	AttachedFilesInfos []ArgumentAttachedFilesInfo `json:"attachedFilesInfos"`
	Author             string                      `json:"author"`
	InputMethod        string                      `json:"inputMethod"`
	Text               string                      `json:"text"`
	MessageType        string                      `json:"messageType"`
	RequestId          string                      `json:"requestId"`
	MessageId          string                      `json:"messageId"`
	ImageUrl           any                         `json:"imageUrl"`
}

type ArgumentPlugin

type ArgumentPlugin struct {
	Id       string `json:"id"`
	Category int    `json:"category"`
}

type AskStreamOptions

type AskStreamOptions struct {
	StopCtx        context.Context
	Prompt         string
	WebpageContext string
	ImageURL       string
	UploadFilePath string
	// contains filtered or unexported fields
}

type BypassCaptchaRequest

type BypassCaptchaRequest struct {
	IG       string `json:"IG"`
	Cookies  string `json:"cookies"`
	IFrameID string `json:"iframeid"`
	ConvID   string `json:"convId"`
	RID      string `json:"rid"`
}

type BypassCaptchaResponse

type BypassCaptchaResponse struct {
	Result struct {
		Cookies    string `json:"cookies"`
		ScreenShot string `json:"screenshot"`
	} `json:"result"`
	Error string `json:"error"`
}

type ChatCompletionChoice

type ChatCompletionChoice struct {
	Index        int           `json:"index"`
	Message      ChoiceMessage `json:"message"`
	FinishReason string        `json:"finish_reason"`
}

type ChatCompletionChunkChoice

type ChatCompletionChunkChoice struct {
	Index        int         `json:"index"`
	Delta        ChoiceDelta `json:"delta"`
	FinishReason *string     `json:"finish_reason"`
}

type ChatMessage

type ChatMessage struct {
	Arguments    []Argument `json:"arguments"`
	InvocationId string     `json:"invocationId"`
	Target       string     `json:"target"`
	Type         int        `json:"type"`
}

type ChatStreamRequest

type ChatStreamRequest struct {
	Prompt            string   `json:"prompt"`
	WebpageContext    string   `json:"context"`
	Cookies           string   `json:"cookies"`
	ImageURL          string   `json:"imageUrl"`
	NoSearch          bool     `json:"noSearch"`
	UseGPT4Turbo      bool     `json:"gpt4turbo"`
	UseClassic        bool     `json:"classic"`
	ConversationStyle string   `json:"conversationStyle"`
	Plugins           []string `json:"plugins"`
}

type ChoiceDelta

type ChoiceDelta struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type ChoiceMessage

type ChoiceMessage struct {
	Content string `json:"content"`
	Role    string `json:"role"`
}

type Conn

type Conn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

func (*Conn) ReadWithTimeout

func (o *Conn) ReadWithTimeout() ([]string, error)

func (*Conn) WriteWithTimeout

func (o *Conn) WriteWithTimeout(v []byte) error

type ConvoData

type ConvoData struct {
	Convoid   string `json:"convoid"`
	Convotone string `json:"convotone"`
}

type CreateConversationRequest

type CreateConversationRequest struct {
	Cookies string `json:"cookies"`
}

type CreateConversationResponse

type CreateConversationResponse struct {
	ConversationId        string                   `json:"conversationId"`
	ClientId              string                   `json:"clientId"`
	Result                CreateConversationResult `json:"result"`
	SecAccessToken        string                   `json:"secAccessToken"`
	ConversationSignature string                   `json:"conversationSignature"`
	BearerToken           string                   `json:"bearerToken"`
}

type CreateConversationResult

type CreateConversationResult struct {
	Value   string `json:"value"`
	Message string `json:"message"`
}

type CreateImageRequest

type CreateImageRequest struct {
	Image   GenerativeImage `json:"image"`
	Cookies string          `json:"cookies"`
}

type GenerateImageResult

type GenerateImageResult struct {
	GenerativeImage
	ImageURLs []string      `json:"image_urls"`
	Duration  time.Duration `json:"duration"`
}

type GenerateMusicRawResponse

type GenerateMusicRawResponse struct {
	RawResponse string `json:"RawResponse"`
}

type GenerateMusicRealResponse

type GenerateMusicRealResponse struct {
	Id               string  `json:"id"`
	Status           string  `json:"status"`
	ErrorMessage     string  `json:"errorMessage"`
	GptPrompt        string  `json:"gptPrompt"`
	Lyrics           string  `json:"lyrics"`
	AudioKey         string  `json:"audioKey"`
	ImageKey         string  `json:"imageKey"`
	VideoKey         string  `json:"videoKey"`
	Duration         float64 `json:"duration"`
	SunoJsonResponse string  `json:"sunoJsonResponse"`
	MusicalStyle     string  `json:"musicalStyle"`
	BingShareHash    string  `json:"bingShareHash"`
}

type GenerateMusicResult

type GenerateMusicResult struct {
	GenerativeMusic
	CoverImgURL   string        `json:"cover_img_url"`
	AudioURL      string        `json:"music_url"`
	VideoURL      string        `json:"video_url"`
	MusicDuration time.Duration `json:"duration"`
	MusicalStyle  string        `json:"musical_style"`
	Title         string        `json:"title"`
	Lyrics        string        `json:"lyrics"`
	TimeElapsed   time.Duration `json:"time_elapsed"`
}

type GenerativeImage

type GenerativeImage struct {
	Text string `json:"text"`
	URL  string `json:"url"`
}

type GenerativeMusic

type GenerativeMusic struct {
	IFrameID  string `json:"iframeid"`
	RequestID string `json:"requestid"`
	Text      string `json:"text"`
}

type InvokedSkillsRequestData

type InvokedSkillsRequestData struct {
	EnableFaceBlur bool `json:"enableFaceBlur"`
}

type KnowledgeRequest

type KnowledgeRequest struct {
	InvokedSkills            []string                 `json:"invokedSkills"`
	SubscriptionId           string                   `json:"subscriptionId"`
	InvokedSkillsRequestData InvokedSkillsRequestData `json:"invokedSkillsRequestData"`
	ConvoData                ConvoData                `json:"convoData"`
}

type LatLng

type LatLng struct {
	Latitude  float64 `json:"Latitude"`
	Longitude float64 `json:"Longitude"`
}

type LocationHint

type LocationHint struct {
	SourceType               int     `json:"SourceType"`
	RegionType               int     `json:"RegionType"`
	Center                   LatLng  `json:"Center"`
	Radius                   int     `json:"Radius"`
	Name                     string  `json:"Name"`
	Accuracy                 int     `json:"Accuracy"`
	FDConfidence             float64 `json:"FDConfidence"`
	CountryName              string  `json:"CountryName"`
	CountryConfidence        int     `json:"CountryConfidence"`
	Admin1Name               string  `json:"Admin1Name"`
	PopulatedPlaceName       string  `json:"PopulatedPlaceName"`
	PopulatedPlaceConfidence int     `json:"PopulatedPlaceConfidence"`
	PostCodeName             string  `json:"PostCodeName"`
	UtcOffset                int     `json:"UtcOffset"`
	Dma                      int     `json:"Dma"`
}

type Message

type Message struct {
	Type  string
	Text  string
	Error error
}

type OpenAIChatCompletion

type OpenAIChatCompletion struct {
	ID                string                 `json:"id"`
	Object            string                 `json:"object"`
	Created           int64                  `json:"created"`
	Model             string                 `json:"model"`
	SystemFingerprint string                 `json:"system_fingerprint"`
	Choices           []ChatCompletionChoice `json:"choices"`
	Usage             UsageStats             `json:"usage"`
}

func NewOpenAIChatCompletion

func NewOpenAIChatCompletion(model, content, finishReason string) *OpenAIChatCompletion

type OpenAIChatCompletionChunk

type OpenAIChatCompletionChunk struct {
	ID                string                      `json:"id"`
	Object            string                      `json:"object"`
	Created           int64                       `json:"created"`
	Model             string                      `json:"model"`
	SystemFingerprint string                      `json:"system_fingerprint"`
	Choices           []ChatCompletionChunkChoice `json:"choices"`
}

func NewOpenAIChatCompletionChunk

func NewOpenAIChatCompletionChunk(model, delta string, finishReason *string) *OpenAIChatCompletionChunk

type OpenAIChatCompletionRequest

type OpenAIChatCompletionRequest struct {
	Model        string                     `json:"model"`
	Messages     []OpenAIMessage            `json:"messages"`
	Stream       bool                       `json:"stream"`
	ToolChoice   *interface{}               `json:"tool_choice"`
	Conversation CreateConversationResponse `json:"conversation"`
}

Most fields are omitted due to limitations of the Bing API

type OpenAIImageGeneration

type OpenAIImageGeneration struct {
	Created int64               `json:"created"`
	Data    []OpenAIImageObject `json:"data"`
}

func ToOpenAIImageGeneration

func ToOpenAIImageGeneration(result GenerateImageResult) OpenAIImageGeneration

type OpenAIImageGenerationRequest

type OpenAIImageGenerationRequest struct {
	Prompt string `json:"prompt"`
}

type OpenAIImageObject

type OpenAIImageObject struct {
	URL           string `json:"url"`
	RevisedPrompt string `json:"revised_prompt"`
}

type OpenAIMessage

type OpenAIMessage struct {
	Role    string      `json:"role"`
	Content interface{} `json:"content"`
}

type OpenAIMessagesParseResult

type OpenAIMessagesParseResult struct {
	WebpageContext string
	Prompt         string
	ImageURL       string
}

func ParseOpenAIMessages

func ParseOpenAIMessages(messages []OpenAIMessage) (OpenAIMessagesParseResult, error)

type Options

type Options struct {
	Debug                 bool
	Cookies               map[string]string
	Proxy                 string
	ConversationStyle     string
	Locale                string
	WssDomain             string
	CreateConversationURL string
	NoSearch              bool
	UseClassic            bool
	GPT4Turbo             bool
	BypassServer          string
	Plugins               []string
}

type Participant

type Participant struct {
	Id string `json:"id"`
}

type Plugin

type Plugin struct {
	Name        string
	OptionsSets []string
	ArgumentPlugin
}

type PreviousMessage

type PreviousMessage struct {
	Author      string `json:"author"`
	Description string `json:"description"`
	ContextType string `json:"contextType"`
	MessageType string `json:"messageType"`
	HiddenText  string `json:"hiddenText"`
}

type RawMessage

type RawMessage struct {
	Data  string
	Error error
}

type SourceAttribute

type SourceAttribute struct {
	Index int    `json:"index"`
	Link  string `json:"link"`
	Title string `json:"title"`
}

type Sydney

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

func NewSydney

func NewSydney(options Options) *Sydney

func (*Sydney) AskStream

func (o *Sydney) AskStream(options AskStreamOptions) (<-chan Message, error)

func (*Sydney) AskStreamRaw

func (o *Sydney) AskStreamRaw(options AskStreamOptions) (CreateConversationResponse, <-chan RawMessage, error)

func (*Sydney) BypassCaptcha

func (o *Sydney) BypassCaptcha(stopCtx context.Context, conversationID string, messageID string) error

func (*Sydney) GenerateImage

func (o *Sydney) GenerateImage(generativeImage GenerativeImage) (GenerateImageResult, error)

func (*Sydney) GenerateMusic

func (o *Sydney) GenerateMusic(generativeMusic GenerativeMusic) (GenerateMusicResult, error)

func (*Sydney) GetUser

func (o *Sydney) GetUser() (string, error)

func (*Sydney) ResolveCaptcha

func (o *Sydney) ResolveCaptcha(stopCtx context.Context) (err error)

func (*Sydney) UpdateModifiedCookies

func (o *Sydney) UpdateModifiedCookies(modifiedCookies map[string]string)

func (*Sydney) UploadImage

func (o *Sydney) UploadImage(jpgImgData []byte) (string, error)

type UploadFileHiddenText

type UploadFileHiddenText struct {
	FileName      string `json:"fileName"`
	FileType      string `json:"fileType"`
	DocId         string `json:"docId"`
	IsLongContext bool   `json:"isLongContext"`
	UserId        string `json:"userId"`
	IsBCE         bool   `json:"isBCE"`
}

type UploadFileResponse

type UploadFileResponse struct {
	FileName      string `json:"fileName"`
	FileSize      int    `json:"fileSize"`
	FileType      string `json:"fileType"`
	IsLongContext bool   `json:"isLongContext"`
	DocId         string `json:"docId"`
	UserId        string `json:"userId"`
	Result        struct {
		Value          string `json:"value"`
		Message        string `json:"message"`
		ServiceVersion string `json:"serviceVersion"`
	} `json:"result"`
}

type UploadFileResult

type UploadFileResult struct {
	Valid          bool
	Response       UploadFileResponse
	FileHiddenText string
	RealFileType   string
}

type UploadImagePayload

type UploadImagePayload struct {
	ImageInfo        map[string]any   `json:"imageInfo"`
	KnowledgeRequest KnowledgeRequest `json:"knowledgeRequest"`
}

type UploadImageResponse

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

type UsageStats

type UsageStats struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Directories

Path Synopsis
internal
hex

Jump to

Keyboard shortcuts

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