db

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var D *sql.DB

Functions

func GetDittoTokensPerDollar

func GetDittoTokensPerDollar(ctx context.Context) (int64, error)

func SearchExamples

func SearchExamples(ctx context.Context, em llm.Embedding, opts ...SearchOption) ([]llm.Example, error)

func Setup

func Setup(ctx context.Context, shutdown *sync.WaitGroup, mode ConnectionMode) error

Types

type ConnectionMode added in v0.0.4

type ConnectionMode string
const (
	ModeCloud   ConnectionMode = "cloud"
	ModeReplica ConnectionMode = "replica"
)

type Purchase

type Purchase struct {
	ID        int64
	PaymentID string
	UserID    int64
	Cents     int64
	Tokens    int64
	CreatedAt time.Time
}

func (*Purchase) Insert

func (p *Purchase) Insert(uid string) error

type Receipt

type Receipt struct {
	ID     int64
	UserID int64
	// ServiceName is the name of the service used for this receipt.
	// It is not in this DB table, but is used for internal logic.
	ServiceName         llm.ServiceName
	ServiceID           int64
	Timestamp           time.Time
	InputTokens         int64
	OutputTokens        int64
	TotalTokens         int64
	CallDurationSeconds float64
	DataProcessedBytes  int64
	DataStoredBytes     int64
	NumImages           int64
	NumSearches         int64
	NumAPICalls         int64
	DittoTokenCost      int64
	Metadata            json.RawMessage
}

func (*Receipt) Insert

func (r *Receipt) Insert(ctx context.Context) error

Insert inserts a new receipt into the database. It updates the Receipt's ID with the ID from the database.

type SearchOption

type SearchOption func(*opt)

func WithK

func WithK(k int) SearchOption

type Service

type Service struct {
	ID                             int64
	Name                           string
	Description                    string
	Version                        string
	ServiceType                    string
	Provider                       string
	BaseCostPerCall                float64
	BaseCostPerMillionTokens       float64
	BaseCostPerMillionInputTokens  float64
	BaseCostPerMillionOutputTokens float64
	BaseCostPerImage               float64
	BaseCostPerSearch              float64
	MaxInputTokens                 int64
	MaxOutputTokens                int64
	MaxTotalTokens                 int64
	BaseCostPerSecond              float64
	BaseCostPerGBProcessed         float64
	BaseCostPerGBStored            float64
	SupportsBatching               bool
	BatchSizeLimit                 int64
	BaseCostPerBatch               float64
	RateLimitPerMinute             int64
	RateLimitPerDay                int64
	ProfitMarginPercentage         float64
	MinimumProfitAmount            float64
	PeakHoursMultiplier            float64
	VolumeDiscountThreshold        int64
	VolumeDiscountPercentage       float64
	Currency                       string
	IsActive                       bool
}

func (*Service) GetByName

func (s *Service) GetByName(ctx context.Context) error

GetServiceByName retrieves a service from the database by its name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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