db

package
v0.0.0-...-b155b17 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 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
	// PriceTxt2ImageFluxPro is the price for txt2image flux pro
	//
	// https://replicate.com/pricing
	PriceTxt2ImageFluxPro Price = 27500      // 0.055 usd
	PriceTxt2ImageSchnell Price = 1500       // 0.003 usd
	PriceUploadFile       Price = 2500       // 0.005 usd
	PriceTTS              Price = 20         // 0.00004 usd
	PriceUSD              Price = 500000     // 1 usd
	PriceRMB              Price = 500000 / 8 // 1 rmb
)

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