db

package
v0.0.0-...-85dcd5f Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequiredCollectionBucket = []string{"config", "users", "models", "chats", "messages", "media", "openai"}

Functions

func AddUpdateModel

func AddUpdateModel(db QataiDatabase, m *LLMModel, updateIfExists bool) error

func AddUpdateUser

func AddUpdateUser(db *QataiDatabase, user *User, updateIfExists bool) error

func ClearAllConfig

func ClearAllConfig(db QataiDatabase) error

func ClearAllModels

func ClearAllModels(db QataiDatabase) error

func SetConfig

func SetConfig(db QataiDatabase, config *Config) error

Types

type BBoltDB

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

func InitNewBoltDB

func InitNewBoltDB(path string) (*BBoltDB, error)

func (*BBoltDB) ClearAllRecordsInCollection

func (db *BBoltDB) ClearAllRecordsInCollection(CollectionBucketName string) error

func (*BBoltDB) GetAllRecordForCollectionBucket

func (db *BBoltDB) GetAllRecordForCollectionBucket(CollectionBucketName string) ([]QataiDatabaseRecord, error)

func (*BBoltDB) GetValueByKeyName

func (b *BBoltDB) GetValueByKeyName(CollectionBucketName string, Key string) (*QataiDatabaseRecord, error)

func (*BBoltDB) SetValueByKeyName

func (b *BBoltDB) SetValueByKeyName(CollectionBucketName string, record *QataiDatabaseRecord) error

type Config

type Config struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

func GetAllConfig

func GetAllConfig(db QataiDatabase) ([]Config, error)

func GetConfig

func GetConfig(db QataiDatabase, key string) (*Config, error)

BBolt

type LLMEndPoint

type LLMEndPoint struct {
	Host   string `json:"host"`
	Port   int16  `json:"port"`
	UseSSL bool   `json:"useSSL"`
}

type LLMModel

type LLMModel struct {
	UUID        string        `json:"uuid"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	PrePrompt   string        `json:"prePrompt"`
	Tokens      LLMTokens     `json:"tokens"`
	Stops       []string      `json:"stops"`
	Provider    LLMProvider   `json:"provider"`
	Prompts     []LLMPrompts  `json:"prompts"`
	Parameters  LLMParameters `json:"parameters"`
	EndPoints   []LLMEndPoint `json:"endPoints"`
}

func GetAllModels

func GetAllModels(db QataiDatabase) ([]LLMModel, error)

func GetModelByName

func GetModelByName(db QataiDatabase, modelName string) (*LLMModel, error)

func GetModelByUUID

func GetModelByUUID(db QataiDatabase, uuid string) (*LLMModel, error)

func NewLLMModel

func NewLLMModel(name string, description string, provider LLMProvider, prePrompt string, tokens LLMTokens, stops []string, endpoints []LLMEndPoint, prompts []LLMPrompts, params LLMParameters) *LLMModel

Initialise LLMModel

type LLMParameters

type LLMParameters struct {
	Temperature        float64 `json:"temperature"`
	Top_P              float64 `json:"topP"`
	Top_K              int     `json:"topK"`
	RepetitionPenality float64 `json:"repetitionPenality"`
	Truncate           int64   `json:"truncate"`
	MaxNewTokens       int     `json:"maxNewTokens"`
}

type LLMPrompts

type LLMPrompts struct {
	Title       string `json:"title"`
	Prompt      string `json:"prompt"`
	PromptImage string `json:"promptImage"`
}

type LLMProvider

type LLMProvider string
const (
	OPENAI LLMProvider = "openai"
	HFTGI  LLMProvider = "tgi"
)

type LLMTokens

type LLMTokens struct {
	SystemToken    string `json:"systemToken"`
	UserToken      string `json:"userToken"`
	AssistantToken string `json:"assistantToken"`
	FunctionToken  string `json:"functionToken"`
}

type MongoDB

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

func InitNewMongoDB

func InitNewMongoDB(uri string, dbName string) (*MongoDB, error)

func (*MongoDB) ClearAllRecordsInCollection

func (db *MongoDB) ClearAllRecordsInCollection(CollectionBucketName string) error

func (*MongoDB) GetAllRecordForCollectionBucket

func (db *MongoDB) GetAllRecordForCollectionBucket(CollectionBucketName string) ([]QataiDatabaseRecord, error)

func (*MongoDB) GetValueByKeyName

func (m *MongoDB) GetValueByKeyName(CollectionBucketName string, Key string) (*QataiDatabaseRecord, error)

func (*MongoDB) SetValueByKeyName

func (m *MongoDB) SetValueByKeyName(CollectionBucketName string, record *QataiDatabaseRecord) error

type QataiDatabase

type QataiDatabase interface {
	SetValueByKeyName(CollectionBucketName string, record *QataiDatabaseRecord) error
	GetValueByKeyName(CollectionBucketName string, Key string) (*QataiDatabaseRecord, error)
	GetAllRecordForCollectionBucket(CollectionBucketName string) ([]QataiDatabaseRecord, error) //TODO: I know, wrong, dirty, but I need it anyway and too lazy to create a new a collection for mapping
	ClearAllRecordsInCollection(CollectionBucketName string) error
}

type QataiDatabaseRecord

type QataiDatabaseRecord struct {
	Key   string
	Value string
}

type User

type User struct {
	UUID          string   `json:"uuid"`
	Email         string   `json:"email"`
	Name          string   `json:"name"`
	Salt          string   `json:"salt"`
	Password      string   `json:"password"` // This should be hashed & salted in a real-world scenario
	Disabled      bool     `json:"disabled"`
	LastLoginIP   string   `json:"last_login_ip"`
	LastLoginTime string   `json:"last_login_time"`
	ChatsIDs      []string `json:"chats"`
}

Jump to

Keyboard shortcuts

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