storage

package
v0.0.0-...-26e77a4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPageSize = 5

DefaultPageSize represents the default page size for query results.

View Source
const DuplicateKeyViolatesUniqueConstraintCode = "23505"

DuplicateKeyViolatesUniqueConstraintCode is the error code returned by PostgreSQL when a unique constraint is violated.

Variables

View Source
var ErrExistingResource = errors.New("storage: resource already exists")

ErrExistingResource is an error that is returned when a resource already exists in the storage.

Functions

This section is empty.

Types

type ClassificationTask

type ClassificationTask struct {
	ID         int64
	ProjectID  int64
	LLMInput   string
	LLMOutput  string
	CreatedAt  time.Time
	Embeddings map[string][]byte
	LabelID    int64
}

ID is the unique identifier for the classification task. ProjectID is the identifier for the project associated with the classification task. LLMInput is the input data for the classification task. LLMOutput is the output data generated by the classification task. CreatedAt is the timestamp when the classification task was created. Embeddings are the binary representations of the task's embeddings, with each key being the model that produced the embedding. LabelID is the identifier for the label associated with the classification task.

type ClassificationTaskLabel

type ClassificationTaskLabel struct {
	ID        int64
	ProjectID int64
	Label     string
	CreatedAt time.Time
}

ID represents the unique identifier of the classification task label. ProjectID represents the identifier of the project associated with the classification task label. Label represents the name or description of the classification task label. CreatedAt represents the timestamp when the classification task label was created.

type Database

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

Database represents a connection to an SQL database.

func Open

func Open(ctx context.Context, cfg config.Config) (*Database, error)

Open opens a connection to the database and returns a pointer to the Database struct. It uses the sqlite driver and connects to the "semantic-sensei.sqlite" file with foreign key support enabled. If the connection is successful, it returns a pointer to the Database struct and nil error. Otherwise, it returns nil and the error encountered during the connection.

func (Database) Close

func (d Database) Close() error

Close closes the database connection. It returns an error if there was a problem closing the connection.

func (Database) CreateClassificationTask

func (d Database) CreateClassificationTask(ctx context.Context, ct ClassificationTask) (int64, error)

CreateClassificationTask creates a new classification task in the database and returns the ID of the newly created classification task.

func (Database) CreateClassificationTaskLabel

func (d Database) CreateClassificationTaskLabel(ctx context.Context, ctl ClassificationTaskLabel) (int64, error)

CreateClassificationTaskLabel creates a new classification task label in the database and returns the ID of the newly created classification task label.

func (Database) CreatePendingClassificationTask

func (d Database) CreatePendingClassificationTask(ctx context.Context, pct PendingClassificationTask) (int64, error)

CreatePendingClassificationTask creates a new pending classification task in the database and returns the ID of the newly created pending classification task.

func (Database) CreateProject

func (d Database) CreateProject(ctx context.Context, p Project) (int64, error)

CreateProject creates a new project in the database and returns the ID of the newly created project.

func (Database) DeleteClassificationTask

func (d Database) DeleteClassificationTask(ctx context.Context, id int64) error

DeleteClassificationTask deletes a classification task from the database based on the given ID.

func (Database) DeleteClassificationTaskLabel

func (d Database) DeleteClassificationTaskLabel(ctx context.Context, id int64) error

DeleteClassificationTaskLabel deletes a classification task label from the database based on the given ID.

func (Database) DeletePendingClassificationTask

func (d Database) DeletePendingClassificationTask(ctx context.Context, id int64) error

DeletePendingClassificationTask deletes a pending classification task from the database based on the given ID.

func (Database) DeleteProject

func (d Database) DeleteProject(ctx context.Context, id int64) error

DeleteProject deletes a project from the database based on the given ID. It takes a context.Context and an int64 ID as parameters. It returns an error if there was a problem deleting the project.

func (Database) FindClassificationTaskLabelsForProject

func (d Database) FindClassificationTaskLabelsForProject(
	ctx context.Context,
	projectID int64,
) ([]ClassificationTaskLabel, error)

FindClassificationTaskLabelsForProject returns the classification task label with the given project ID.

func (Database) FindClassificationTasksForProject

func (d Database) FindClassificationTasksForProject(
	ctx context.Context,
	projectID int64,
	parameters Parameters,
) ([]ClassificationTask, error)

FindClassificationTasksForProject returns a list of classification tasks for the specified project ID.

func (Database) FindPendingClassificationTaskCountForProject

func (d Database) FindPendingClassificationTaskCountForProject(
	ctx context.Context,
	projectID int64,
	where ...string,
) (uint64, error)

FindPendingClassificationTaskCountForProject returns the count of pending classification tasks for the specified project ID.

func (Database) FindPendingClassificationTasksForProject

func (d Database) FindPendingClassificationTasksForProject(
	ctx context.Context,
	projectID int64,
	parameters Parameters,
) ([]PendingClassificationTask, error)

FindPendingClassificationTasksForProject returns a list of pending classification tasks for the specified project ID.

func (Database) FindProjects

func (d Database) FindProjects(ctx context.Context) ([]Project, error)

FindProjects gets a list of all projects.

func (Database) GetClassificationTask

func (d Database) GetClassificationTask(ctx context.Context, id int64) (*ClassificationTask, error)

GetClassificationTask returns the classification task with the provided ID.

func (Database) GetClassificationTaskLabel

func (d Database) GetClassificationTaskLabel(ctx context.Context, id int64) (*ClassificationTaskLabel, error)

GetClassificationTaskLabel returns the classification task label with the provided ID.

func (Database) GetPendingClassificationTask

func (d Database) GetPendingClassificationTask(ctx context.Context, id int64) (*PendingClassificationTask, error)

GetPendingClassificationTask returns the pending classification task with the provided ID.

func (Database) GetProject

func (d Database) GetProject(ctx context.Context, id int64) (*Project, error)

GetProject returns the project with the provided ID.

func (Database) Migrate

func (d Database) Migrate(ctx context.Context) error

Migrate applies database migrations using the provided migration source and driver. It returns an error if there was a problem creating the migration driver or source, or if there was an error running the migrations.

func (Database) UpdateClassificationTask

func (d Database) UpdateClassificationTask(ctx context.Context, ct ClassificationTask) error

UpdateClassificationTask updates the classification task with the provided ID with the provided values.

func (Database) UpdateClassificationTaskLabel

func (d Database) UpdateClassificationTaskLabel(ctx context.Context, ctl ClassificationTaskLabel) error

UpdateClassificationTaskLabel updates the classification task label with the provided ID with the provided values.

func (Database) UpdatePendingClassificationTask

func (d Database) UpdatePendingClassificationTask(ctx context.Context, pct PendingClassificationTask) error

UpdatePendingClassificationTask updates the pending classification task with the provided ID with the provided values.

func (Database) UpdateProject

func (d Database) UpdateProject(ctx context.Context, p Project) error

UpdateProject updates the project with the provided ID with the provided values.

type Parameters

type Parameters struct {
	Where    []string
	Page     uint64
	PageSize uint64
}

Parameters represents parametrisation of the queries.

type PendingClassificationTask

type PendingClassificationTask struct {
	ID         int64
	ProjectID  int64
	LLMInput   string
	LLMOutput  string
	CreatedAt  time.Time
	Embeddings map[string][]byte
}

ID is the unique identifier for the classification task. ProjectID is the identifier for the project associated with the classification task. LLMInput is the input data for the classification task. LLMOutput is the output data generated by the classification task. CreatedAt is the timestamp when the classification task was created. Embeddings are the binary representations of the task's embeddings, with each key being the name of the model taht produced the embedding.

type Project

type Project struct {
	ID          int64
	Name        string
	Description string
	CreatedAt   time.Time
}

ID represents the unique identifier of the project. Name represents the name of the project. Description represents the description of the project. CreatedAt represents the timestamp when the project was created.

Jump to

Keyboard shortcuts

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