db

package
v0.0.0-...-a59c08c Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFragmentTables

func CreateFragmentTables(db *gorm.DB) error

func NewDatabase

func NewDatabase(url string) (*gorm.DB, error)

Types

type Actor

type Actor struct {
	ID   id.ID  `gorm:"type:uuid;primaryKey"`
	Name string `gorm:"type:varchar(255);not null"`

	Assistant bool `gorm:"type:boolean;not null;default:false"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type Fragment

type Fragment struct {
	ID        id.ID           `gorm:"type:uuid;primaryKey"`
	ActorID   id.ID           `gorm:"type:uuid;not null;index"`
	SessionID id.ID           `gorm:"type:uuid;not null;index"`
	Content   string          `gorm:"type:text;not null"`
	Metadata  Metadata        `gorm:"type:jsonb;not null;default:'{}'::jsonb"`
	Embedding pgvector.Vector `gorm:"type:vector(1536)"`

	Actor   *Actor   `gorm:"foreignKey:ActorID"`
	Session *Session `gorm:"foreignKey:SessionID"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type FragmentTable

type FragmentTable string
const (
	FragmentTableInteraction FragmentTable = "interaction"
	FragmentTablePersonality FragmentTable = "personality"
	FragmentTableInsight     FragmentTable = "insight"
	FragmentTableTwitter     FragmentTable = "twitter"
)

type Metadata

type Metadata map[string]interface{}

Metadata represents a JSON object stored in the database

func (Metadata) GetBool

func (m Metadata) GetBool(key string) bool

GetBool safely retrieves a boolean value from metadata

func (Metadata) GetFloat

func (m Metadata) GetFloat(key string) float64

GetFloat safely retrieves a float64 value from metadata

func (Metadata) GetString

func (m Metadata) GetString(key string) string

GetString safely retrieves a string value from metadata

func (*Metadata) Scan

func (m *Metadata) Scan(value interface{}) error

Scan implements the sql.Scanner interface

func (Metadata) Value

func (m Metadata) Value() (driver.Value, error)

Value implements the driver.Valuer interface

type Session

type Session struct {
	ID id.ID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Jump to

Keyboard shortcuts

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