service

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAnthropic

func RegisterAnthropic(i IAnthropic)

func RegisterApp

func RegisterApp(i IApp)

func RegisterAppKey

func RegisterAppKey(i IAppKey)

func RegisterAudio

func RegisterAudio(i IAudio)

func RegisterAuth

func RegisterAuth(i IAuth)

func RegisterBatch

func RegisterBatch(i IBatch)

func RegisterChat

func RegisterChat(i IChat)

func RegisterCommon

func RegisterCommon(i ICommon)

func RegisterCore

func RegisterCore(i ICore)

func RegisterDashboard

func RegisterDashboard(i IDashboard)

func RegisterEmbedding

func RegisterEmbedding(i IEmbedding)

func RegisterFile

func RegisterFile(i IFile)

func RegisterGeneral

func RegisterGeneral(i IGeneral)

func RegisterGoogle

func RegisterGoogle(i IGoogle)

func RegisterGroup

func RegisterGroup(i IGroup)

func RegisterImage

func RegisterImage(i IImage)

func RegisterKey

func RegisterKey(i IKey)

func RegisterLog

func RegisterLog(i ILog)

func RegisterMidjourney

func RegisterMidjourney(i IMidjourney)

func RegisterModel

func RegisterModel(i IModel)

func RegisterModelAgent

func RegisterModelAgent(i IModelAgent)

func RegisterModeration

func RegisterModeration(i IModeration)

func RegisterOpenAI

func RegisterOpenAI(i IOpenAI)

func RegisterProvider

func RegisterProvider(i IProvider)

func RegisterRealtime

func RegisterRealtime(i IRealtime)

func RegisterReseller

func RegisterReseller(i IReseller)

func RegisterSession

func RegisterSession(i ISession)

func RegisterSysConfig

func RegisterSysConfig(i ISysConfig)

func RegisterUser

func RegisterUser(i IUser)

func RegisterVideo

func RegisterVideo(i IVideo)

Types

type IAnthropic

type IAnthropic interface {
	// Completions
	Completions(ctx context.Context, request *ghttp.Request, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.ChatCompletionResponse, err error)
	// CompletionsStream
	CompletionsStream(ctx context.Context, request *ghttp.Request, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (err error)
}

func Anthropic

func Anthropic() IAnthropic

type IApp

type IApp interface {
	// 根据应用ID获取应用信息
	GetByAppId(ctx context.Context, appId int) (*model.App, error)
	// 应用列表
	List(ctx context.Context) ([]*model.App, error)
	// 应用花费额度
	SpendQuota(ctx context.Context, appId int, spendQuota int, currentQuota int) error
	// 应用已用额度
	UsedQuota(ctx context.Context, appId int, quota int) error
	// 保存应用额度到缓存
	SaveCacheQuota(ctx context.Context, appId int, quota int) error
	// 获取缓存中的应用额度
	GetCacheQuota(ctx context.Context, appId int) int
	// 保存应用信息到缓存
	SaveCache(ctx context.Context, app *model.App) error
	// 获取缓存中的应用信息
	GetCache(ctx context.Context, appId int) (*model.App, error)
	// 更新缓存中的应用信息
	UpdateCache(ctx context.Context, app *entity.App)
	// 移除缓存中的应用信息
	RemoveCache(ctx context.Context, appId int)
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func App

func App() IApp

type IAppKey

type IAppKey interface {
	// 根据secretKey获取应用密钥信息
	GetBySecretKey(ctx context.Context, secretKey string) (*model.AppKey, error)
	// 应用密钥列表
	List(ctx context.Context) ([]*model.AppKey, error)
	// 保存应用密钥信息到缓存
	SaveCache(ctx context.Context, key *model.AppKey) error
	// 获取缓存中的应用密钥信息
	GetCache(ctx context.Context, secretKey string) (*model.AppKey, error)
	// 更新缓存中的应用密钥信息
	UpdateCache(ctx context.Context, key *entity.AppKey)
	// 移除缓存中的应用密钥信息
	RemoveCache(ctx context.Context, secretKey string)
	// 应用密钥花费额度
	SpendQuota(ctx context.Context, secretKey string, spendQuota int, currentQuota int) error
	// 应用密钥已用额度
	UsedQuota(ctx context.Context, secretKey string, quota int) error
	// 保存应用密钥额度到缓存
	SaveCacheQuota(ctx context.Context, secretKey string, quota int) error
	// 获取缓存中的应用密钥额度
	GetCacheQuota(ctx context.Context, secretKey string) int
	// 更新应用密钥额度过期时间
	UpdateQuotaExpiresAt(ctx context.Context, key *model.AppKey) error
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func AppKey

func AppKey() IAppKey

type IAudio

type IAudio interface {
	// Speech
	Speech(ctx context.Context, data []byte, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.SpeechResponse, err error)
	// Transcriptions
	Transcriptions(ctx context.Context, params *v1.TranscriptionsReq, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.AudioResponse, err error)
}

func Audio

func Audio() IAudio

type IAuth

type IAuth interface {
	// 身份核验
	Authenticator(ctx context.Context, secretKey string) error
	// 核验密钥
	VerifySecretKey(ctx context.Context, secretKey string) error
}

func Auth

func Auth() IAuth

type IBatch

type IBatch interface {
	// Create
	Create(ctx context.Context, params *v1.CreateReq, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.BatchResponse, err error)
	// List
	List(ctx context.Context, params *v1.ListReq) (response smodel.BatchListResponse, err error)
	// Retrieve
	Retrieve(ctx context.Context, params *v1.RetrieveReq) (response smodel.BatchResponse, err error)
	// Cancel
	Cancel(ctx context.Context, params *v1.CancelReq) (response smodel.BatchResponse, err error)
}

func Batch

func Batch() IBatch

type IChat

type IChat interface {
	// Completions
	Completions(ctx context.Context, params smodel.ChatCompletionRequest, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.ChatCompletionResponse, err error)
	// CompletionsStream
	CompletionsStream(ctx context.Context, params smodel.ChatCompletionRequest, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (err error)
	// SmartCompletions
	SmartCompletions(ctx context.Context, params smodel.ChatCompletionRequest, reqModel *model.Model, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.ChatCompletionResponse, err error)
}

func Chat

func Chat() IChat

type ICommon

type ICommon interface {
	// 解析密钥
	ParseSecretKey(ctx context.Context, secretKey string) (int, int, error)
	// 记录错误次数和禁用
	RecordError(ctx context.Context, model *model.Model, key *model.Key, modelAgent *model.ModelAgent)
}

func Common

func Common() ICommon

type ICore

type ICore interface {
	// 刷新缓存
	Refresh(ctx context.Context) error
}

func Core

func Core() ICore

type IDashboard

type IDashboard interface {
	// Subscription
	Subscription(ctx context.Context) (*model.DashboardSubscriptionRes, error)
	// Usage
	Usage(ctx context.Context) (*model.DashboardUsageRes, error)
}

func Dashboard

func Dashboard() IDashboard

type IEmbedding

type IEmbedding interface {
	// Embeddings
	Embeddings(ctx context.Context, data []byte, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.EmbeddingResponse, err error)
}

func Embedding

func Embedding() IEmbedding

type IFile

type IFile interface {
	// Upload
	Upload(ctx context.Context, params *v1.UploadReq, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.FileResponse, err error)
	// List
	List(ctx context.Context, params *v1.ListReq) (response smodel.FileListResponse, err error)
	// Retrieve
	Retrieve(ctx context.Context, params *v1.RetrieveReq) (response smodel.FileResponse, err error)
	// Delete
	Delete(ctx context.Context, params *v1.DeleteReq) (response smodel.FileResponse, err error)
	// Content
	Content(ctx context.Context, params *v1.ContentReq) (response smodel.FileContentResponse, err error)
}

func File

func File() IFile

type IGeneral

type IGeneral interface {
	// General
	General(ctx context.Context, request *ghttp.Request, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.ChatCompletionResponse, err error)
	// GeneralStream
	GeneralStream(ctx context.Context, request *ghttp.Request, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (err error)
}

func General

func General() IGeneral

type IGoogle

type IGoogle interface {
	// Completions
	Completions(ctx context.Context, request *ghttp.Request, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.ChatCompletionResponse, err error)
	// CompletionsStream
	CompletionsStream(ctx context.Context, request *ghttp.Request, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (err error)
}

func Google

func Google() IGoogle

type IGroup

type IGroup interface {
	// 根据分组ID获取分组信息
	GetById(ctx context.Context, id string) (*model.Group, error)
	// 分组列表
	List(ctx context.Context) ([]*model.Group, error)
	// 根据分组ID获取分组信息并保存到缓存
	GetAndSaveCache(ctx context.Context, id string) (*model.Group, error)
	// 保存分组到缓存
	SaveCache(ctx context.Context, group *model.Group) error
	// 保存分组列表到缓存
	SaveCacheList(ctx context.Context, groups []*model.Group) error
	// 获取缓存中的分组信息
	GetCache(ctx context.Context, id string) (*model.Group, error)
	// 获取缓存中的分组列表
	GetCacheList(ctx context.Context, ids ...string) ([]*model.Group, error)
	// 更新缓存中的分组列表
	UpdateCache(ctx context.Context, newData *entity.Group)
	// 移除缓存中的分组列表
	RemoveCache(ctx context.Context, id string)
	// 根据分组Ids获取模型Ids
	GetModelIds(ctx context.Context, ids ...string) ([]string, error)
	// 根据分组Ids获取默认分组
	GetDefault(ctx context.Context, ids ...string) (*model.Group, error)
	// 根据model挑选分组和模型
	PickGroupAndModel(ctx context.Context, m string, ids ...string) (reqModel *model.Model, group *model.Group, err error)
	// 分组花费额度
	SpendQuota(ctx context.Context, group string, spendQuota int, currentQuota int) error
	// 分组已用额度
	UsedQuota(ctx context.Context, group string, quota int) error
	// 保存分组额度到缓存
	SaveCacheQuota(ctx context.Context, group string, quota int) error
	// 获取缓存中的分组额度
	GetCacheQuota(ctx context.Context, group string) int
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func Group

func Group() IGroup

type IImage

type IImage interface {
	// Generations
	Generations(ctx context.Context, data []byte, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.ImageResponse, err error)
	// Edits
	Edits(ctx context.Context, params smodel.ImageEditRequest, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.ImageResponse, err error)
}

func Image

func Image() IImage

type IKey

type IKey interface {
	// 根据模型ID获取密钥列表
	GetByModelId(ctx context.Context, modelId string) ([]*model.Key, error)
	// 密钥列表
	List(ctx context.Context) ([]*model.Key, error)
	// 挑选模型密钥
	Pick(ctx context.Context, m *model.Model) (int, *model.Key, error)
	// 移除模型密钥
	Remove(ctx context.Context, m *model.Model, key *model.Key)
	// 记录错误模型密钥
	RecordError(ctx context.Context, m *model.Model, key *model.Key)
	// 禁用模型密钥
	Disabled(ctx context.Context, key *model.Key, disabledReason string)
	// 保存模型密钥列表到缓存
	SaveCache(ctx context.Context, id string, keys []*model.Key) error
	// 获取缓存中的模型密钥列表
	GetCache(ctx context.Context, id string) ([]*model.Key, error)
	// 添加模型密钥到缓存列表中
	AddCache(ctx context.Context, key *entity.Key)
	// 更新缓存中的模型密钥
	UpdateCache(ctx context.Context, oldData *entity.Key, newData *entity.Key)
	// 移除缓存中的模型密钥
	RemoveCache(ctx context.Context, key *entity.Key)
	// 密钥已用额度
	UsedQuota(ctx context.Context, key string, quota int) error
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func Key

func Key() IKey

type ILog

type ILog interface {
	// 文本日志
	Text(ctx context.Context, textLog model.LogText, retry ...int)
	// 绘图日志
	Image(ctx context.Context, imageLog model.LogImage, retry ...int)
	// 音频日志
	Audio(ctx context.Context, audioLog model.LogAudio, retry ...int)
	// 视频日志
	Video(ctx context.Context, videoLog model.LogVideo, retry ...int)
	// 文件日志
	File(ctx context.Context, fileLog model.LogFile, retry ...int)
	// 批处理日志
	Batch(ctx context.Context, batchLog model.LogBatch, retry ...int)
	// Midjourney日志
	Midjourney(ctx context.Context, midjourneyLog model.LogMidjourney, retry ...int)
	// 通用日志
	General(ctx context.Context, generalLog model.LogGeneral, retry ...int)
}

func Log

func Log() ILog

type IMidjourney

type IMidjourney interface {
	// 任务提交
	Submit(ctx context.Context, request *ghttp.Request, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.MidjourneyResponse, err error)
	// 任务查询
	Task(ctx context.Context, request *ghttp.Request, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.MidjourneyResponse, err error)
}

func Midjourney

func Midjourney() IMidjourney

type IModel

type IModel interface {
	// 根据model获取模型信息
	GetModel(ctx context.Context, m string) (*model.Model, error)
	// 根据模型ID获取模型信息
	GetModelById(ctx context.Context, id string) (*model.Model, error)
	// 根据model和group获取模型信息
	GetModelByGroup(ctx context.Context, m string, group *model.Group) (*model.Model, error)
	// 模型列表
	List(ctx context.Context, ids []string) ([]*model.Model, error)
	// 全部模型列表
	ListAll(ctx context.Context) ([]*model.Model, error)
	// 获取模型与密钥列表
	GetModelsAndKeys(ctx context.Context) ([]*model.Model, map[string][]*model.Key, error)
	// 根据模型ID获取模型信息并保存到缓存
	GetModelAndSaveCache(ctx context.Context, id string) (*model.Model, error)
	// 获取模型列表并保存到缓存
	GetModelListAndSaveCacheList(ctx context.Context, ids []string) ([]*model.Model, error)
	// 保存模型到缓存
	SaveCache(ctx context.Context, m *model.Model) error
	// 保存模型列表到缓存
	SaveCacheList(ctx context.Context, models []*model.Model) error
	// 获取缓存中的模型列表
	GetCacheList(ctx context.Context, ids ...string) ([]*model.Model, error)
	// 获取缓存中的模型信息
	GetCacheModel(ctx context.Context, id string) (*model.Model, error)
	// 更新缓存中的模型列表
	UpdateCacheModel(ctx context.Context, oldData *entity.Model, newData *entity.Model)
	// 移除缓存中的模型列表
	RemoveCacheModel(ctx context.Context, id string)
	// 获取目标模型
	GetTargetModel(ctx context.Context, model *model.Model, messages []smodel.ChatCompletionMessage) (targetModel *model.Model, err error)
	// 获取分组目标模型
	GetGroupTargetModel(ctx context.Context, group *model.Group, model *model.Model, messages []smodel.ChatCompletionMessage) (targetModel *model.Model, err error)
	// 获取后备模型
	GetFallbackModel(ctx context.Context, model *model.Model) (fallbackModel *model.Model, err error)
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func Model

func Model() IModel

type IModelAgent

type IModelAgent interface {
	// 根据模型代理ID获取模型代理信息
	GetById(ctx context.Context, id string) (*model.ModelAgent, error)
	// 模型代理列表
	List(ctx context.Context, ids []string) ([]*model.ModelAgent, error)
	// 全部模型代理列表
	ListAll(ctx context.Context) ([]*model.ModelAgent, error)
	// 根据模型代理ID获取密钥列表
	GetKeys(ctx context.Context, id string) ([]*model.Key, error)
	// 获取模型代理与密钥列表
	GetModelAgentsAndKeys(ctx context.Context) ([]*model.ModelAgent, map[string][]*model.Key, error)
	// 挑选模型代理
	Pick(ctx context.Context, m *model.Model) (int, *model.ModelAgent, error)
	// 根据模型挑选分组模型代理
	PickGroup(ctx context.Context, m *model.Model, group *model.Group) (int, *model.ModelAgent, error)
	// 移除模型代理
	Remove(ctx context.Context, m *model.Model, modelAgent *model.ModelAgent)
	// 记录错误模型代理
	RecordError(ctx context.Context, m *model.Model, modelAgent *model.ModelAgent)
	// 禁用模型代理
	Disabled(ctx context.Context, modelAgent *model.ModelAgent, disabledReason string)
	// 挑选模型代理密钥
	PickKey(ctx context.Context, modelAgent *model.ModelAgent) (int, *model.Key, error)
	// 移除模型代理密钥
	RemoveKey(ctx context.Context, modelAgent *model.ModelAgent, key *model.Key)
	// 记录错误模型代理密钥
	RecordErrorKey(ctx context.Context, modelAgent *model.ModelAgent, key *model.Key)
	// 禁用模型代理密钥
	DisabledKey(ctx context.Context, key *model.Key, disabledReason string)
	// 保存模型代理列表到缓存
	SaveCacheList(ctx context.Context, modelAgents []*model.ModelAgent) error
	// 获取缓存中的模型代理列表
	GetCacheList(ctx context.Context, ids ...string) ([]*model.ModelAgent, error)
	// 添加模型代理到缓存列表中
	AddCache(ctx context.Context, newData *model.ModelAgent)
	// 更新缓存中的模型代理列表
	UpdateCache(ctx context.Context, oldData *entity.ModelAgent, newData *model.ModelAgent)
	// 移除缓存中的模型代理
	RemoveCache(ctx context.Context, modelAgent *model.ModelAgent)
	// 保存模型代理密钥列表到缓存
	SaveCacheKeys(ctx context.Context, id string, keys []*model.Key) error
	// 获取缓存中的模型代理密钥列表
	GetCacheKeys(ctx context.Context, id string) ([]*model.Key, error)
	// 新增模型代理密钥到缓存列表中
	CreateCacheKey(ctx context.Context, key *entity.Key)
	// 更新缓存中的模型代理密钥
	UpdateCacheKey(ctx context.Context, oldData *entity.Key, newData *entity.Key)
	// 移除缓存中的模型代理密钥
	RemoveCacheKey(ctx context.Context, key *entity.Key)
	// 获取缓存中的模型代理信息
	GetCache(ctx context.Context, id string) (*model.ModelAgent, error)
	// 根据模型代理ID获取模型代理信息并保存到缓存
	GetAndSaveCache(ctx context.Context, id string) (*model.ModelAgent, error)
	// 保存模型代理到缓存
	SaveCache(ctx context.Context, modelAgent *model.ModelAgent) error
	// 获取后备模型代理
	GetFallback(ctx context.Context, model *model.Model) (fallbackModelAgent *model.ModelAgent, err error)
	// 保存分组模型代理列表到缓存
	SaveGroupCache(ctx context.Context, group *model.Group) error
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func ModelAgent

func ModelAgent() IModelAgent

type IModeration

type IModeration interface {
	// Moderations
	Moderations(ctx context.Context, params smodel.ModerationRequest, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.ModerationResponse, err error)
}

func Moderation

func Moderation() IModeration

type IOpenAI

type IOpenAI interface {
	// Responses
	Responses(ctx context.Context, request *ghttp.Request, isChatCompletions bool, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.OpenAIResponsesRes, err error)
	// ResponsesStream
	ResponsesStream(ctx context.Context, request *ghttp.Request, isChatCompletions bool, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (err error)
}

func OpenAI

func OpenAI() IOpenAI

type IProvider

type IProvider interface {
	// 根据提供商ID获取提供商信息
	GetById(ctx context.Context, id string) (*model.Provider, error)
	// 提供商列表
	List(ctx context.Context) ([]*model.Provider, error)
	// 根据提供商ID获取提供商信息并保存到缓存
	GetAndSaveCache(ctx context.Context, id string) (*model.Provider, error)
	// 保存提供商到缓存
	SaveCache(ctx context.Context, provider *model.Provider) error
	// 保存提供商列表到缓存
	SaveCacheList(ctx context.Context, providers []*model.Provider) error
	// 获取缓存中的提供商信息
	GetCache(ctx context.Context, id string) (*model.Provider, error)
	// 获取缓存中的提供商列表
	GetCacheList(ctx context.Context, ids ...string) ([]*model.Provider, error)
	// 更新缓存中的提供商列表
	UpdateCache(ctx context.Context, newData *entity.Provider)
	// 移除缓存中的提供商列表
	RemoveCache(ctx context.Context, id string)
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func Provider

func Provider() IProvider

type IRealtime

type IRealtime interface {
	// Realtime
	Realtime(ctx context.Context, r *ghttp.Request, params model.RealtimeRequest, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (err error)
}

func Realtime

func Realtime() IRealtime

type IReseller

type IReseller interface {
	// 根据用户ID获取代理商信息
	GetByUserId(ctx context.Context, userId int) (*model.Reseller, error)
	// 代理商列表
	List(ctx context.Context) ([]*model.Reseller, error)
	// 代理商花费额度
	SpendQuota(ctx context.Context, userId int, spendQuota int, currentQuota int) error
	// 保存代理商信息到缓存
	SaveCache(ctx context.Context, reseller *model.Reseller) error
	// 获取缓存中的代理商信息
	GetCache(ctx context.Context, userId int) (*model.Reseller, error)
	// 更新缓存中的代理商信息
	UpdateCache(ctx context.Context, reseller *entity.Reseller)
	// 移除缓存中的代理商信息
	RemoveCache(ctx context.Context, userId int)
	// 保存代理商额度到缓存
	SaveCacheQuota(ctx context.Context, userId int, quota int) error
	// 获取缓存中的代理商额度
	GetCacheQuota(ctx context.Context, userId int) int
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func Reseller

func Reseller() IReseller

type ISession

type ISession interface {
	// 保存会话
	Save(ctx context.Context, secretKey string) error
	// 保存应用和密钥是否限制额度
	SaveIsLimitQuota(ctx context.Context, app bool, key bool)
	// 保存代理商ID到会话中
	SaveRid(ctx context.Context, rid int)
	// 获取代理商ID
	GetRid(ctx context.Context) int
	// 获取用户ID
	GetUserId(ctx context.Context) int
	// 获取应用ID
	GetAppId(ctx context.Context) int
	// 获取密钥
	GetSecretKey(ctx context.Context) string
	// 获取应用是否限制额度
	GetAppIsLimitQuota(ctx context.Context) bool
	// 获取密钥是否限制额度
	GetKeyIsLimitQuota(ctx context.Context) bool
	// 保存代理商信息到会话中
	SaveReseller(ctx context.Context, reseller *model.Reseller)
	// 获取会话中的代理商信息
	GetReseller(ctx context.Context) *model.Reseller
	// 保存用户信息到会话中
	SaveUser(ctx context.Context, user *model.User)
	// 获取会话中的用户信息
	GetUser(ctx context.Context) *model.User
	// 保存应用信息到会话中
	SaveApp(ctx context.Context, app *model.App)
	// 获取会话中的应用信息
	GetApp(ctx context.Context) *model.App
	// 保存应用密钥信息到会话中
	SaveAppKey(ctx context.Context, key *model.AppKey)
	// 获取会话中的应用密钥信息
	GetAppKey(ctx context.Context) *model.AppKey
	// 记录错误模型代理ID到会话中
	RecordErrorModelAgent(ctx context.Context, id string)
	// 获取会话中的错误模型代理Ids
	GetErrorModelAgents(ctx context.Context) []string
	// 记录错误密钥ID到会话中
	RecordErrorKey(ctx context.Context, id string)
	// 获取会话中的错误密钥Ids
	GetErrorKeys(ctx context.Context) []string
	// 是否已选定模型代理
	IsSelectedModelAgent(ctx context.Context) (string, bool)
	// 保存模型代理计费方式
	SaveModelAgentBillingMethod(ctx context.Context, billingMethod int)
	// 获取模型代理计费方式
	GetModelAgentBillingMethod(ctx context.Context) int
}

func Session

func Session() ISession

type ISysConfig

type ISysConfig interface {
	// 初始化配置
	Init(ctx context.Context) (sysConfig *entity.SysConfig, err error)
}

func SysConfig

func SysConfig() ISysConfig

type IUser

type IUser interface {
	// 根据用户ID获取用户信息
	GetByUserId(ctx context.Context, userId int) (*model.User, error)
	// 用户列表
	List(ctx context.Context) ([]*model.User, error)
	// 用户花费额度
	SpendQuota(ctx context.Context, userId int, spendQuota int, currentQuota int) error
	// 保存用户信息到缓存
	SaveCache(ctx context.Context, user *model.User) error
	// 获取缓存中的用户信息
	GetCache(ctx context.Context, userId int) (*model.User, error)
	// 更新缓存中的用户信息
	UpdateCache(ctx context.Context, user *entity.User)
	// 移除缓存中的用户信息
	RemoveCache(ctx context.Context, userId int)
	// 保存用户额度到缓存
	SaveCacheQuota(ctx context.Context, userId int, quota int) error
	// 获取缓存中的用户额度
	GetCacheQuota(ctx context.Context, userId int) int
	// 变更订阅
	Subscribe(ctx context.Context, msg string) error
}

func User

func User() IUser

type IVideo

type IVideo interface {
	// Create
	Create(ctx context.Context, params *v1.CreateReq, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.VideoJobResponse, err error)
	// Remix
	Remix(ctx context.Context, params *v1.RemixReq, fallbackModelAgent *model.ModelAgent, fallbackModel *model.Model, retry ...int) (response smodel.VideoJobResponse, err error)
	// List
	List(ctx context.Context, params *v1.ListReq) (response smodel.VideoListResponse, err error)
	// Retrieve
	Retrieve(ctx context.Context, params *v1.RetrieveReq) (response smodel.VideoJobResponse, err error)
	// Delete
	Delete(ctx context.Context, params *v1.DeleteReq) (response smodel.VideoJobResponse, err error)
	// Content
	Content(ctx context.Context, params *v1.ContentReq) (response smodel.VideoContentResponse, err error)
}

func Video

func Video() IVideo

Jump to

Keyboard shortcuts

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