controllers

package
v0.0.0-...-44a1fbc Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatPrimedTokens = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountPayload

type AccountPayload struct {
	Action   string `json:"action"`
	Count    int64  `json:"count"`
	Username string `json:"i_username"`
	Password string `json:"i_password"`
}

type AccountService

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

func NewAccountService

func NewAccountService(dsn string, basicUsers, baiscPasswords string) (*AccountService, error)

func (*AccountService) AccountProcess

func (ac *AccountService) AccountProcess(ctx *gin.Context)

func (*AccountService) AuthenticateUser

func (ac *AccountService) AuthenticateUser(username, password string) int

func (*AccountService) CheckUser

func (ac *AccountService) CheckUser(username string) (User, error)

func (*AccountService) CreateUser

func (ac *AccountService) CreateUser(name, password string, cnt int64) error

func (*AccountService) GetUser

func (ac *AccountService) GetUser(username, password string) (User, error)

func (*AccountService) GrantUser

func (ac *AccountService) GrantUser(username string, block int64) error

func (*AccountService) IncBalance

func (ac *AccountService) IncBalance(username string, cnt int64) error

func (*AccountService) IncUsage

func (ac *AccountService) IncUsage(username string, cnt int64) error

func (*AccountService) ListUser

func (ac *AccountService) ListUser() ([]User, error)

func (*AccountService) UpdateUser

func (ac *AccountService) UpdateUser(oldName, oldPassword, name, password string) error

type ChatCompletionParams

type ChatCompletionParams struct {
	Model                 string        `json:"model"`
	MaxTokens             int           `json:"max_tokens,omitempty"`
	Temperature           float32       `json:"temperature,omitempty"`
	PresencePenalty       float32       `json:"presence_penalty,omitempty"`
	FrequencyPenalty      float32       `json:"frequency_penalty,omitempty"`
	ChatSessionTTL        time.Duration `json:"chat_session_ttl"`
	ChatMinResponseTokens int           `json:"chat_min_response_tokens"`
}

type ChatMessage

type ChatMessage struct {
	ID              string                              `json:"id"`
	Text            string                              `json:"text"`
	Role            string                              `json:"role"`
	Name            string                              `json:"name"`
	Delta           string                              `json:"delta"`
	Detail          openai.ChatCompletionStreamResponse `json:"detail"`
	TokenCount      int                                 `json:"tokenCount"`
	ParentMessageId string                              `json:"parentMessageId"`
}

type ChatMessageRequest

type ChatMessageRequest struct {
	Prompt  string                    `json:"prompt"`
	Options ChatMessageRequestOptions `json:"options"`
}

type ChatMessageRequestOptions

type ChatMessageRequestOptions struct {
	Name            string `json:"name"`
	ParentMessageId string `json:"parentMessageId"`
}

type ChatService

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

func NewChatService

func NewChatService(apiKey string, baseURL string, socksProxy string, params ChatCompletionParams, account *AccountService) (*ChatService, error)

func (*ChatService) ChatProcess

func (chat *ChatService) ChatProcess(ctx *gin.Context)

func (*ChatService) MessageProcess

func (chat *ChatService) MessageProcess(ctx *gin.Context)

type User

type User struct {
	ID       int64  `gorm:"column:id;primaryKey;autoIncrement"`
	Username string `gorm:"column:username;not null;unique;index"`
	Password string `gorm:"column:password;not null;index"`
	Balance  int64  `gorm:"column:balance;not null;default:0"`
	Usage    int64  `gorm:"column:usage;not null;default:0"`
	Isblock  int    `gorm:"column:is_block;not null;default:0"`
}

func (User) TableName

func (User) TableName() string

Jump to

Keyboard shortcuts

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