service

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAuth

func RegisterAuth(i IAuth)

func RegisterChat

func RegisterChat(i IChat)

func RegisterCommon

func RegisterCommon(i ICommon)

func RegisterUser

func RegisterUser(i IUser)

func RegisterVip

func RegisterVip(i IVip)

Types

type IAuth

type IAuth interface {
	GetUid(ctx context.Context) int
	VerifyToken(ctx context.Context, token string) (bool, error)
	GetToken(ctx context.Context) string
	CheckUsage(ctx context.Context) bool
}

func Auth

func Auth() IAuth

type IChat

type IChat interface {
	Completions(ctx context.Context, params model.CompletionsReq) (response openai.ChatCompletionResponse, err error)
	CompletionsStream(ctx context.Context, params model.CompletionsReq) (err error)
}

func Chat

func Chat() IChat

type ICommon

type ICommon interface {
	VerifyToken(ctx context.Context, secretKey string) bool
	GetUidUsageKey(ctx context.Context) string
	RecordUsage(ctx context.Context, totalTokens int) error
	GetUsageCount(ctx context.Context) (int, error)
	GetUsedTokens(ctx context.Context) (int, error)
	GetTotalTokens(ctx context.Context) (int, error)
}

func Common

func Common() ICommon

type IUser

type IUser interface {
	// 根据userId获取用户信息
	GetUserById(ctx context.Context, userId int) (*model.User, error)
}

func User

func User() IUser

type IVip

type IVip interface {
	CheckUserVipPermissions(ctx context.Context, secretKey, model string) bool
}

func Vip

func Vip() IVip

Jump to

Keyboard shortcuts

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