db

package
v0.0.0-...-dcbe3c4 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

package db is a package for database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOpenaiDB

func GetOpenaiDB() (db mongo.DB, err error)

GetOpenaiDB get openai db

Types

type Billing

type Billing struct {
	ID          primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	BillingType BillingType        `bson:"type" json:"type"`
	Username    string             `bson:"username" json:"username"`
	// UsedQuota how many quotes used totally, 1usd = 500000 quotes
	UsedQuota Price `bson:"used_quota" json:"used_quota"`
}

Billing billing for user

type BillingType

type BillingType string

BillingType billing type

const (
	BillTypeTxt2Image BillingType = "txt2image"
)

type OpenaiConservation

type OpenaiConservation struct {
	ID         primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	Model      string             `bson:"model" json:"model"`
	MaxTokens  uint               `bson:"max_tokens" json:"max_tokens"`
	Prompt     []OpenaiMessage    `bson:"prompt" json:"prompt"`
	Completion string             `bson:"completion" json:"completion"`
}

OpenaiConservation save each conservation of openai

type OpenaiMessage

type OpenaiMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

OpenaiMessage message from openai

type Price

type Price int

Price how many quotes for 1 usd

const (
	// PriceTxt2Image how many quotes for txt2image
	PriceTxt2Image  Price = 20000 // 0.04 usd
	PriceUploadFile Price = 2500  // 0.005 usd
)

func (Price) Int

func (p Price) Int() int

Int return int value

func (Price) USDCents

func (p Price) USDCents() int

USD100 return how many usd in cents

Jump to

Keyboard shortcuts

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