Documentation
¶
Index ¶
- Constants
- Variables
- type ClassificationTask
- type ClassificationTaskLabel
- type Database
- func (d Database) Close() error
- func (d Database) CreateClassificationTask(ctx context.Context, ct ClassificationTask) (int64, error)
- func (d Database) CreateClassificationTaskLabel(ctx context.Context, ctl ClassificationTaskLabel) (int64, error)
- func (d Database) CreatePendingClassificationTask(ctx context.Context, pct PendingClassificationTask) (int64, error)
- func (d Database) CreateProject(ctx context.Context, p Project) (int64, error)
- func (d Database) DeleteClassificationTask(ctx context.Context, id int64) error
- func (d Database) DeleteClassificationTaskLabel(ctx context.Context, id int64) error
- func (d Database) DeletePendingClassificationTask(ctx context.Context, id int64) error
- func (d Database) DeleteProject(ctx context.Context, id int64) error
- func (d Database) FindClassificationTaskLabelsForProject(ctx context.Context, projectID int64) ([]ClassificationTaskLabel, error)
- func (d Database) FindClassificationTasksForProject(ctx context.Context, projectID int64, parameters Parameters) ([]ClassificationTask, error)
- func (d Database) FindPendingClassificationTaskCountForProject(ctx context.Context, projectID int64, where ...string) (uint64, error)
- func (d Database) FindPendingClassificationTasksForProject(ctx context.Context, projectID int64, parameters Parameters) ([]PendingClassificationTask, error)
- func (d Database) FindProjects(ctx context.Context) ([]Project, error)
- func (d Database) GetClassificationTask(ctx context.Context, id int64) (*ClassificationTask, error)
- func (d Database) GetClassificationTaskLabel(ctx context.Context, id int64) (*ClassificationTaskLabel, error)
- func (d Database) GetPendingClassificationTask(ctx context.Context, id int64) (*PendingClassificationTask, error)
- func (d Database) GetProject(ctx context.Context, id int64) (*Project, error)
- func (d Database) Migrate(ctx context.Context) error
- func (d Database) UpdateClassificationTask(ctx context.Context, ct ClassificationTask) error
- func (d Database) UpdateClassificationTaskLabel(ctx context.Context, ctl ClassificationTaskLabel) error
- func (d Database) UpdatePendingClassificationTask(ctx context.Context, pct PendingClassificationTask) error
- func (d Database) UpdateProject(ctx context.Context, p Project) error
- type Parameters
- type PendingClassificationTask
- type Project
Constants ¶
const DefaultPageSize = 5
DefaultPageSize represents the default page size for query results.
const DuplicateKeyViolatesUniqueConstraintCode = "23505"
DuplicateKeyViolatesUniqueConstraintCode is the error code returned by PostgreSQL when a unique constraint is violated.
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
CreateProject creates a new project in the database and returns the ID of the newly created project.
func (Database) DeleteClassificationTask ¶
DeleteClassificationTask deletes a classification task from the database based on the given ID.
func (Database) DeleteClassificationTaskLabel ¶
DeleteClassificationTaskLabel deletes a classification task label from the database based on the given ID.
func (Database) DeletePendingClassificationTask ¶
DeletePendingClassificationTask deletes a pending classification task from the database based on the given ID.
func (Database) DeleteProject ¶
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 ¶
FindProjects gets a list of all projects.
func (Database) GetClassificationTask ¶
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 ¶
GetProject returns the project with the provided ID.
func (Database) Migrate ¶
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.
type Parameters ¶
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.