hugchat

package
v0.0.0-...-280b4f7 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateUUID

func GenerateUUID() (string, error)

func HandleError

func HandleError(err error)

func LoadEnvFromFile

func LoadEnvFromFile(filepath string) error

Types

type ChatBot

type ChatBot struct {
	Username             string
	Password             string
	Cookies              []*http.Cookie
	Session              *http.Client
	HFBaseURL            *url.URL
	JSONHeader           http.Header
	ConversationIDList   []string
	ActiveModel          string
	AcceptedWelcomeModal bool
	CurrentConversation  string
}

func NewChatBot

func NewChatBot(username, password string) (*ChatBot, error)

func (*ChatBot) AcceptEthicsModal

func (c *ChatBot) AcceptEthicsModal() error

func (*ChatBot) Chat

func (c *ChatBot) Chat(
	text string,
	temperature float64,
	topP float64,
	repetitionPenalty float64,
	topK int,
	truncate int,
	watermark bool,
	maxNewTokens int,
	stop []string,
	returnFullText bool,
	stream bool,
	useCache bool,
	isRetry bool,
	retryCount int,
) (string, error)

func (*ChatBot) ChatPrompt

func (c *ChatBot) ChatPrompt(
	text string,
) (string, error)

func (*ChatBot) NewConversation

func (c *ChatBot) NewConversation() (string, error)

type ChatOptions

type ChatOptions struct {
	UseCache bool   `json:"use_cache"`
	IsRetry  bool   `json:"is_retry"`
	ID       string `json:"id"`
}

type ChatParameters

type ChatParameters struct {
	Temperature       float64  `json:"temperature"`
	TopP              float64  `json:"top_p"`
	RepetitionPenalty float64  `json:"repetition_penalty"`
	TopK              int      `json:"top_k"`
	Truncate          int      `json:"truncate"`
	Watermark         bool     `json:"watermark"`
	MaxNewTokens      int      `json:"max_new_tokens"`
	Stop              []string `json:"stop"`
	ReturnFullText    bool     `json:"return_full_text"`
	Stream            bool     `json:"stream"`
}

type ChatRequest

type ChatRequest struct {
	Inputs     string         `json:"inputs"`
	Parameters ChatParameters `json:"parameters"`
	Options    ChatOptions    `json:"options"`
}

type ChatResponse

type ChatResponse struct {
	GeneratedText string `json:"generated_text"`
	Error         string `json:"error"`
}

type Login

type Login struct {
	Email      string
	Passwd     string
	CookiePath string
	Cookies    []*http.Cookie
	Client     *http.Client
}

func NewLogin

func NewLogin(email, passwd, cookiePath string) *Login

func (*Login) GetAuthURL

func (l *Login) GetAuthURL() (string, error)

func (*Login) GrantAuth

func (l *Login) GrantAuth(Url string) error

func (*Login) LoadCookies

func (l *Login) LoadCookies() error

func (*Login) Login

func (l *Login) Login() error

func (*Login) SaveCookies

func (l *Login) SaveCookies() error

func (*Login) SigninWithEmail

func (l *Login) SigninWithEmail() error

Jump to

Keyboard shortcuts

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