Documentation
¶
Index ¶
- Variables
- type CompletionResponse
- type IMaasService
- type IModelRepo
- type LLMRequest
- type Maas
- type MaasAttrFunc
- func WithApiKey(apiKey string) MaasAttrFunc
- func WithAvatar(avatar string) MaasAttrFunc
- func WithBaseUrl(baseUrl string) MaasAttrFunc
- func WithCreateBy(createBy int64) MaasAttrFunc
- func WithModel(model string) MaasAttrFunc
- func WithModelType(modelType string) MaasAttrFunc
- func WithName(name string) MaasAttrFunc
- type MaasAttrFuncs
- type MaasBaseInfo
- type MaasController
- func (this *MaasController) Build(r *gin.RouterGroup)
- func (this *MaasController) Completion(c *gin.Context)
- func (this *MaasController) Create(c *gin.Context)
- func (this *MaasController) Delete(c *gin.Context)
- func (this *MaasController) GetMaasDetail(c *gin.Context)
- func (this *MaasController) GetMaasList(c *gin.Context)
- func (this *MaasController) Invoke(c *gin.Context)
- func (this *MaasController) Update(c *gin.Context)
- type MaasRepo
- func (m MaasRepo) CheckDuplicateMaasBaseURL(ctx context.Context, model string, baseURL string) (bool, error)
- func (m MaasRepo) DeleteMaas(id int) error
- func (m MaasRepo) FindMaasById(id int64, model *Maas) (*Maas, error)
- func (m MaasRepo) FindMaasByModel(model string) (*Maas, error)
- func (m MaasRepo) FindMaasList(userId int64) ([]*Maas, error)
- func (m MaasRepo) ImportMaas(model *Maas) error
- func (m MaasRepo) UpdateMaas(id int, model *Maas) error
- type MaasRequest
- type MaasStatus
- type ModelService
- func (m *ModelService) Completion(c *gin.Context, req CompletionResponse, userId int64)
- func (m *ModelService) DeleteMaas(id int) *result.ErrorResult
- func (m *ModelService) GetMaasDetail(id int64) *result.ErrorResult
- func (m *ModelService) GetMaasList(userId int64) ([]*MaasBaseInfo, error)
- func (m *ModelService) ImportMaas(modelRequest *MaasRequest, userId int64) (*Maas, error)
- func (m *ModelService) InvokeMaas(ctx context.Context, req LLMRequest) (<-chan string, error)
- func (m *ModelService) UpdateMaas(id int, model *Maas) *result.ErrorResult
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrDuplicateMaasBaseURL = fmt.Errorf("combination of maas and base_url already exists")
)
View Source
var MaasSet = wire.NewSet( ProvideMaasRepo, ProvideMaasService, ProvideMaasController, )
Functions ¶
This section is empty.
Types ¶
type CompletionResponse ¶
type CompletionResponse struct {
MaasId int64 `json:"maas_id" binding:"required"`
Prompt string `json:"prompt" binding:"required"`
Params map[string]interface{} `json:"params" binding:"required"`
SessionId string `json:"session_id" binding:"required"`
Context string `json:"context" binding:"required"`
}
type IMaasService ¶
type IMaasService interface {
GetMaasList(userId int64) ([]*MaasBaseInfo, error)
GetMaasDetail(id int64) *result.ErrorResult
ImportMaas(model *MaasRequest, userId int64) (*Maas, error)
UpdateMaas(id int, model *Maas) *result.ErrorResult
DeleteMaas(id int) *result.ErrorResult
InvokeMaas(ctx context.Context, req LLMRequest) (<-chan string, error)
Completion(ctx *gin.Context, req CompletionResponse, userId int64)
}
func ProvideMaasService ¶
func ProvideMaasService(repo IModelRepo, messageService message.IMessageService, conversationService conversation.IConversationService) IMaasService
type IModelRepo ¶
type IModelRepo interface {
FindMaasList(userId int64) ([]*Maas, error)
FindMaasById(id int64, model *Maas) (*Maas, error)
FindMaasByModel(model string) (*Maas, error)
ImportMaas(model *Maas) error
UpdateMaas(id int, model *Maas) error
DeleteMaas(id int) error
CheckDuplicateMaasBaseURL(ctx context.Context, model string, baseURL string) (bool, error)
}
func ProvideMaasRepo ¶
func ProvideMaasRepo(db *gorm.DB) IModelRepo
type LLMRequest ¶
type Maas ¶
type Maas struct {
ID int64 `json:"id" gorm:"column:id; primaryKey; autoIncrement"`
Name string `json:"name" gorm:"not null"`
Description string `json:"description"`
Status MaasStatus `json:"status" gorm:"type:ENUM('active', 'inactive', 'deprecated');default:'active'"`
Model string `json:"model" gorm:"column:model;unique" binding:"required"`
BaseUrl string `json:"base_url" gorm:"column:base_url;not null" binding:"required"`
ApiKey string `json:"api_key" gorm:"column:api_key;not null" binding:"required"`
ModelType string `json:"model_type" gorm:"column:model_type;not null" binding:"required"`
Avatar string `json:"avatar" gorm:"column:avatar"`
// 自动维护时间
CreateTime time.Time `json:"create_time" gorm:"column:create_time;autoCreateTime;type:datetime(0);"`
UpdateTime time.Time `json:"update_time" gorm:"column:update_time;autoCreateTime;<-:false;type:datetime(0);"`
CreateBy int64 `json:"create_by" gorm:"not null;default:0"`
UpdateBy int64 `json:"-" gorm:"column:update_by"`
}
User 创建 Users struct
func NewMaas ¶
func NewMaas(attrs ...MaasAttrFunc) *Maas
func (*Maas) Mutate ¶
func (u *Maas) Mutate(attrs ...MaasAttrFunc) *Maas
type MaasAttrFunc ¶
type MaasAttrFunc func(u *Maas)
func WithApiKey ¶
func WithApiKey(apiKey string) MaasAttrFunc
func WithAvatar ¶
func WithAvatar(avatar string) MaasAttrFunc
func WithBaseUrl ¶
func WithBaseUrl(baseUrl string) MaasAttrFunc
func WithCreateBy ¶
func WithCreateBy(createBy int64) MaasAttrFunc
func WithModel ¶
func WithModel(model string) MaasAttrFunc
func WithModelType ¶
func WithModelType(modelType string) MaasAttrFunc
func WithName ¶
func WithName(name string) MaasAttrFunc
type MaasAttrFuncs ¶
type MaasAttrFuncs []MaasAttrFunc
type MaasBaseInfo ¶
type MaasController ¶
type MaasController struct {
// contains filtered or unexported fields
}
func ProvideMaasController ¶
func ProvideMaasController(service IMaasService) *MaasController
func (*MaasController) Build ¶
func (this *MaasController) Build(r *gin.RouterGroup)
func (*MaasController) Completion ¶
func (this *MaasController) Completion(c *gin.Context)
func (*MaasController) Create ¶
func (this *MaasController) Create(c *gin.Context)
func (*MaasController) Delete ¶
func (this *MaasController) Delete(c *gin.Context)
func (*MaasController) GetMaasDetail ¶
func (this *MaasController) GetMaasDetail(c *gin.Context)
func (*MaasController) GetMaasList ¶
func (this *MaasController) GetMaasList(c *gin.Context)
func (*MaasController) Invoke ¶
func (this *MaasController) Invoke(c *gin.Context)
func (*MaasController) Update ¶
func (this *MaasController) Update(c *gin.Context)
type MaasRepo ¶
type MaasRepo struct {
// contains filtered or unexported fields
}
func (MaasRepo) CheckDuplicateMaasBaseURL ¶
func (MaasRepo) DeleteMaas ¶
func (MaasRepo) ImportMaas ¶
type MaasRequest ¶
type MaasRequest struct {
Name string `json:"name" `
Description string `json:"description"`
Model string `json:"maas" binding:"required"`
ModelType string `json:"model_type" binding:"required"`
BaseURL string `json:"base_url" binding:"required,url"`
APIKey string `json:"api_key" binding:"required"`
Avatar string `json:"avatar"`
}
type MaasStatus ¶
type MaasStatus string
const ( MaasStatusActive MaasStatus = "active" MaasStatusInactive MaasStatus = "inactive" MaasStatusDeprecated MaasStatus = "deprecated" )
type ModelService ¶
type ModelService struct {
// contains filtered or unexported fields
}
func (*ModelService) Completion ¶
func (m *ModelService) Completion(c *gin.Context, req CompletionResponse, userId int64)
func (*ModelService) DeleteMaas ¶
func (m *ModelService) DeleteMaas(id int) *result.ErrorResult
func (*ModelService) GetMaasDetail ¶
func (m *ModelService) GetMaasDetail(id int64) *result.ErrorResult
func (*ModelService) GetMaasList ¶
func (m *ModelService) GetMaasList(userId int64) ([]*MaasBaseInfo, error)
func (*ModelService) ImportMaas ¶
func (m *ModelService) ImportMaas(modelRequest *MaasRequest, userId int64) (*Maas, error)
func (*ModelService) InvokeMaas ¶
func (m *ModelService) InvokeMaas(ctx context.Context, req LLMRequest) (<-chan string, error)
func (*ModelService) UpdateMaas ¶
func (m *ModelService) UpdateMaas(id int, model *Maas) *result.ErrorResult
Click to show internal directories.
Click to hide internal directories.