maas

package
v0.0.0-...-e7f2ee2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateMaasBaseURL = fmt.Errorf("combination of maas and base_url already exists")
)

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 LLMRequest struct {
	ModelId int64                  `json:"model_id" binding:"required"`
	Prompt  string                 `json:"prompt" binding:"required"`
	Params  map[string]interface{} `json:"params" binding:"required"`
}

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

func (*Maas) TableName

func (u *Maas) TableName() string

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 MaasBaseInfo struct {
	Id       int64     `json:"id"`
	Model    string    `json:"model"`
	Name     string    `json:"name"`
	Avatar   string    `json:"avatar"`
	CreateAt time.Time `json:"create_time"`
}

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 (m MaasRepo) CheckDuplicateMaasBaseURL(ctx context.Context, model string, baseURL string) (bool, error)

func (MaasRepo) DeleteMaas

func (m MaasRepo) DeleteMaas(id int) error

func (MaasRepo) FindMaasById

func (m MaasRepo) FindMaasById(id int64, model *Maas) (*Maas, error)

func (MaasRepo) FindMaasByModel

func (m MaasRepo) FindMaasByModel(model string) (*Maas, error)

func (MaasRepo) FindMaasList

func (m MaasRepo) FindMaasList(userId int64) ([]*Maas, error)

func (MaasRepo) ImportMaas

func (m MaasRepo) ImportMaas(model *Maas) error

func (MaasRepo) UpdateMaas

func (m MaasRepo) UpdateMaas(id int, model *Maas) error

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

Jump to

Keyboard shortcuts

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