model

package
v0.0.0-...-d55f1c7 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 43 Imported by: 75

Documentation

Index

Constants

View Source
const (
	SyncFrequency    = time.Minute * 3
	TokenCacheKey    = "token:%s"
	GroupCacheKey    = "group:%s"
	GroupModelTPMKey = "group:%s:model_tpm"
)
View Source
const (
	ChannelStatusUnknown  = 0
	ChannelStatusEnabled  = 1
	ChannelStatusDisabled = 2
)
View Source
const (
	GroupStatusEnabled  = 1
	GroupStatusDisabled = 2
	GroupStatusInternal = 3
)
View Source
const (
	ErrPublicMCPNotFound       = "public mcp"
	ErrMCPReusingParamNotFound = "mcp reusing param"
)
View Source
const (
	TokenStatusEnabled  = 1
	TokenStatusDisabled = 2
)
View Source
const (
	ChannelDefaultSet = "default"
)
View Source
const (
	DefaultPriority = 10
)
View Source
const (
	ErrChannelNotFound = "channel"
)
View Source
const (
	ErrGroupMCPNotFound = "group mcp"
)
View Source
const (
	ErrGroupNotFound = "group"
)
View Source
const ErrModelConfigNotFound = "model config"
View Source
const (
	ErrStoreNotFound = "store id"
)
View Source
const (
	ErrTokenNotFound = "token"
)
View Source
const (
	GroupMCPCacheKey = "group_mcp:%s:%s" // group_id:mcp_id
)
View Source
const (
	GroupModelConfigCacheKey = "group_model_config"
)
View Source
const (
	// /1K tokens
	PriceUnit = 1000
)
View Source
const (
	PublicMCPCacheKey = "public_mcp:%s" // mcp_id
)
View Source
const (
	PublicMCPReusingParamCacheKey = "public_mcp_param:%s:%s" // mcp_id:group_id
)
View Source
const (
	StoreCacheKey = "store:%s" // store_id
)

Variables

View Source
var (
	DB    *gorm.DB
	LogDB *gorm.DB
)
View Source
var ErrUnknownOptionKey = errors.New("unknown option key")

Functions

func BatchInsertChannels

func BatchInsertChannels(channels []*Channel) (err error)

func BatchRecordLogs

func BatchRecordLogs(
	requestID string,
	requestAt time.Time,
	retryAt time.Time,
	firstByteAt time.Time,
	group string,
	code int,
	channelID int,
	modelName string,
	tokenID int,
	tokenName string,
	endpoint string,
	content string,
	mode int,
	ip string,
	retryTimes int,
	requestDetail *RequestDetail,
	downstreamResult bool,
	usage Usage,
	modelPrice Price,
	amount float64,
	user string,
	metadata map[string]string,
) (err error)

func CacheDeleteGroup

func CacheDeleteGroup(id string) error

func CacheDeleteGroupMCP

func CacheDeleteGroupMCP(groupID, mcpID string) error

func CacheDeletePublicMCP

func CacheDeletePublicMCP(mcpID string) error

func CacheDeletePublicMCPReusingParam

func CacheDeletePublicMCPReusingParam(mcpID, groupID string) error

func CacheDeleteToken

func CacheDeleteToken(key string) error

func CacheSetGroup

func CacheSetGroup(group *GroupCache) error

func CacheSetGroupMCP

func CacheSetGroupMCP(groupMCP *GroupMCPCache) error

func CacheSetPublicMCP

func CacheSetPublicMCP(publicMCP *PublicMCPCache) error

func CacheSetPublicMCPReusingParam

func CacheSetPublicMCPReusingParam(param PublicMCPReusingParamCache) error

func CacheSetStore

func CacheSetStore(store *StoreCache) error

func CacheSetToken

func CacheSetToken(token *TokenCache) error

func CacheUpdateGroupMCPStatus

func CacheUpdateGroupMCPStatus(groupID, mcpID string, status GroupMCPStatus) error

func CacheUpdateGroupRPMRatio

func CacheUpdateGroupRPMRatio(id string, rpmRatio float64) error

func CacheUpdateGroupStatus

func CacheUpdateGroupStatus(id string, status int) error

func CacheUpdateGroupTPMRatio

func CacheUpdateGroupTPMRatio(id string, tpmRatio float64) error

func CacheUpdateGroupUsedAmountOnlyIncrease

func CacheUpdateGroupUsedAmountOnlyIncrease(id string, amount float64) error

func CacheUpdatePublicMCPStatus

func CacheUpdatePublicMCPStatus(mcpID string, status PublicMCPStatus) error

func CacheUpdateTokenName

func CacheUpdateTokenName(key, name string) error

func CacheUpdateTokenStatus

func CacheUpdateTokenStatus(key string, status int) error

func CacheUpdateTokenUsedAmountOnlyIncrease

func CacheUpdateTokenUsedAmountOnlyIncrease(key string, amount float64) error

func CheckModelConfigExist

func CheckModelConfigExist(models []string) error

func CleanBatchUpdatesSummary

func CleanBatchUpdatesSummary(ctx context.Context)

func CleanLog

func CleanLog(batchSize int, optimize bool) (err error)

func ClearLastTestErrorAt

func ClearLastTestErrorAt(id int) error

func CloseDB

func CloseDB() error

func CreateConsumeError

func CreateConsumeError(
	requestID string,
	requestAt time.Time,
	group, tokenName, model, content string,
	usedAmount float64,
	tokenID int,
) error

func CreateGroup

func CreateGroup(group *Group) error

func CreateGroupMCP

func CreateGroupMCP(mcp *GroupMCP) error

CreateGroupMCP creates a new GroupMCP

func CreateGroupSummaryIndexs

func CreateGroupSummaryIndexs(db *gorm.DB) error

func CreateGroupSummaryMinuteIndexs

func CreateGroupSummaryMinuteIndexs(db *gorm.DB) error

func CreateLogIndexes

func CreateLogIndexes(db *gorm.DB) error

func CreatePublicMCP

func CreatePublicMCP(mcp *PublicMCP) error

CreatePublicMCP creates a new MCP

func CreateSummaryIndexs

func CreateSummaryIndexs(db *gorm.DB) error

func CreateSummaryMinuteIndexs

func CreateSummaryMinuteIndexs(db *gorm.DB) error

func DeleteChannelByID

func DeleteChannelByID(id int) (err error)

func DeleteChannelsByIDs

func DeleteChannelsByIDs(ids []int) (err error)

func DeleteGroupByID

func DeleteGroupByID(id string) (err error)

func DeleteGroupLogs

func DeleteGroupLogs(groupID string) (int64, error)

func DeleteGroupMCP

func DeleteGroupMCP(id, groupID string) (err error)

DeleteGroupMCP deletes a GroupMCP by ID and GroupID

func DeleteGroupModelConfig

func DeleteGroupModelConfig(groupID, model string) error

func DeleteGroupModelConfigs

func DeleteGroupModelConfigs(groupID string, models []string) error

func DeleteGroupTokenByID

func DeleteGroupTokenByID(groupID string, id int) (err error)

func DeleteGroupTokensByIDs

func DeleteGroupTokensByIDs(group string, ids []int) (err error)

func DeleteGroupsByIDs

func DeleteGroupsByIDs(ids []string) (err error)

func DeleteModelConfig

func DeleteModelConfig(model string) error

func DeleteModelConfigsByModels

func DeleteModelConfigsByModels(models []string) error

func DeleteOldLog

func DeleteOldLog(timestamp time.Time) (int64, error)

func DeletePublicMCP

func DeletePublicMCP(id string) (err error)

DeletePublicMCP deletes an MCP by ID

func DeletePublicMCPReusingParam

func DeletePublicMCPReusingParam(mcpID, groupID string) (err error)

DeletePublicMCPReusingParam deletes a GroupMCPReusingParam

func DeleteTokenByID

func DeleteTokenByID(id int) (err error)

func DeleteTokensByIDs

func DeleteTokensByIDs(ids []int) (err error)

func GetGroupLastRequestTimeMinute

func GetGroupLastRequestTimeMinute(group string) (time.Time, error)

func GetGroupTokenLastRequestTimeMinute

func GetGroupTokenLastRequestTimeMinute(group, token string) (time.Time, error)

func GetGroupUsedModels

func GetGroupUsedModels(group, tokenName string, start, end time.Time) ([]string, error)

func GetGroupUsedModelsMinute

func GetGroupUsedModelsMinute(group, tokenName string, start, end time.Time) ([]string, error)

func GetGroupUsedTokenNames

func GetGroupUsedTokenNames(group string, start, end time.Time) ([]string, error)

func GetGroupUsedTokenNamesMinute

func GetGroupUsedTokenNamesMinute(group string, start, end time.Time) ([]string, error)

func GetIPGroups

func GetIPGroups(threshold int, start, end time.Time) (map[string][]string, error)

func GetModelConfigBool

func GetModelConfigBool(config map[ModelConfigKey]any, key ModelConfigKey) (bool, bool)

func GetModelConfigFloat

func GetModelConfigFloat(config map[ModelConfigKey]any, key ModelConfigKey) (float64, bool)

func GetModelConfigInt

func GetModelConfigInt(config map[ModelConfigKey]any, key ModelConfigKey) (int, bool)

func GetModelConfigStringSlice

func GetModelConfigStringSlice(config map[ModelConfigKey]any, key ModelConfigKey) ([]string, bool)

func GetModelConfigUint

func GetModelConfigUint(config map[ModelConfigKey]any, key ModelConfigKey) (uint64, bool)

func GetModelConfigWithModels

func GetModelConfigWithModels(models []string) ([]string, []string, error)

func GetPublicMCPsEmbedConfig

func GetPublicMCPsEmbedConfig(ids []string) (map[string]MCPEmbeddingConfig, error)

func GetPublicMCPsEnabled

func GetPublicMCPsEnabled(ids []string) ([]string, error)

func GetUsedChannels

func GetUsedChannels(start, end time.Time) ([]int, error)

func GetUsedChannelsMinute

func GetUsedChannelsMinute(start, end time.Time) ([]int, error)

func GetUsedModels

func GetUsedModels(start, end time.Time) ([]string, error)

func GetUsedModelsMinute

func GetUsedModelsMinute(start, end time.Time) ([]string, error)

func HandleNotFound

func HandleNotFound(err error, errMsg ...string) error

func HandleUpdateResult

func HandleUpdateResult(result *gorm.DB, entityName string) error

func IgnoreNotFound

func IgnoreNotFound(err error) error

func InitDB

func InitDB()

func InitLogDB

func InitLogDB()

func InitModelConfigAndChannelCache

func InitModelConfigAndChannelCache() error

InitModelConfigAndChannelCache initializes the channel cache from database

func InitOption2DB

func InitOption2DB() error

func InsertToken

func InsertToken(token *Token, autoCreateGroup, ignoreExist bool) error

func NewModelConfig

func NewModelConfig(opts ...ModelConfigOption) map[ModelConfigKey]any

func NotFoundError

func NotFoundError(errMsg ...string) error

func OnConflictDoNothing

func OnConflictDoNothing() *gorm.DB

func OpenMySQL

func OpenMySQL(dsn string) (*gorm.DB, error)

func OpenPostgreSQL

func OpenPostgreSQL(dsn string) (*gorm.DB, error)

func OpenSQLite

func OpenSQLite(sqlitePath string) (*gorm.DB, error)

func ProcessBatchUpdatesSummary

func ProcessBatchUpdatesSummary()

func RecordConsumeLog

func RecordConsumeLog(
	requestID string,
	createAt time.Time,
	requestAt time.Time,
	retryAt time.Time,
	firstByteAt time.Time,
	group string,
	code int,
	channelID int,
	modelName string,
	tokenID int,
	tokenName string,
	endpoint string,
	content string,
	mode int,
	ip string,
	retryTimes int,
	requestDetail *RequestDetail,
	usage Usage,
	modelPrice Price,
	amount float64,
	user string,
	metadata map[string]string,
) error

func RecordRetryLog

func RecordRetryLog(
	requestID string,
	createAt time.Time,
	requestAt time.Time,
	retryAt time.Time,
	firstByteAt time.Time,
	code int,
	channelID int,
	modelName string,
	mode int,
	retryTimes int,
	requestDetail *RequestDetail,
) error

func SaveGroupModelConfig

func SaveGroupModelConfig(groupModelConfig GroupModelConfig) (err error)

func SaveGroupModelConfigs

func SaveGroupModelConfigs(groupID string, groupModelConfigs []GroupModelConfig) (err error)

func SaveModelConfig

func SaveModelConfig(config ModelConfig) (err error)

func SaveModelConfigs

func SaveModelConfigs(configs []ModelConfig) (err error)

func SavePublicMCP

func SavePublicMCP(mcp *PublicMCP) (err error)

func SavePublicMCPReusingParam

func SavePublicMCPReusingParam(param *PublicMCPReusingParam) (err error)

func SavePublicMCPs

func SavePublicMCPs(msps []PublicMCP) (err error)

func SortModelConfigsFunc

func SortModelConfigsFunc(i, j ModelConfig) int

func StartBatchProcessorSummary

func StartBatchProcessorSummary(ctx context.Context, wg *sync.WaitGroup)

func String2Int

func String2Int(keyword string) int

func SyncModelConfigAndChannelCache

func SyncModelConfigAndChannelCache(
	ctx context.Context,
	wg *sync.WaitGroup,
	frequency time.Duration,
)

func SyncOptions

func SyncOptions(ctx context.Context, wg *sync.WaitGroup, frequency time.Duration)

func UpdateChannel

func UpdateChannel(channel *Channel) (err error)

func UpdateChannelStatusByID

func UpdateChannelStatusByID(id, status int) error

func UpdateChannelUsedAmount

func UpdateChannelUsedAmount(id int, amount float64, requestCount int) error

func UpdateGroup

func UpdateGroup(id string, group *Group) (err error)

func UpdateGroupMCP

func UpdateGroupMCP(mcp *GroupMCP) (err error)

UpdateGroupMCP updates an existing GroupMCP

func UpdateGroupMCPStatus

func UpdateGroupMCPStatus(id, groupID string, status GroupMCPStatus) (err error)

func UpdateGroupModelConfig

func UpdateGroupModelConfig(groupModelConfig GroupModelConfig) (err error)

func UpdateGroupModelConfigs

func UpdateGroupModelConfigs(groupID string, groupModelConfigs []GroupModelConfig) (err error)

func UpdateGroupRPMRatio

func UpdateGroupRPMRatio(id string, rpmRatio float64) (err error)

func UpdateGroupStatus

func UpdateGroupStatus(id string, status int) (err error)

func UpdateGroupTPMRatio

func UpdateGroupTPMRatio(id string, tpmRatio float64) (err error)

func UpdateGroupToken

func UpdateGroupToken(id int, group string, token *Token) (err error)

func UpdateGroupTokenName

func UpdateGroupTokenName(group string, id int, name string) (err error)

func UpdateGroupTokenStatus

func UpdateGroupTokenStatus(group string, id, status int) (err error)

func UpdateGroupUsedAmountAndRequestCount

func UpdateGroupUsedAmountAndRequestCount(id string, amount float64, count int) (err error)

func UpdateGroupsStatus

func UpdateGroupsStatus(ids []string, status int) (rowsAffected int64, err error)

func UpdateOption

func UpdateOption(key, value string) error

func UpdateOptions

func UpdateOptions(options map[string]string) error

func UpdatePublicMCP

func UpdatePublicMCP(mcp *PublicMCP) (err error)

UpdatePublicMCP updates an existing MCP

func UpdatePublicMCPReusingParam

func UpdatePublicMCPReusingParam(param *PublicMCPReusingParam) (err error)

UpdatePublicMCPReusingParam updates an existing GroupMCPReusingParam

func UpdatePublicMCPStatus

func UpdatePublicMCPStatus(id string, status PublicMCPStatus) (err error)

func UpdateToken

func UpdateToken(id int, token *Token) (err error)

func UpdateTokenName

func UpdateTokenName(id int, name string) (err error)

func UpdateTokenStatus

func UpdateTokenStatus(id, status int) (err error)

func UpdateTokenUsedAmount

func UpdateTokenUsedAmount(id int, amount float64, requestCount int) (err error)

func UpsertGroupSummary

func UpsertGroupSummary(unique GroupSummaryUnique, data SummaryData) error

func UpsertGroupSummaryMinute

func UpsertGroupSummaryMinute(unique GroupSummaryMinuteUnique, data SummaryData) error

func UpsertSummary

func UpsertSummary(unique SummaryUnique, data SummaryData) error

func UpsertSummaryMinute

func UpsertSummaryMinute(unique SummaryMinuteUnique, data SummaryData) error

Types

type Channel

type Channel struct {
	DeletedAt               gorm.DeletedAt    `gorm:"index"                              json:"-"`
	CreatedAt               time.Time         `gorm:"index"                              json:"created_at"`
	LastTestErrorAt         time.Time         `                                          json:"last_test_error_at"`
	ChannelTests            []*ChannelTest    `gorm:"foreignKey:ChannelID;references:ID" json:"channel_tests,omitempty"`
	BalanceUpdatedAt        time.Time         `                                          json:"balance_updated_at"`
	ModelMapping            map[string]string `gorm:"serializer:fastjson;type:text"      json:"model_mapping"`
	Key                     string            `gorm:"type:text;index"                    json:"key"`
	Name                    string            `gorm:"index"                              json:"name"`
	BaseURL                 string            `gorm:"index"                              json:"base_url"`
	Models                  []string          `gorm:"serializer:fastjson;type:text"      json:"models"`
	Balance                 float64           `                                          json:"balance"`
	ID                      int               `gorm:"primaryKey"                         json:"id"`
	UsedAmount              float64           `gorm:"index"                              json:"used_amount"`
	RequestCount            int               `gorm:"index"                              json:"request_count"`
	Status                  int               `gorm:"default:1;index"                    json:"status"`
	Type                    ChannelType       `gorm:"default:0;index"                    json:"type"`
	Priority                int32             `                                          json:"priority"`
	EnabledAutoBalanceCheck bool              `                                          json:"enabled_auto_balance_check"`
	BalanceThreshold        float64           `                                          json:"balance_threshold"`
	Config                  *ChannelConfig    `gorm:"serializer:fastjson;type:text"      json:"config,omitempty"`
	Sets                    []string          `gorm:"serializer:fastjson;type:text"      json:"sets,omitempty"`
}

func GetAllChannels

func GetAllChannels() (channels []*Channel, err error)

func GetChannelByID

func GetChannelByID(id int) (*Channel, error)

func GetChannels

func GetChannels(
	page, perPage, id int,
	name, key string,
	channelType int,
	baseURL, order string,
) (channels []*Channel, total int64, err error)

func LoadChannelByID

func LoadChannelByID(id int) (*Channel, error)

func LoadChannels

func LoadChannels() ([]*Channel, error)

func LoadDisabledChannels

func LoadDisabledChannels() ([]*Channel, error)

func LoadEnabledChannels

func LoadEnabledChannels() ([]*Channel, error)

func SearchChannels

func SearchChannels(
	keyword string,
	page, perPage, id int,
	name, key string,
	channelType int,
	baseURL, order string,
) (channels []*Channel, total int64, err error)

func (*Channel) BeforeDelete

func (c *Channel) BeforeDelete(tx *gorm.DB) (err error)

func (*Channel) GetBalanceThreshold

func (c *Channel) GetBalanceThreshold() float64

func (*Channel) GetPriority

func (c *Channel) GetPriority() int32

func (*Channel) GetSets

func (c *Channel) GetSets() []string

func (*Channel) MarshalJSON

func (c *Channel) MarshalJSON() ([]byte, error)

func (*Channel) UpdateBalance

func (c *Channel) UpdateBalance(balance float64) error

func (*Channel) UpdateModelTest

func (c *Channel) UpdateModelTest(
	testAt time.Time,
	model, actualModel string,
	mode mode.Mode,
	took float64,
	success bool,
	response string,
	code int,
) (*ChannelTest, error)

type ChannelConfig

type ChannelConfig struct {
	Spec json.RawMessage `json:"spec"`
}

func (*ChannelConfig) Get

func (c *ChannelConfig) Get(key ...any) (ast.Node, error)

func (*ChannelConfig) SpecConfig

func (c *ChannelConfig) SpecConfig(obj any) error

func (*ChannelConfig) UnmarshalJSON

func (c *ChannelConfig) UnmarshalJSON(data []byte) error

validate spec json is map[string]any

type ChannelTest

type ChannelTest struct {
	TestAt      time.Time   `json:"test_at"`
	Model       string      `json:"model"        gorm:"primaryKey"`
	ActualModel string      `json:"actual_model"`
	Response    string      `json:"response"     gorm:"type:text"`
	ChannelName string      `json:"channel_name"`
	ChannelType ChannelType `json:"channel_type"`
	ChannelID   int         `json:"channel_id"   gorm:"primaryKey"`
	Took        float64     `json:"took"`
	Success     bool        `json:"success"`
	Mode        mode.Mode   `json:"mode"`
	Code        int         `json:"code"`
}

func (*ChannelTest) MarshalJSON

func (ct *ChannelTest) MarshalJSON() ([]byte, error)

type ChannelType

type ChannelType int
const (
	ChannelTypeOpenAI                  ChannelType = 1
	ChannelTypeAzure                   ChannelType = 3
	ChannelTypeAzure2                  ChannelType = 4
	ChannelTypeGoogleGeminiOpenAI      ChannelType = 12
	ChannelTypeBaiduV2                 ChannelType = 13
	ChannelTypeAnthropic               ChannelType = 14
	ChannelTypeBaidu                   ChannelType = 15
	ChannelTypeZhipu                   ChannelType = 16
	ChannelTypeAli                     ChannelType = 17
	ChannelTypeXunfei                  ChannelType = 18
	ChannelTypeAI360                   ChannelType = 19
	ChannelTypeOpenRouter              ChannelType = 20
	ChannelTypeTencent                 ChannelType = 23
	ChannelTypeGoogleGemini            ChannelType = 24
	ChannelTypeMoonshot                ChannelType = 25
	ChannelTypeBaichuan                ChannelType = 26
	ChannelTypeMinimax                 ChannelType = 27
	ChannelTypeMistral                 ChannelType = 28
	ChannelTypeGroq                    ChannelType = 29
	ChannelTypeOllama                  ChannelType = 30
	ChannelTypeLingyiwanwu             ChannelType = 31
	ChannelTypeStepfun                 ChannelType = 32
	ChannelTypeAWS                     ChannelType = 33
	ChannelTypeCoze                    ChannelType = 34
	ChannelTypeCohere                  ChannelType = 35
	ChannelTypeDeepseek                ChannelType = 36
	ChannelTypeCloudflare              ChannelType = 37
	ChannelTypeDoubao                  ChannelType = 40
	ChannelTypeNovita                  ChannelType = 41
	ChannelTypeVertexAI                ChannelType = 42
	ChannelTypeSiliconflow             ChannelType = 43
	ChannelTypeDoubaoAudio             ChannelType = 44
	ChannelTypeXAI                     ChannelType = 45
	ChannelTypeDoc2x                   ChannelType = 46
	ChannelTypeJina                    ChannelType = 47
	ChannelTypeTextEmbeddingsInference ChannelType = 48
)

func AllChannelTypes

func AllChannelTypes() []ChannelType

func (ChannelType) String

func (c ChannelType) String() string

type ChannelUpdate

type ChannelUpdate struct {
	Amount decimal.Decimal
	Count  int
}

type ChartData

type ChartData struct {
	Timestamp    int64   `json:"timestamp"`
	RequestCount int64   `json:"request_count"`
	UsedAmount   float64 `json:"used_amount"`

	TotalTimeMilliseconds int64 `json:"total_time_milliseconds,omitempty"`
	TotalTTFBMilliseconds int64 `json:"total_ttfb_milliseconds,omitempty"`

	InputTokens         int64 `json:"input_tokens,omitempty"`
	ImageInputTokens    int64 `json:"image_input_tokens,omitempty"`
	AudioInputTokens    int64 `json:"audio_input_tokens,omitempty"`
	OutputTokens        int64 `json:"output_tokens,omitempty"`
	CachedTokens        int64 `json:"cached_tokens,omitempty"`
	CacheCreationTokens int64 `json:"cache_creation_tokens,omitempty"`
	TotalTokens         int64 `json:"total_tokens,omitempty"`
	ExceptionCount      int64 `json:"exception_count"`
	WebSearchCount      int64 `json:"web_search_count,omitempty"`

	MaxRPM int64 `json:"max_rpm,omitempty"`
	MaxTPM int64 `json:"max_tpm,omitempty"`
}

type CodeType

type CodeType string
const (
	CodeTypeAll     CodeType = "all"
	CodeTypeSuccess CodeType = "success"
	CodeTypeError   CodeType = "error"
)

type ConditionalPrice

type ConditionalPrice struct {
	Condition PriceCondition `json:"condition"`
	Price     Price          `json:"price"`
}

type ConsumeError

type ConsumeError struct {
	RequestAt  time.Time       `gorm:"index;index:idx_consume_error_group_reqat,priority:2" json:"request_at"`
	CreatedAt  time.Time       `                                                            json:"created_at"`
	GroupID    string          `gorm:"index;index:idx_consume_error_group_reqat,priority:1" json:"group_id"`
	RequestID  string          `gorm:"index"                                                json:"request_id"`
	TokenName  EmptyNullString `gorm:"not null"                                             json:"token_name"`
	Model      string          `                                                            json:"model"`
	Content    string          `gorm:"type:text"                                            json:"content"`
	ID         int             `gorm:"primaryKey"                                           json:"id"`
	UsedAmount float64         `                                                            json:"used_amount"`
	TokenID    int             `                                                            json:"token_id"`
}

func SearchConsumeError

func SearchConsumeError(
	keyword, requestID, group, tokenName, model string,
	tokenID, page, perPage int,
	order string,
) ([]*ConsumeError, int64, error)

func (*ConsumeError) MarshalJSON

func (c *ConsumeError) MarshalJSON() ([]byte, error)

type DashboardResponse

type DashboardResponse struct {
	ChartData             []*ChartData `json:"chart_data"`
	TotalCount            int64        `json:"total_count"`
	ExceptionCount        int64        `json:"exception_count"`
	TotalTimeMilliseconds int64        `json:"total_time_milliseconds,omitempty"`
	TotalTTFBMilliseconds int64        `json:"total_ttfb_milliseconds,omitempty"`

	RPM int64 `json:"rpm"`
	TPM int64 `json:"tpm"`

	MaxRPM int64 `json:"max_rpm,omitempty"`
	MaxTPM int64 `json:"max_tpm,omitempty"`

	UsedAmount          float64 `json:"used_amount"`
	InputTokens         int64   `json:"input_tokens,omitempty"`
	ImageInputTokens    int64   `json:"image_input_tokens,omitempty"`
	AudioInputTokens    int64   `json:"audio_input_tokens,omitempty"`
	OutputTokens        int64   `json:"output_tokens,omitempty"`
	TotalTokens         int64   `json:"total_tokens,omitempty"`
	CachedTokens        int64   `json:"cached_tokens,omitempty"`
	CacheCreationTokens int64   `json:"cache_creation_tokens,omitempty"`
	WebSearchCount      int64   `json:"web_search_count,omitempty"`

	Channels []int    `json:"channels,omitempty"`
	Models   []string `json:"models,omitempty"`
}

func GetDashboardData

func GetDashboardData(
	start,
	end time.Time,
	modelName string,
	channelID int,
	timeSpan TimeSpanType,
	timezone *time.Location,
) (*DashboardResponse, error)

func GetDashboardDataMinute

func GetDashboardDataMinute(
	start,
	end time.Time,
	modelName string,
	channelID int,
	timeSpan TimeSpanType,
	timezone *time.Location,
) (*DashboardResponse, error)

type EmptyNullString

type EmptyNullString string

func (*EmptyNullString) Scan

func (ns *EmptyNullString) Scan(value any) error

Scan implements the [Scanner] interface.

func (EmptyNullString) String

func (ns EmptyNullString) String() string

func (EmptyNullString) Value

func (ns EmptyNullString) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type GetGroupLogsResult

type GetGroupLogsResult struct {
	GetLogsResult
	Models     []string `json:"models"`
	TokenNames []string `json:"token_names"`
}

func GetGroupLogs

func GetGroupLogs(
	group string,
	startTimestamp time.Time,
	endTimestamp time.Time,
	modelName string,
	requestID string,
	tokenID int,
	tokenName string,
	order string,
	codeType CodeType,
	code int,
	withBody bool,
	ip string,
	user string,
	page int,
	perPage int,
) (*GetGroupLogsResult, error)

func SearchGroupLogs

func SearchGroupLogs(
	group string,
	keyword string,
	requestID string,
	tokenID int,
	tokenName string,
	modelName string,
	startTimestamp time.Time,
	endTimestamp time.Time,
	order string,
	codeType CodeType,
	code int,
	withBody bool,
	ip string,
	user string,
	page int,
	perPage int,
) (*GetGroupLogsResult, error)

type GetLogsResult

type GetLogsResult struct {
	Logs     []*Log `json:"logs"`
	Total    int64  `json:"total"`
	Channels []int  `json:"channels,omitempty"`
}

func GetLogs

func GetLogs(
	startTimestamp time.Time,
	endTimestamp time.Time,
	modelName string,
	requestID string,
	channelID int,
	order string,
	codeType CodeType,
	code int,
	withBody bool,
	ip string,
	user string,
	page int,
	perPage int,
) (*GetLogsResult, error)

func SearchLogs

func SearchLogs(
	keyword string,
	requestID string,
	tokenID int,
	modelName string,
	startTimestamp time.Time,
	endTimestamp time.Time,
	channelID int,
	order string,
	codeType CodeType,
	code int,
	withBody bool,
	ip string,
	user string,
	page int,
	perPage int,
) (*GetLogsResult, error)

type Group

type Group struct {
	CreatedAt              time.Time               `json:"created_at"`
	ID                     string                  `json:"id"                       gorm:"primaryKey"`
	Tokens                 []Token                 `json:"-"                        gorm:"foreignKey:GroupID"`
	GroupModelConfigs      []GroupModelConfig      `json:"-"                        gorm:"foreignKey:GroupID"`
	PublicMCPReusingParams []PublicMCPReusingParam `json:"-"                        gorm:"foreignKey:GroupID"`
	GroupMCPs              []GroupMCP              `json:"-"                        gorm:"foreignKey:GroupID"`
	Status                 int                     `json:"status"                   gorm:"default:1;index"`
	RPMRatio               float64                 `json:"rpm_ratio,omitempty"      gorm:"index"`
	TPMRatio               float64                 `json:"tpm_ratio,omitempty"      gorm:"index"`
	UsedAmount             float64                 `json:"used_amount"              gorm:"index"`
	RequestCount           int                     `json:"request_count"            gorm:"index"`
	AvailableSets          []string                `json:"available_sets,omitempty" gorm:"serializer:fastjson;type:text"`

	BalanceAlertEnabled   bool    `gorm:"default:false" json:"balance_alert_enabled"`
	BalanceAlertThreshold float64 `gorm:"default:0"     json:"balance_alert_threshold"`
}

func GetGroupByID

func GetGroupByID(id string, preloadGroupModelConfigs bool) (*Group, error)

func GetGroups

func GetGroups(
	page, perPage int,
	order string,
	onlyDisabled bool,
) (groups []*Group, total int64, err error)

func SearchGroup

func SearchGroup(
	keyword string,
	page, perPage int,
	order string,
	status int,
) (groups []*Group, total int64, err error)

func (*Group) BeforeDelete

func (g *Group) BeforeDelete(tx *gorm.DB) (err error)

func (*Group) ToGroupCache

func (g *Group) ToGroupCache() *GroupCache

type GroupCache

type GroupCache struct {
	ID            string                   `json:"-"              redis:"-"`
	Status        int                      `json:"status"         redis:"st"`
	UsedAmount    float64                  `json:"used_amount"    redis:"ua"`
	RPMRatio      float64                  `json:"rpm_ratio"      redis:"rpm_r"`
	TPMRatio      float64                  `json:"tpm_ratio"      redis:"tpm_r"`
	AvailableSets redisStringSlice         `json:"available_sets" redis:"ass"`
	ModelConfigs  redisGroupModelConfigMap `json:"model_configs"  redis:"mc"`

	BalanceAlertEnabled   bool    `json:"balance_alert_enabled"   redis:"bae"`
	BalanceAlertThreshold float64 `json:"balance_alert_threshold" redis:"bat"`
}

func CacheGetGroup

func CacheGetGroup(id string) (*GroupCache, error)

func (*GroupCache) GetAvailableSets

func (g *GroupCache) GetAvailableSets() []string

type GroupDashboardResponse

type GroupDashboardResponse struct {
	DashboardResponse
	TokenNames []string `json:"token_names"`
}

func GetGroupDashboardData

func GetGroupDashboardData(
	group string,
	start, end time.Time,
	tokenName string,
	modelName string,
	timeSpan TimeSpanType,
	timezone *time.Location,
) (*GroupDashboardResponse, error)

func GetGroupDashboardDataMinute

func GetGroupDashboardDataMinute(
	group string,
	start, end time.Time,
	tokenName string,
	modelName string,
	timeSpan TimeSpanType,
	timezone *time.Location,
) (*GroupDashboardResponse, error)

type GroupMCP

type GroupMCP struct {
	ID            string               `gorm:"primaryKey"                    json:"id"`
	GroupID       string               `gorm:"primaryKey"                    json:"group_id"`
	Group         *Group               `gorm:"foreignKey:GroupID"            json:"-"`
	Status        GroupMCPStatus       `gorm:"index;default:1"               json:"status"`
	CreatedAt     time.Time            `gorm:"index,autoCreateTime"          json:"created_at"`
	UpdateAt      time.Time            `gorm:"index,autoUpdateTime"          json:"update_at"`
	Name          string               `                                     json:"name"`
	Type          GroupMCPType         `gorm:"index"                         json:"type"`
	Description   string               `                                     json:"description"`
	ProxyConfig   *GroupMCPProxyConfig `gorm:"serializer:fastjson;type:text" json:"proxy_config,omitempty"`
	OpenAPIConfig *MCPOpenAPIConfig    `gorm:"serializer:fastjson;type:text" json:"openapi_config,omitempty"`
}

func GetAllGroupMCPs

func GetAllGroupMCPs(status GroupMCPStatus) ([]GroupMCP, error)

func GetGroupMCPByID

func GetGroupMCPByID(id, groupID string) (GroupMCP, error)

GetGroupMCPByID retrieves a GroupMCP by ID and GroupID

func GetGroupMCPs

func GetGroupMCPs(
	groupID string,
	page, perPage int,
	id string,
	mcpType GroupMCPType,
	keyword string,
	status GroupMCPStatus,
) (mcps []GroupMCP, total int64, err error)

GetGroupMCPs retrieves GroupMCPs with pagination and filtering

func (*GroupMCP) BeforeSave

func (g *GroupMCP) BeforeSave(_ *gorm.DB) (err error)

func (*GroupMCP) ToGroupMCPCache

func (g *GroupMCP) ToGroupMCPCache() *GroupMCPCache

type GroupMCPCache

type GroupMCPCache struct {
	ID            string               `json:"id"             redis:"i"`
	GroupID       string               `json:"group_id"       redis:"g"`
	Status        GroupMCPStatus       `json:"status"         redis:"s"`
	Type          GroupMCPType         `json:"type"           redis:"t"`
	ProxyConfig   *GroupMCPProxyConfig `json:"proxy_config"   redis:"pc"`
	OpenAPIConfig *MCPOpenAPIConfig    `json:"openapi_config" redis:"oc"`
}

func CacheGetGroupMCP

func CacheGetGroupMCP(groupID, mcpID string) (*GroupMCPCache, error)

type GroupMCPProxyConfig

type GroupMCPProxyConfig struct {
	URL     string            `json:"url"`
	Querys  map[string]string `json:"querys"`
	Headers map[string]string `json:"headers"`
}

type GroupMCPStatus

type GroupMCPStatus int
const (
	GroupMCPStatusEnabled GroupMCPStatus = iota + 1
	GroupMCPStatusDisabled
)

type GroupMCPType

type GroupMCPType string
const (
	GroupMCPTypeProxySSE        GroupMCPType = "mcp_proxy_sse"
	GroupMCPTypeProxyStreamable GroupMCPType = "mcp_proxy_streamable"
	GroupMCPTypeOpenAPI         GroupMCPType = "mcp_openapi"
)

type GroupModelConfig

type GroupModelConfig struct {
	GroupID string `gorm:"primaryKey"         json:"group_id"`
	Group   *Group `gorm:"foreignKey:GroupID" json:"-"`
	Model   string `gorm:"primaryKey"         json:"model"`

	OverrideLimit bool  `json:"override_limit"`
	RPM           int64 `json:"rpm"`
	TPM           int64 `json:"tpm"`

	OverridePrice bool               `json:"override_price"`
	ImagePrices   map[string]float64 `json:"image_prices,omitempty" gorm:"serializer:fastjson;type:text"`
	Price         Price              `json:"price,omitempty"        gorm:"embedded"`

	OverrideRetryTimes bool  `json:"override_retry_times"`
	RetryTimes         int64 `json:"retry_times"`

	OverrideForceSaveDetail bool `json:"override_force_save_detail"`
	ForceSaveDetail         bool `json:"force_save_detail"`
}

func GetGroupModelConfig

func GetGroupModelConfig(groupID, model string) (*GroupModelConfig, error)

func GetGroupModelConfigs

func GetGroupModelConfigs(groupID string) ([]GroupModelConfig, error)

func (*GroupModelConfig) BeforeSave

func (g *GroupModelConfig) BeforeSave(_ *gorm.DB) (err error)

type GroupSummary

type GroupSummary struct {
	ID     int                `gorm:"primaryKey"`
	Unique GroupSummaryUnique `gorm:"embedded"`
	Data   SummaryData        `gorm:"embedded"`
}

only summary result only requests

func (*GroupSummary) BeforeCreate

func (l *GroupSummary) BeforeCreate(_ *gorm.DB) (err error)

type GroupSummaryMinute

type GroupSummaryMinute struct {
	ID     int                      `gorm:"primaryKey"`
	Unique GroupSummaryMinuteUnique `gorm:"embedded"`
	Data   SummaryData              `gorm:"embedded"`
}

only summary result only requests

func (*GroupSummaryMinute) BeforeCreate

func (l *GroupSummaryMinute) BeforeCreate(_ *gorm.DB) (err error)

type GroupSummaryMinuteUnique

type GroupSummaryMinuteUnique struct {
	GroupID         string `gorm:"not null;uniqueIndex:idx_groupsummary_minute_unique,priority:1"`
	TokenName       string `gorm:"not null;uniqueIndex:idx_groupsummary_minute_unique,priority:2"`
	Model           string `gorm:"not null;uniqueIndex:idx_groupsummary_minute_unique,priority:3"`
	MinuteTimestamp int64  `gorm:"not null;uniqueIndex:idx_groupsummary_minute_unique,priority:4,sort:desc"`
}

type GroupSummaryMinuteUpdate

type GroupSummaryMinuteUpdate struct {
	GroupSummaryMinuteUnique
	SummaryData
}

type GroupSummaryUnique

type GroupSummaryUnique struct {
	GroupID       string `gorm:"not null;uniqueIndex:idx_groupsummary_unique,priority:1"`
	TokenName     string `gorm:"not null;uniqueIndex:idx_groupsummary_unique,priority:2"`
	Model         string `gorm:"not null;uniqueIndex:idx_groupsummary_unique,priority:3"`
	HourTimestamp int64  `gorm:"not null;uniqueIndex:idx_groupsummary_unique,priority:4,sort:desc"`
}

type GroupSummaryUpdate

type GroupSummaryUpdate struct {
	GroupSummaryUnique
	SummaryData
}

type GroupUpdate

type GroupUpdate struct {
	Amount decimal.Decimal
	Count  int
}

type Log

type Log struct {
	RequestDetail    *RequestDetail  `gorm:"foreignKey:LogID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"request_detail,omitempty"`
	RequestAt        time.Time       `                                                                      json:"request_at"`
	RetryAt          time.Time       `                                                                      json:"retry_at,omitempty"`
	TTFBMilliseconds ZeroNullInt64   `                                                                      json:"ttfb_milliseconds,omitempty"`
	CreatedAt        time.Time       `gorm:"autoCreateTime;index"                                           json:"created_at"`
	TokenName        string          `                                                                      json:"token_name,omitempty"`
	Endpoint         EmptyNullString `                                                                      json:"endpoint,omitempty"`
	Content          EmptyNullString `gorm:"type:text"                                                      json:"content,omitempty"`
	GroupID          string          `                                                                      json:"group,omitempty"`
	Model            string          `                                                                      json:"model"`
	RequestID        EmptyNullString `gorm:"index:,where:request_id is not null"                            json:"request_id"`
	ID               int             `gorm:"primaryKey"                                                     json:"id"`
	TokenID          int             `gorm:"index"                                                          json:"token_id,omitempty"`
	ChannelID        int             `                                                                      json:"channel,omitempty"`
	Code             int             `gorm:"index"                                                          json:"code,omitempty"`
	Mode             int             `                                                                      json:"mode,omitempty"`
	IP               EmptyNullString `gorm:"index:,where:ip is not null"                                    json:"ip,omitempty"`
	RetryTimes       ZeroNullInt64   `                                                                      json:"retry_times,omitempty"`
	Price            Price           `gorm:"embedded"                                                       json:"price,omitempty"`
	Usage            Usage           `gorm:"embedded"                                                       json:"usage,omitempty"`
	UsedAmount       float64         `                                                                      json:"used_amount,omitempty"`
	// https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids
	User     EmptyNullString   `                                                                      json:"user,omitempty"`
	Metadata map[string]string `gorm:"serializer:fastjson;type:text"                                  json:"metadata,omitempty"`
}

func (*Log) BeforeCreate

func (l *Log) BeforeCreate(_ *gorm.DB) (err error)

func (*Log) MarshalJSON

func (l *Log) MarshalJSON() ([]byte, error)

type MCPEmbeddingConfig

type MCPEmbeddingConfig struct {
	Init    map[string]string       `json:"init"`
	Reusing map[string]ReusingParam `json:"reusing"`
}

type MCPOpenAPIConfig

type MCPOpenAPIConfig struct {
	OpenAPISpec    string `json:"openapi_spec"`
	OpenAPIContent string `json:"openapi_content,omitempty"`
	V2             bool   `json:"v2"`
	ServerAddr     string `json:"server_addr,omitempty"`
	Authorization  string `json:"authorization,omitempty"`
}

type MCPPrice

type MCPPrice struct {
	DefaultToolsCallPrice float64            `json:"default_tools_call_price"`
	ToolsCallPrices       map[string]float64 `json:"tools_call_prices"        gorm:"serializer:fastjson;type:text"`
}

type ModelCaches

type ModelCaches struct {
	ModelConfig ModelConfigCache

	// map[set][]model
	EnabledModelsBySet map[string][]string
	// map[set][]modelconfig
	EnabledModelConfigsBySet map[string][]ModelConfig
	// map[model]modelconfig
	EnabledModelConfigsMap map[string]ModelConfig

	// map[set]map[model][]channel
	EnabledModel2ChannelsBySet map[string]map[string][]*Channel
	// map[set]map[model][]channel
	DisabledModel2ChannelsBySet map[string]map[string][]*Channel
}

func LoadModelCaches

func LoadModelCaches() *ModelCaches

type ModelConfig

type ModelConfig struct {
	CreatedAt        time.Time                  `gorm:"index;autoCreateTime"          json:"created_at"`
	UpdatedAt        time.Time                  `gorm:"index;autoUpdateTime"          json:"updated_at"`
	Config           map[ModelConfigKey]any     `gorm:"serializer:fastjson;type:text" json:"config,omitempty"`
	Plugin           map[string]json.RawMessage `gorm:"serializer:fastjson;type:text" json:"plugin,omitempty"`
	Model            string                     `gorm:"primaryKey"                    json:"model"`
	Owner            ModelOwner                 `gorm:"type:varchar(255);index"       json:"owner"`
	Type             mode.Mode                  `                                     json:"type"`
	ExcludeFromTests bool                       `                                     json:"exclude_from_tests,omitempty"`
	RPM              int64                      `                                     json:"rpm,omitempty"`
	TPM              int64                      `                                     json:"tpm,omitempty"`
	// map[size]map[quality]price_per_image
	ImageQualityPrices map[string]map[string]float64 `gorm:"serializer:fastjson;type:text" json:"image_quality_prices,omitempty"`
	// map[size]price_per_image
	ImagePrices     map[string]float64 `gorm:"serializer:fastjson;type:text" json:"image_prices,omitempty"`
	Price           Price              `gorm:"embedded"                      json:"price,omitempty"`
	RetryTimes      int64              `                                     json:"retry_times,omitempty"`
	Timeout         int64              `                                     json:"timeout,omitempty"`
	MaxErrorRate    float64            `                                     json:"max_error_rate,omitempty"`
	ForceSaveDetail bool               `                                     json:"force_save_detail,omitempty"`
}

func GetAllModelConfigs

func GetAllModelConfigs() (configs []ModelConfig, err error)

func GetModelConfig

func GetModelConfig(model string) (ModelConfig, error)

func GetModelConfigs

func GetModelConfigs(
	page, perPage int,
	model string,
) (configs []*ModelConfig, total int64, err error)

func GetModelConfigsByModels

func GetModelConfigsByModels(models []string) (configs []ModelConfig, err error)

func NewDefaultModelConfig

func NewDefaultModelConfig(model string) ModelConfig

func SearchModelConfigs

func SearchModelConfigs(
	keyword string,
	page, perPage int,
	model string,
	owner ModelOwner,
) (configs []ModelConfig, total int64, err error)

func (*ModelConfig) BeforeSave

func (c *ModelConfig) BeforeSave(_ *gorm.DB) (err error)

func (*ModelConfig) LoadFromGroupModelConfig

func (c *ModelConfig) LoadFromGroupModelConfig(groupModelConfig GroupModelConfig) ModelConfig

func (*ModelConfig) LoadPluginConfig

func (c *ModelConfig) LoadPluginConfig(pluginName string, config any) error

func (*ModelConfig) MarshalJSON

func (c *ModelConfig) MarshalJSON() ([]byte, error)

func (*ModelConfig) MaxContextTokens

func (c *ModelConfig) MaxContextTokens() (int, bool)

func (*ModelConfig) MaxInputTokens

func (c *ModelConfig) MaxInputTokens() (int, bool)

func (*ModelConfig) MaxOutputTokens

func (c *ModelConfig) MaxOutputTokens() (int, bool)

func (*ModelConfig) SupportFormats

func (c *ModelConfig) SupportFormats() ([]string, bool)

func (*ModelConfig) SupportToolChoice

func (c *ModelConfig) SupportToolChoice() (bool, bool)

func (*ModelConfig) SupportVision

func (c *ModelConfig) SupportVision() (bool, bool)

func (*ModelConfig) SupportVoices

func (c *ModelConfig) SupportVoices() ([]string, bool)

type ModelConfigCache

type ModelConfigCache interface {
	GetModelConfig(model string) (ModelConfig, bool)
}

type ModelConfigKey

type ModelConfigKey string
const (
	ModelConfigMaxContextTokensKey ModelConfigKey = "max_context_tokens"
	ModelConfigMaxInputTokensKey   ModelConfigKey = "max_input_tokens"
	ModelConfigMaxOutputTokensKey  ModelConfigKey = "max_output_tokens"
	ModelConfigVisionKey           ModelConfigKey = "vision"
	ModelConfigToolChoiceKey       ModelConfigKey = "tool_choice"
	ModelConfigSupportFormatsKey   ModelConfigKey = "support_formats"
	ModelConfigSupportVoicesKey    ModelConfigKey = "support_voices"
	ModelConfigImageSizes          ModelConfigKey = "image_sizes"
	ModelConfigImageQualitys       ModelConfigKey = "image_qualitys"
)

type ModelConfigOption

type ModelConfigOption func(config map[ModelConfigKey]any)

func WithModelConfigImageQualitys

func WithModelConfigImageQualitys(qualitys ...string) ModelConfigOption

func WithModelConfigImageSizes

func WithModelConfigImageSizes(sizes ...string) ModelConfigOption

func WithModelConfigMaxContextTokens

func WithModelConfigMaxContextTokens(maxContextTokens int) ModelConfigOption

func WithModelConfigMaxInputTokens

func WithModelConfigMaxInputTokens(maxInputTokens int) ModelConfigOption

func WithModelConfigMaxOutputTokens

func WithModelConfigMaxOutputTokens(maxOutputTokens int) ModelConfigOption

func WithModelConfigSupportFormats

func WithModelConfigSupportFormats(supportFormats []string) ModelConfigOption

func WithModelConfigSupportVoices

func WithModelConfigSupportVoices(supportVoices []string) ModelConfigOption

func WithModelConfigToolChoice

func WithModelConfigToolChoice(toolChoice bool) ModelConfigOption

func WithModelConfigVision

func WithModelConfigVision(vision bool) ModelConfigOption

type ModelOwner

type ModelOwner string
const (
	ModelOwnerOpenAI      ModelOwner = "openai"
	ModelOwnerAlibaba     ModelOwner = "alibaba"
	ModelOwnerTencent     ModelOwner = "tencent"
	ModelOwnerXunfei      ModelOwner = "xunfei"
	ModelOwnerDeepSeek    ModelOwner = "deepseek"
	ModelOwnerMoonshot    ModelOwner = "moonshot"
	ModelOwnerMiniMax     ModelOwner = "minimax"
	ModelOwnerBaidu       ModelOwner = "baidu"
	ModelOwnerGoogle      ModelOwner = "google"
	ModelOwnerBAAI        ModelOwner = "baai"
	ModelOwnerFunAudioLLM ModelOwner = "funaudiollm"
	ModelOwnerDoubao      ModelOwner = "doubao"
	ModelOwnerFishAudio   ModelOwner = "fishaudio"
	ModelOwnerChatGLM     ModelOwner = "chatglm"
	ModelOwnerStabilityAI ModelOwner = "stabilityai"
	ModelOwnerNetease     ModelOwner = "netease"
	ModelOwnerAI360       ModelOwner = "ai360"
	ModelOwnerAnthropic   ModelOwner = "anthropic"
	ModelOwnerMeta        ModelOwner = "meta"
	ModelOwnerBaichuan    ModelOwner = "baichuan"
	ModelOwnerMistral     ModelOwner = "mistral"
	ModelOwnerOpenChat    ModelOwner = "openchat"
	ModelOwnerMicrosoft   ModelOwner = "microsoft"
	ModelOwnerDefog       ModelOwner = "defog"
	ModelOwnerNexusFlow   ModelOwner = "nexusflow"
	ModelOwnerCohere      ModelOwner = "cohere"
	ModelOwnerHuggingFace ModelOwner = "huggingface"
	ModelOwnerLingyiWanwu ModelOwner = "lingyiwanwu"
	ModelOwnerStepFun     ModelOwner = "stepfun"
	ModelOwnerXAI         ModelOwner = "xai"
	ModelOwnerDoc2x       ModelOwner = "doc2x"
	ModelOwnerJina        ModelOwner = "jina"
)

type Option

type Option struct {
	Key   string `gorm:"primaryKey" json:"key"`
	Value string `                  json:"value"`
}

func GetAllOption

func GetAllOption() ([]*Option, error)

func GetOption

func GetOption(key string) (*Option, error)

type Params

type Params = map[string]string

type Price

type Price struct {
	PerRequestPrice ZeroNullFloat64 `json:"per_request_price,omitempty"`

	InputPrice     ZeroNullFloat64 `json:"input_price,omitempty"`
	InputPriceUnit ZeroNullInt64   `json:"input_price_unit,omitempty"`

	ImageInputPrice     ZeroNullFloat64 `json:"image_input_price,omitempty"`
	ImageInputPriceUnit ZeroNullInt64   `json:"image_input_price_unit,omitempty"`

	AudioInputPrice     ZeroNullFloat64 `json:"audio_input_price,omitempty"`
	AudioInputPriceUnit ZeroNullInt64   `json:"audio_input_price_unit,omitempty"`

	OutputPrice     ZeroNullFloat64 `json:"output_price,omitempty"`
	OutputPriceUnit ZeroNullInt64   `json:"output_price_unit,omitempty"`

	// when ThinkingModeOutputPrice and ReasoningTokens are not 0, OutputPrice and OutputPriceUnit
	// will be overwritten
	ThinkingModeOutputPrice     ZeroNullFloat64 `json:"thinking_mode_output_price,omitempty"`
	ThinkingModeOutputPriceUnit ZeroNullInt64   `json:"thinking_mode_output_price_unit,omitempty"`

	CachedPrice     ZeroNullFloat64 `json:"cached_price,omitempty"`
	CachedPriceUnit ZeroNullInt64   `json:"cached_price_unit,omitempty"`

	CacheCreationPrice     ZeroNullFloat64 `json:"cache_creation_price,omitempty"`
	CacheCreationPriceUnit ZeroNullInt64   `json:"cache_creation_price_unit,omitempty"`

	WebSearchPrice     ZeroNullFloat64 `json:"web_search_price,omitempty"`
	WebSearchPriceUnit ZeroNullInt64   `json:"web_search_price_unit,omitempty"`

	ConditionalPrices []ConditionalPrice `gorm:"serializer:fastjson;type:text" json:"conditional_prices,omitempty"`
}

func (*Price) GetAudioInputPriceUnit

func (p *Price) GetAudioInputPriceUnit() int64

func (*Price) GetCacheCreationPriceUnit

func (p *Price) GetCacheCreationPriceUnit() int64

func (*Price) GetCachedPriceUnit

func (p *Price) GetCachedPriceUnit() int64

func (*Price) GetImageInputPriceUnit

func (p *Price) GetImageInputPriceUnit() int64

func (*Price) GetInputPriceUnit

func (p *Price) GetInputPriceUnit() int64

func (*Price) GetOutputPriceUnit

func (p *Price) GetOutputPriceUnit() int64

func (*Price) GetWebSearchPriceUnit

func (p *Price) GetWebSearchPriceUnit() int64

func (*Price) SelectConditionalPrice

func (p *Price) SelectConditionalPrice(usage Usage) Price

func (*Price) ValidateConditionalPrices

func (p *Price) ValidateConditionalPrices() error

type PriceCondition

type PriceCondition struct {
	InputTokenMin  int64 `json:"input_token_min,omitempty"`
	InputTokenMax  int64 `json:"input_token_max,omitempty"`
	OutputTokenMin int64 `json:"output_token_min,omitempty"`
	OutputTokenMax int64 `json:"output_token_max,omitempty"`
}

type ProxyParamType

type ProxyParamType string
const (
	ParamTypeURL    ProxyParamType = "url"
	ParamTypeHeader ProxyParamType = "header"
	ParamTypeQuery  ProxyParamType = "query"
)

type PublicMCP

type PublicMCP struct {
	ID                     string                  `gorm:"primaryKey"           json:"id"`
	CreatedAt              time.Time               `gorm:"index,autoCreateTime" json:"created_at"`
	UpdateAt               time.Time               `gorm:"index,autoUpdateTime" json:"update_at"`
	PublicMCPReusingParams []PublicMCPReusingParam `gorm:"foreignKey:MCPID"     json:"-"`

	Name          string          `json:"name"`
	NameCN        string          `json:"name_cn,omitempty"`
	Status        PublicMCPStatus `json:"status"                   gorm:"index;default:1"`
	Type          PublicMCPType   `json:"type,omitempty"           gorm:"index"`
	Description   string          `json:"description"`
	DescriptionCN string          `json:"description_cn,omitempty"`
	GitHubURL     string          `json:"github_url"`
	Readme        string          `json:"readme,omitempty"         gorm:"type:text"`
	ReadmeCN      string          `json:"readme_cn,omitempty"      gorm:"type:text"`
	ReadmeURL     string          `json:"readme_url,omitempty"`
	ReadmeCNURL   string          `json:"readme_cn_url,omitempty"`
	Tags          []string        `json:"tags,omitempty"           gorm:"serializer:fastjson;type:text"`
	LogoURL       string          `json:"logo_url,omitempty"`
	Price         MCPPrice        `json:"price"                    gorm:"embedded"`

	ProxyConfig   *PublicMCPProxyConfig `gorm:"serializer:fastjson;type:text" json:"proxy_config,omitempty"`
	OpenAPIConfig *MCPOpenAPIConfig     `gorm:"serializer:fastjson;type:text" json:"openapi_config,omitempty"`
	EmbedConfig   *MCPEmbeddingConfig   `gorm:"serializer:fastjson;type:text" json:"embed_config,omitempty"`
	// only used by list tools
	TestConfig *TestConfig `gorm:"serializer:fastjson;type:text" json:"test_config,omitempty"`
}

func GetAllPublicMCPs

func GetAllPublicMCPs(status PublicMCPStatus) ([]PublicMCP, error)

func GetPublicMCPByID

func GetPublicMCPByID(id string) (PublicMCP, error)

GetPublicMCPByID retrieves an MCP by ID

func GetPublicMCPs

func GetPublicMCPs(
	page, perPage int,
	id string,
	mcpType []PublicMCPType,
	keyword string,
	status PublicMCPStatus,
) (mcps []PublicMCP, total int64, err error)

GetPublicMCPs retrieves MCPs with pagination and filtering

func (*PublicMCP) BeforeCreate

func (p *PublicMCP) BeforeCreate(_ *gorm.DB) error

func (*PublicMCP) BeforeDelete

func (p *PublicMCP) BeforeDelete(tx *gorm.DB) (err error)

func (*PublicMCP) BeforeSave

func (p *PublicMCP) BeforeSave(_ *gorm.DB) error

func (*PublicMCP) ToPublicMCPCache

func (p *PublicMCP) ToPublicMCPCache() *PublicMCPCache

type PublicMCPCache

type PublicMCPCache struct {
	ID            string                `json:"id"             redis:"i"`
	Status        PublicMCPStatus       `json:"status"         redis:"s"`
	Type          PublicMCPType         `json:"type"           redis:"t"`
	Price         MCPPrice              `json:"price"          redis:"p"`
	ProxyConfig   *PublicMCPProxyConfig `json:"proxy_config"   redis:"pc"`
	OpenAPIConfig *MCPOpenAPIConfig     `json:"openapi_config" redis:"oc"`
	EmbedConfig   *MCPEmbeddingConfig   `json:"embed_config"   redis:"ec"`
}

func CacheGetPublicMCP

func CacheGetPublicMCP(mcpID string) (*PublicMCPCache, error)

type PublicMCPProxyConfig

type PublicMCPProxyConfig struct {
	URL     string                                `json:"url"`
	Querys  map[string]string                     `json:"querys"`
	Headers map[string]string                     `json:"headers"`
	Reusing map[string]PublicMCPProxyReusingParam `json:"reusing"`
}

type PublicMCPProxyReusingParam

type PublicMCPProxyReusingParam struct {
	ReusingParam
	Type ProxyParamType `json:"type"`
}

type PublicMCPReusingParam

type PublicMCPReusingParam struct {
	MCPID     string    `gorm:"primaryKey"                    json:"mcp_id"`
	GroupID   string    `gorm:"primaryKey"                    json:"group_id"`
	CreatedAt time.Time `gorm:"index"                         json:"created_at"`
	UpdateAt  time.Time `gorm:"index"                         json:"update_at"`
	Group     *Group    `gorm:"foreignKey:GroupID"            json:"-"`
	Params    Params    `gorm:"serializer:fastjson;type:text" json:"params"`
}

func GetPublicMCPReusingParam

func GetPublicMCPReusingParam(mcpID, groupID string) (PublicMCPReusingParam, error)

GetPublicMCPReusingParam retrieves a GroupMCPReusingParam by MCP ID and Group ID

func (*PublicMCPReusingParam) BeforeCreate

func (p *PublicMCPReusingParam) BeforeCreate(_ *gorm.DB) (err error)

func (*PublicMCPReusingParam) MarshalJSON

func (p *PublicMCPReusingParam) MarshalJSON() ([]byte, error)

func (*PublicMCPReusingParam) ToPublicMCPReusingParamCache

func (p *PublicMCPReusingParam) ToPublicMCPReusingParamCache() PublicMCPReusingParamCache

type PublicMCPReusingParamCache

type PublicMCPReusingParamCache struct {
	MCPID   string                   `json:"mcp_id"   redis:"m"`
	GroupID string                   `json:"group_id" redis:"g"`
	Params  redisMap[string, string] `json:"params"   redis:"p"`
}

func CacheGetPublicMCPReusingParam

func CacheGetPublicMCPReusingParam(mcpID, groupID string) (PublicMCPReusingParamCache, error)

type PublicMCPStatus

type PublicMCPStatus int
const (
	PublicMCPStatusEnabled PublicMCPStatus = iota + 1
	PublicMCPStatusDisabled
)

type PublicMCPType

type PublicMCPType string
const (
	PublicMCPTypeProxySSE        PublicMCPType = "mcp_proxy_sse"
	PublicMCPTypeProxyStreamable PublicMCPType = "mcp_proxy_streamable"
	PublicMCPTypeDocs            PublicMCPType = "mcp_docs" // read only
	PublicMCPTypeOpenAPI         PublicMCPType = "mcp_openapi"
	PublicMCPTypeEmbed           PublicMCPType = "mcp_embed"
)

type RequestDetail

type RequestDetail struct {
	CreatedAt             time.Time `gorm:"autoCreateTime;index" json:"-"`
	RequestBody           string    `gorm:"type:text"            json:"request_body,omitempty"`
	ResponseBody          string    `gorm:"type:text"            json:"response_body,omitempty"`
	RequestBodyTruncated  bool      `                            json:"request_body_truncated,omitempty"`
	ResponseBodyTruncated bool      `                            json:"response_body_truncated,omitempty"`
	ID                    int       `gorm:"primaryKey"           json:"id"`
	LogID                 int       `gorm:"index"                json:"log_id"`
}

func GetGroupLogDetail

func GetGroupLogDetail(logID int, group string) (*RequestDetail, error)

func GetLogDetail

func GetLogDetail(logID int) (*RequestDetail, error)

func (*RequestDetail) BeforeSave

func (d *RequestDetail) BeforeSave(_ *gorm.DB) (err error)

type RetryLog

type RetryLog struct {
	RequestBody           string          `gorm:"type:text"                           json:"request_body,omitempty"`
	ResponseBody          string          `gorm:"type:text"                           json:"response_body,omitempty"`
	RequestBodyTruncated  bool            `                                           json:"request_body_truncated,omitempty"`
	ResponseBodyTruncated bool            `                                           json:"response_body_truncated,omitempty"`
	RequestAt             time.Time       `                                           json:"request_at"`
	RetryAt               time.Time       `                                           json:"retry_at,omitempty"`
	TTFBMilliseconds      ZeroNullInt64   `                                           json:"ttfb_milliseconds,omitempty"`
	CreatedAt             time.Time       `gorm:"autoCreateTime;index"                json:"created_at"`
	Model                 string          `                                           json:"model"`
	RequestID             EmptyNullString `gorm:"index:,where:request_id is not null" json:"request_id"`
	ID                    int             `gorm:"primaryKey"                          json:"id"`
	ChannelID             int             `                                           json:"channel,omitempty"`
	Code                  int             `gorm:"index"                               json:"code,omitempty"`
	Mode                  int             `                                           json:"mode,omitempty"`
	RetryTimes            ZeroNullInt64   `                                           json:"retry_times,omitempty"`
}

func (*RetryLog) BeforeSave

func (r *RetryLog) BeforeSave(_ *gorm.DB) (err error)

func (*RetryLog) MarshalJSON

func (r *RetryLog) MarshalJSON() ([]byte, error)

type ReusingParam

type ReusingParam struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
}

type Store

type Store struct {
	ID        string    `gorm:"primaryKey"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
	ExpiresAt time.Time
	GroupID   string
	TokenID   int
	ChannelID int
	Model     string
}

Store represents channel-associated data storage for various purposes: - Video generation jobs and their results - File storage with associated metadata - Any other channel-specific data that needs persistence

func GetStore

func GetStore(id string) (*Store, error)

func SaveStore

func SaveStore(s *Store) (*Store, error)

func (*Store) BeforeSave

func (s *Store) BeforeSave(_ *gorm.DB) error

func (*Store) ToStoreCache

func (s *Store) ToStoreCache() *StoreCache

type StoreCache

type StoreCache struct {
	ID        string    `json:"id"         redis:"i"`
	GroupID   string    `json:"group_id"   redis:"g"`
	TokenID   int       `json:"token_id"   redis:"t"`
	ChannelID int       `json:"channel_id" redis:"c"`
	Model     string    `json:"model"      redis:"m"`
	ExpiresAt time.Time `json:"expires_at" redis:"e"`
}

func CacheGetStore

func CacheGetStore(id string) (*StoreCache, error)

type Summary

type Summary struct {
	ID     int           `gorm:"primaryKey"`
	Unique SummaryUnique `gorm:"embedded"`
	Data   SummaryData   `gorm:"embedded"`
}

only summary result only requests

func (*Summary) BeforeCreate

func (l *Summary) BeforeCreate(_ *gorm.DB) (err error)

type SummaryData

type SummaryData struct {
	RequestCount          int64   `json:"request_count"`
	UsedAmount            float64 `json:"used_amount"`
	ExceptionCount        int64   `json:"exception_count"`
	TotalTimeMilliseconds int64   `json:"total_time_milliseconds,omitempty"`
	TotalTTFBMilliseconds int64   `json:"total_ttfb_milliseconds,omitempty"`
	Usage                 Usage   `json:"usage,omitempty"                   gorm:"embedded"`
}

type SummaryDataV2

type SummaryDataV2 struct {
	Timestamp      int64   `json:"timestamp,omitempty"`
	ChannelID      int     `json:"channel_id,omitempty"`
	Model          string  `json:"model"`
	RequestCount   int64   `json:"request_count"`
	UsedAmount     float64 `json:"used_amount"`
	ExceptionCount int64   `json:"exception_count"`

	TotalTimeMilliseconds int64 `json:"total_time_milliseconds,omitempty"`
	TotalTTFBMilliseconds int64 `json:"total_ttfb_milliseconds,omitempty"`

	InputTokens         int64 `json:"input_tokens,omitempty"`
	ImageInputTokens    int64 `json:"image_input_tokens,omitempty"`
	AudioInputTokens    int64 `json:"audio_input_tokens,omitempty"`
	OutputTokens        int64 `json:"output_tokens,omitempty"`
	CachedTokens        int64 `json:"cached_tokens,omitempty"`
	CacheCreationTokens int64 `json:"cache_creation_tokens,omitempty"`
	TotalTokens         int64 `json:"total_tokens,omitempty"`
	WebSearchCount      int64 `json:"web_search_count,omitempty"`

	MaxRPM int64 `json:"max_rpm,omitempty"`
	MaxTPM int64 `json:"max_tpm,omitempty"`
}

type SummaryMinute

type SummaryMinute struct {
	ID     int                 `gorm:"primaryKey"`
	Unique SummaryMinuteUnique `gorm:"embedded"`
	Data   SummaryData         `gorm:"embedded"`
}

func (*SummaryMinute) BeforeCreate

func (l *SummaryMinute) BeforeCreate(_ *gorm.DB) (err error)

type SummaryMinuteUnique

type SummaryMinuteUnique struct {
	ChannelID       int    `gorm:"not null;uniqueIndex:idx_summary_minute_unique,priority:1"`
	Model           string `gorm:"not null;uniqueIndex:idx_summary_minute_unique,priority:2"`
	MinuteTimestamp int64  `gorm:"not null;uniqueIndex:idx_summary_minute_unique,priority:3,sort:desc"`
}

type SummaryMinuteUpdate

type SummaryMinuteUpdate struct {
	SummaryMinuteUnique
	SummaryData
}

type SummaryUnique

type SummaryUnique struct {
	ChannelID     int    `gorm:"not null;uniqueIndex:idx_summary_unique,priority:1"`
	Model         string `gorm:"not null;uniqueIndex:idx_summary_unique,priority:2"`
	HourTimestamp int64  `gorm:"not null;uniqueIndex:idx_summary_unique,priority:3,sort:desc"`
}

type SummaryUpdate

type SummaryUpdate struct {
	SummaryUnique
	SummaryData
}

type TestConfig

type TestConfig struct {
	Enabled bool   `json:"enabled"`
	Params  Params `json:"params"`
}

type TimeSpanType

type TimeSpanType string
const (
	TimeSpanMinute TimeSpanType = "minute"
	TimeSpanDay    TimeSpanType = "day"
	TimeSpanHour   TimeSpanType = "hour"
)

type TimeSummaryDataV2

type TimeSummaryDataV2 struct {
	Timestamp int64            `json:"timestamp"`
	Summary   []*SummaryDataV2 `json:"summary"`
}

func GetGroupTimeSeriesModelDataMinute

func GetGroupTimeSeriesModelDataMinute(
	group string,
	tokenName string,
	modelName string,
	start, end time.Time,
	timeSpan TimeSpanType,
	timezone *time.Location,
) ([]*TimeSummaryDataV2, error)

func GetTimeSeriesModelDataMinute

func GetTimeSeriesModelDataMinute(
	channelID int,
	modelName string,
	start, end time.Time,
	timeSpan TimeSpanType,
	timezone *time.Location,
) ([]*TimeSummaryDataV2, error)

type Token

type Token struct {
	CreatedAt    time.Time       `json:"created_at"`
	ExpiredAt    time.Time       `json:"expired_at"`
	Group        *Group          `json:"-"             gorm:"foreignKey:GroupID"`
	Key          string          `json:"key"           gorm:"type:char(48);uniqueIndex"`
	Name         EmptyNullString `json:"name"          gorm:"index;uniqueIndex:idx_group_name;not null"`
	GroupID      string          `json:"group"         gorm:"index;uniqueIndex:idx_group_name"`
	Subnets      []string        `json:"subnets"       gorm:"serializer:fastjson;type:text"`
	Models       []string        `json:"models"        gorm:"serializer:fastjson;type:text"`
	Status       int             `json:"status"        gorm:"default:1;index"`
	ID           int             `json:"id"            gorm:"primaryKey"`
	Quota        float64         `json:"quota"`
	UsedAmount   float64         `json:"used_amount"   gorm:"index"`
	RequestCount int             `json:"request_count" gorm:"index"`
}

func GetGroupTokenByID

func GetGroupTokenByID(group string, id int) (*Token, error)

func GetTokenByID

func GetTokenByID(id int) (*Token, error)

func GetTokenByKey

func GetTokenByKey(key string) (*Token, error)

func GetTokens

func GetTokens(
	group string,
	page, perPage int,
	order string,
	status int,
) (tokens []*Token, total int64, err error)

func SearchGroupTokens

func SearchGroupTokens(
	group, keyword string,
	page, perPage int,
	order string,
	status int,
	name, key string,
) (tokens []*Token, total int64, err error)

func SearchTokens

func SearchTokens(
	group, keyword string,
	page, perPage int,
	order string,
	status int,
	name, key string,
) (tokens []*Token, total int64, err error)

func (*Token) BeforeCreate

func (t *Token) BeforeCreate(_ *gorm.DB) (err error)

func (*Token) ToTokenCache

func (t *Token) ToTokenCache() *TokenCache

type TokenCache

type TokenCache struct {
	ExpiredAt  redisTime        `json:"expired_at"  redis:"e"`
	Group      string           `json:"group"       redis:"g"`
	Key        string           `json:"-"           redis:"-"`
	Name       string           `json:"name"        redis:"n"`
	Subnets    redisStringSlice `json:"subnets"     redis:"s"`
	Models     redisStringSlice `json:"models"      redis:"m"`
	ID         int              `json:"id"          redis:"i"`
	Status     int              `json:"status"      redis:"st"`
	Quota      float64          `json:"quota"       redis:"q"`
	UsedAmount float64          `json:"used_amount" redis:"u"`
	// contains filtered or unexported fields
}

func CacheGetTokenByKey

func CacheGetTokenByKey(key string) (*TokenCache, error)

func ValidateAndGetToken

func ValidateAndGetToken(key string) (token *TokenCache, err error)

func (*TokenCache) ContainsModel

func (t *TokenCache) ContainsModel(model string) bool

func (*TokenCache) Range

func (t *TokenCache) Range(fn func(model string) bool)

func (*TokenCache) SetAvailableSets

func (t *TokenCache) SetAvailableSets(availableSets []string)

func (*TokenCache) SetModelsBySet

func (t *TokenCache) SetModelsBySet(modelsBySet map[string][]string)

type TokenUpdate

type TokenUpdate struct {
	Amount decimal.Decimal
	Count  int
}

type Usage

type Usage struct {
	InputTokens         ZeroNullInt64 `json:"input_tokens,omitempty"`
	ImageInputTokens    ZeroNullInt64 `json:"image_input_tokens,omitempty"`
	AudioInputTokens    ZeroNullInt64 `json:"audio_input_tokens,omitempty"`
	OutputTokens        ZeroNullInt64 `json:"output_tokens,omitempty"`
	CachedTokens        ZeroNullInt64 `json:"cached_tokens,omitempty"`
	CacheCreationTokens ZeroNullInt64 `json:"cache_creation_tokens,omitempty"`
	ReasoningTokens     ZeroNullInt64 `json:"reasoning_tokens,omitempty"`
	TotalTokens         ZeroNullInt64 `json:"total_tokens,omitempty"`
	WebSearchCount      ZeroNullInt64 `json:"web_search_count,omitempty"`
}

func (*Usage) Add

func (u *Usage) Add(other Usage)

type ZeroNullFloat64

type ZeroNullFloat64 float64

func (*ZeroNullFloat64) Scan

func (znf *ZeroNullFloat64) Scan(value any) error

func (ZeroNullFloat64) Value

func (znf ZeroNullFloat64) Value() (driver.Value, error)

type ZeroNullInt64

type ZeroNullInt64 int64

func (*ZeroNullInt64) Scan

func (zni *ZeroNullInt64) Scan(value any) error

func (ZeroNullInt64) Value

func (zni ZeroNullInt64) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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