web

package
v2.4.7 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS_CODE         int = 200
	ERROR_PARAMETER_CODE int = 400
	SERVER_ERROR_CODE    int = 500
)
View Source
const (
	Default_Size int = 10
)

Variables

View Source
var (
	CODE_MAPS = map[int]string{
		SUCCESS_CODE:         "success",
		ERROR_PARAMETER_CODE: "parammeter error",
		SERVER_ERROR_CODE:    "server error",
	}
)

Functions

func RegisterCallBackProcessFunc

func RegisterCallBackProcessFunc(scene string, f CallBackProcessFunc)

func Send

func Send(controller *CallBackController)

Types

type CallBackController

type CallBackController struct {
	Controller
	// contains filtered or unexported fields
}

func (*CallBackController) CheckParameter

func (r *CallBackController) CheckParameter() error

func (*CallBackController) Process

type CallBackControllerHandler

type CallBackControllerHandler struct {
	// contains filtered or unexported fields
}

func NewCallBackControllerHandler

func NewCallBackControllerHandler() *CallBackControllerHandler

type CallBackParam

type CallBackParam struct {
	SceneId             string                   `json:"scene_id"`
	RequestId           string                   `json:"request_id"`
	Uid                 string                   `json:"uid"`
	Features            map[string]interface{}   `json:"features"`
	ComplexTypeFeatures ComplexTypeFeatures      `json:"complex_type_features"`
	ItemList            []map[string]interface{} `json:"item_list"`
	RequestInfo         map[string]interface{}   `json:"request_info"`
	Debug               bool                     `json:"debug"`
}

func (*CallBackParam) GetParameter

func (r *CallBackParam) GetParameter(name string) interface{}

type CallBackProcessFunc

type CallBackProcessFunc func(user *module.User, items []*module.Item, context *context.RecommendContext)

type CallBackResponse

type CallBackResponse struct {
	Response
}

func (*CallBackResponse) ToString

func (r *CallBackResponse) ToString() string

type ComplexTypeFeatures added in v2.2.5

type ComplexTypeFeatures struct {
	Features []Feature `json:"features"`

	FeaturesMap map[string]any
}

func (*ComplexTypeFeatures) UnmarshalJSON added in v2.2.5

func (f *ComplexTypeFeatures) UnmarshalJSON(data []byte) error

type Controller

type Controller struct {
	RequestBody []byte
	RequestId   string
	Start       time.Time
	End         time.Time
}

func (*Controller) LogRequestBegin

func (c *Controller) LogRequestBegin(r *http.Request)

func (*Controller) LogRequestBeginWithSize added in v2.2.5

func (c *Controller) LogRequestBeginWithSize(r *http.Request, size int)

func (*Controller) LogRequestEnd

func (c *Controller) LogRequestEnd(r *http.Request)

func (*Controller) SendError

func (c *Controller) SendError(w http.ResponseWriter, code int, msg string)

type DataSourceInfo

type DataSourceInfo struct {
	Type       string `json:"type"`
	AccessId   string `json:"access_id"`
	AccessKey  string `json:"access_key"`
	Endpoint   string `json:"endpoint"`
	Project    string `json:"project"`
	Topic      string `json:"topic"`
	VpcAddress string `json:"vpc_address"`
	Token      string `json:"token"`
	JobId      int    `json:"job_id"`
}

type EmbeddingController added in v2.2.5

type EmbeddingController struct {
	Controller
	// contains filtered or unexported fields
}

func (*EmbeddingController) CheckParameter added in v2.2.5

func (r *EmbeddingController) CheckParameter() error

func (*EmbeddingController) Process added in v2.2.5

type EmbeddingParam added in v2.2.5

type EmbeddingParam struct {
	RequestId               string                 `json:"request_id"`
	SceneId                 string                 `json:"scene_id"`
	Uid                     string                 `json:"uid"` // user id
	Debug                   bool                   `json:"debug"`
	UserFeatures            map[string]interface{} `json:"user_features"`
	UserComplexTypeFeatures ComplexTypeFeatures    `json:"user_complex_type_features"`
	ItemId                  string                 `json:"item_id"`
	ItemFeatures            map[string]interface{} `json:"item_features"`
	ItemComplexTypeFeatures ComplexTypeFeatures    `json:"item_complex_type_features"`
}

func (*EmbeddingParam) GetParameter added in v2.2.5

func (r *EmbeddingParam) GetParameter(name string) interface{}

type EmbeddingResponse added in v2.2.5

type EmbeddingResponse struct {
	Response
	Embedding []float32 `json:"embedding"`
}

func (*EmbeddingResponse) ToBytes added in v2.2.5

func (r *EmbeddingResponse) ToBytes() []byte

func (*EmbeddingResponse) ToString added in v2.2.5

func (r *EmbeddingResponse) ToString() string

type ErrorResponse

type ErrorResponse struct {
	Response
}

func (*ErrorResponse) ToString

func (e *ErrorResponse) ToString() string

type Feature added in v2.2.5

type Feature struct {
	Name   string `json:"name"`
	Values any    `json:"values"`
	Type   string `json:"type"`
}

type FeatureReplyController

type FeatureReplyController struct {
	Controller
	// contains filtered or unexported fields
}

func (*FeatureReplyController) CheckParameter

func (r *FeatureReplyController) CheckParameter() error

func (*FeatureReplyController) Process

type FeatureReplyData

type FeatureReplyData struct {
	Scene        string   `json:"scene"`
	RequestId    string   `json:"request_id"`
	UserId       string   `json:"user_id"` // user id
	UserFeatures string   `json:"user_features"`
	ItemIds      []string `json:"item_ids"` // item ids
	ItemFeatures []string `json:"item_features"`
}

type FeatureReplyParam

type FeatureReplyParam struct {
	DataSource  DataSourceInfo   `json:"datasource"`
	FeatureData FeatureReplyData `json:"items"`
}

func (*FeatureReplyParam) GetParameter

func (r *FeatureReplyParam) GetParameter(name string) interface{}

type FeatureReplyResponse

type FeatureReplyResponse struct {
	Response
}

func (*FeatureReplyResponse) ToString

func (r *FeatureReplyResponse) ToString() string

type ItemData

type ItemData struct {
	ItemId     string `json:"item_id"`
	ItemType   string `json:"item_type"`
	RetrieveId string `json:"retrieve_id"`
}

type RecommendController

type RecommendController struct {
	Controller
	// contains filtered or unexported fields
}

func (*RecommendController) CheckParameter

func (r *RecommendController) CheckParameter() error

func (*RecommendController) Process

type RecommendParam

type RecommendParam struct {
	SceneId  string                 `json:"scene_id"`
	Category string                 `json:"category"`
	Uid      string                 `json:"uid"`  // user id
	Size     int                    `json:"size"` // get recommend items size
	Debug    bool                   `json:"debug"`
	Features map[string]interface{} `json:"features"`
}

func (*RecommendParam) GetParameter

func (r *RecommendParam) GetParameter(name string) interface{}

type RecommendResponse

type RecommendResponse struct {
	Response
	Size  int         `json:"size"`
	Items []*ItemData `json:"items"`
}

func (*RecommendResponse) ToString

func (r *RecommendResponse) ToString() string

type Response

type Response struct {
	Code      int    `json:"code"`
	Message   string `json:"msg"`
	RequestId string `json:"request_id"`
}

type UserRecallController

type UserRecallController struct {
	Controller
	// contains filtered or unexported fields
}

func (*UserRecallController) CheckParameter

func (r *UserRecallController) CheckParameter() error

func (*UserRecallController) Process

type UserRecallItemData

type UserRecallItemData struct {
	ItemId string `json:"item_id"`
	// ItemType   string `json:"item_type"`
	RetrieveId string `json:"retrieve_id"`
}

type UserRecallParam

type UserRecallParam struct {
	SceneId  string `json:"scene_id"`
	Category string `json:"category"`
	Uid      string `json:"uid"`  // user id
	Size     int    `json:"size"` // get recommend items size
}

func (*UserRecallParam) GetParameter

func (r *UserRecallParam) GetParameter(name string) interface{}

type UserRecallResponse

type UserRecallResponse struct {
	Response
	Size   int                   `json:"size"`
	Items  []*UserRecallItemData `json:"items"`
	Errors []error               `json:"errors"`
}

func (*UserRecallResponse) ToString

func (r *UserRecallResponse) ToString() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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