fun

package
v0.0.0-...-5d3449f Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Client = twitch.NewAnonymousClient()
View Source
var F = Fun{}
View Source
var GenericUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0"
View Source
var QuoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"")

Functions

func StableDiffusionImage

func StableDiffusionImage(prompt string) (io.ReadCloser, error)

func TextGeneration

func TextGeneration(c chan Result, query TextQuery, model string)

Types

type Cmd

type Cmd struct {
	Name    string
	Handler func(m twitch.PrivateMessage) error
}

type FileUpload

type FileUpload struct {
	ID       string `json:"id"`
	Ext      string `json:"ext"`
	Type     string `json:"type"`
	Checksum string `json:"checksum"`
	Key      string `json:"key"`
	Link     string `json:"link"`
	Delete   string `json:"delete"`
}

func UploadFile

func UploadFile(rc io.ReadCloser, fileName string, contentType string) (upload FileUpload, err error)

type Fun

type Fun struct {
	Cmds []Cmd
}

func (*Fun) Register

func (f *Fun) Register(c *Cmd)

type ImgPrompt

type ImgPrompt struct {
	Prompt string `json:"prompt"`
	Steps  int    `json:"num_steps"`
}

type Input

type Input struct {
	ChannelID string `json:"channelID"`
	Message   string `json:"message"`
	ParentID  string `json:"replyParentMessageID"`
}

type Message

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

type PMessage

type PMessage struct {
	Role    string           `json:"role"`
	Content []map[string]any `json:"content"`
}

type Payload

type Payload struct {
	Model            string     `json:"model"`
	Messages         []PMessage `json:"messages"`
	Temperature      int        `json:"temperature"`
	MaxTokens        int        `json:"max_tokens"`
	TopP             int        `json:"top_p"`
	FrequencyPenalty int        `json:"frequency_penalty"`
	PresencePenalty  int        `json:"presence_penalty"`
}

type QueryMessage

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

type Response

type Response struct {
	ID        string `json:"id"`
	Type      string `json:"object"`
	Timestamp int    `json:"created"`
	Model     string `json:"model"`
	Choices   []struct {
		Index        int     `json:"index"`
		Message      Message `json:"message"`
		FinishReason string  `json:"finish_reason"`
	} `json:"choices"`
	Usage struct {
		PromptTokens     int `json:"prompt_tokens"`
		CompletionTokens int `json:"completion_tokens"`
		TotalTokens      int `json:"total_tokens"`
	} `json:"usage"`
	Fingerprint string `json:"system_fingerprint"`
}

type Result

type Result struct {
	Response string `json:"response"`
	Error    error
}

type TextQuery

type TextQuery struct {
	Stream   bool           `json:"stream"`
	Messages []QueryMessage `json:"messages"`
}

type TwitchGQLBaseResponse

type TwitchGQLBaseResponse struct {
	Extensions struct {
		Duration      json.Number `json:"durationMilliseconds"`
		OperationName string      `json:"operationName"`
		RequestID     string      `json:"requestID"`
	} `json:"extensions"`
}

type TwitchGQLPayload

type TwitchGQLPayload struct {
	OperationName string `json:"operationName"`
	Query         string `json:"query"`
	Variables     any    `json:"variables"`
}

type TwitchMsg

type TwitchMsg struct {
	Input `json:"input"`
}

type TwitchSendMsgResponse

type TwitchSendMsgResponse struct {
	*TwitchGQLBaseResponse
	Data struct {
		Mutation struct {
			DropReason *string `json:"dropReason"` // nullable hence pointer
			Message    struct {
				ID string `json:"id"`
			} `json:"message"`
		} `json:"sendChatMessage"`
	} `json:"data"`
}

func Say

func Say(channelID string, message string, parentID string, ctx ...int) (response TwitchSendMsgResponse, err error)

type TwitchUser

type TwitchUser struct {
	ID          string `json:"id,omitempty"`
	Login       string `json:"login,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
}

func GetUser

func GetUser(login string, id string) (user TwitchUser, err error)

type TwitchUserResponse

type TwitchUserResponse struct {
	*TwitchGQLBaseResponse
	Data struct {
		User TwitchUser `json:"user"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

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