db

package
v0.0.0-...-0cfe7c7 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client implements the db.Databaser interface using AWS S3 and AWS DynamoDB.

func New

func New(newSession *session.Session, bucketName, questionsTableName, summariesTableName string) *Client

New generates a Client pointer instance.

func (*Client) GetDocuments

func (c *Client) GetDocuments(ctx context.Context) ([]dct.Document, error)

GetDocuments implements the db.Databaser.GetDocuments method using AWS S3 and returns a slice of structs representing the rows in the documents.jsonl file.

func (*Client) GetIDs

func (c *Client) GetIDs(ctx context.Context) ([]string, error)

GetIDs implements the db.Databaser.GetIDs method using AWS DynamoDB and returns a slice of the IDs of the items stored in the "summaries" table.

func (*Client) GetSummaries

func (c *Client) GetSummaries(ctx context.Context) ([]Summary, error)

GetSummaries implements the db.Databaser.GetSummaries method using AWS DynamoDB and returns a slice of structs representing the rows stored in the "summaries" table.

func (*Client) StoreAnswer

func (c *Client) StoreAnswer(ctx context.Context, id, answer string) error

StoreAnswer implements the db.Databaser.StoreAnswer method using AWS DynamoDB and stores the received answer generated by OpenAI in the "questions" table.

func (*Client) StoreDocuments

func (c *Client) StoreDocuments(ctx context.Context, documents []dct.Document) error

StoreDocuments implements the db.Databaser.StoreDocuments method using AWS S3 and stores the provided slice of structs representing the documents.jsonl file and replaces it in storage.

func (*Client) StoreQuestion

func (c *Client) StoreQuestion(ctx context.Context, id, question string) error

StoreQuestion implements the db.Databaser.StoreQuestion method using AWS DynamoDB and stores the received user question in the "questions" table.

func (*Client) StoreSummaries

func (c *Client) StoreSummaries(ctx context.Context, summaries []Summary) error

StoreSummaries implements the db.Databaser.StoreSummaries method using AWS DynamoDB and stores the provided slice of structs in the "summaries" table.

func (*Client) StoreText

func (c *Client) StoreText(ctx context.Context, id, text string) error

StoreText implements the db.Databaser.StoreText method using AWS S3 and stores the provided text as a Markdown file.

This Markdown file is not used by the application,

type Databaser

type Databaser interface {
	GetIDs(ctx context.Context) ([]string, error)
	GetSummaries(ctx context.Context) ([]Summary, error)
	StoreSummaries(ctx context.Context, summaries []Summary) error
	StoreText(ctx context.Context, id, text string) error
	GetDocuments(ctx context.Context) ([]dct.Document, error)
	StoreDocuments(ctx context.Context, answers []dct.Document) error
	StoreQuestion(ctx context.Context, id, question string) error
	StoreAnswer(ctx context.Context, id, answer string) error
}

Databaser defines methods for interacting with the storage layer of the application.

type Summary

type Summary struct {
	ID      string `json:"id"`
	URL     string `json:"url"`
	Title   string `json:"title"`
	Summary string `json:"summary"`
	Number  int    `json:"number"`
}

Summary represents a row in the summaries table.

Jump to

Keyboard shortcuts

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