schedule

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModelPreparationTimeout 模型准备超时时间
	ModelPreparationTimeout = 5 * time.Minute
)

Variables

View Source
var FlavorServiceDefaultInfoMap = make(map[string]map[string]ServiceDefaultInfo)

Functions

func AllAPIFlavors

func AllAPIFlavors() map[string]APIFlavor

func ConvertBetweenFlavors

func ConvertBetweenFlavors(from, to APIFlavor, service string, conv string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func EnsureConversionNameValid

func EnsureConversionNameValid(conversion string)

func ExecuteMiddleware

func ExecuteMiddleware(st *ServiceTask) error

ExecuteMiddleware Executes the middleware chain

func GRPCWebSocketHandler

func GRPCWebSocketHandler(wsConn *client.WebSocketConnection, done chan struct{})

GRPCWebSocketHandler handle GRCWebSocket

func GetProviderServices

func GetProviderServices(flavor string) map[string]ServiceDefaultInfo

func InitAPIFlavors

func InitAPIFlavors() error

func InitConverters added in v0.7.0

func InitConverters() error

InitConverters initializes all converter types (can be called separately before InitAPIFlavors)

func InitProviderDefaultModelTemplate

func InitProviderDefaultModelTemplate(flavor APIFlavor)

func InvokeService

func InvokeService(fromFlavor string, service string, request *http.Request) (uint64, chan *types.ServiceResult, error)

func NewStreamMode

func NewStreamMode(header http.Header) *types.StreamMode

func RegisterAPIFlavor

func RegisterAPIFlavor(f APIFlavor)

func RemoteWebSocketHandler

func RemoteWebSocketHandler(wsConn *client.WebSocketConnection, done chan struct{})

RemoteWebSocketHandler handle HTTPWebSocket

func StartScheduler

func StartScheduler(s string)

func TencentSignGenerate

func TencentSignGenerate(p SignParams, req http.Request) error

Types

type APIFlavor

type APIFlavor interface {
	Name() string
	InstallRoutes(server *gin.Engine)

	// GetStreamResponseProlog In stream mode, some flavor may ask for some packets to be send first
	// or at the end, in addition to normal contents. For example, OpenAI
	// needs to send an additional "data: [DONE]" after everything is done.
	GetStreamResponseProlog(service string) []string
	GetStreamResponseEpilog(service string) []string

	// Convert This should cover the 6 conversion methods below
	Convert(service string, conversion string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

	ConvertRequestToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)
	ConvertRequestFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)
	ConvertResponseToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)
	ConvertResponseFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)
	ConvertStreamResponseToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)
	ConvertStreamResponseFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)
}

APIFlavor mode is usually set to "default". And set to "stream" if it is using stream mode

func GetAPIFlavor

func GetAPIFlavor(name string) (APIFlavor, error)

type APIKEYAuthenticator

type APIKEYAuthenticator struct {
	AuthInfo string `json:"auth_info"`
	Req      http.Request
}

func (*APIKEYAuthenticator) Authenticate

func (a *APIKEYAuthenticator) Authenticate() error

type ApiKeyAuthInfo

type ApiKeyAuthInfo struct {
	ApiKey string `json:"api_key"`
}

type Authenticator

type Authenticator interface {
	Authenticate() error
}

func ChooseProviderAuthenticator

func ChooseProviderAuthenticator(p *AuthenticatorParams) Authenticator

type AuthenticatorParams

type AuthenticatorParams struct {
	Request      *http.Request
	ProviderInfo *types.ServiceProvider
	RequestBody  string
}

type BaseGRPCHandler

type BaseGRPCHandler struct{}

func (*BaseGRPCHandler) PrepareStreamRequest

func (h *BaseGRPCHandler) PrepareStreamRequest(content types.HTTPContent, st *ServiceTask) (*grpc_client.ModelInferRequest, error)

func (*BaseGRPCHandler) ProcessStreamResponse

func (h *BaseGRPCHandler) ProcessStreamResponse(streamResponse *grpc_client.ModelStreamInferResponse, wsConnID string) (*http.Response, bool, error)

type BaseHandler

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

BaseHandler provides a basic processor implementation

func NewBaseHandler

func NewBaseHandler(name string) BaseHandler

func (*BaseHandler) HandleNext

func (h *BaseHandler) HandleNext(ctx *ServiceContext) error

func (*BaseHandler) SetNext

func (h *BaseHandler) SetNext(handler ServiceHandler) ServiceHandler

type BaseMiddleware

type BaseMiddleware struct {
	ServiceName string
}

type BasicServiceScheduler

type BasicServiceScheduler struct {
	WaitingList *utils.SafeList
	RunningList *utils.SafeList
	ChEvent     chan *ServiceTaskEvent
	// contains filtered or unexported fields
}

func NewBasicServiceScheduler

func NewBasicServiceScheduler() *BasicServiceScheduler

func (*BasicServiceScheduler) Enqueue

func (*BasicServiceScheduler) Start

func (ss *BasicServiceScheduler) Start()

func (*BasicServiceScheduler) TaskComplete

func (ss *BasicServiceScheduler) TaskComplete(task *ServiceTask, err error)

type ChatMiddleware

type ChatMiddleware struct {
	BaseMiddleware
}

ChatMiddleware Handles chat-related requests

func NewChatMiddleware

func NewChatMiddleware() *ChatMiddleware

func (*ChatMiddleware) Handle

func (m *ChatMiddleware) Handle(st *ServiceTask) error

type ConfigBasedAPIFlavor

type ConfigBasedAPIFlavor struct {
	Config FlavorDef
	// contains filtered or unexported fields
}

func NewConfigBasedAPIFlavor

func NewConfigBasedAPIFlavor(config FlavorDef) (*ConfigBasedAPIFlavor, error)

func (*ConfigBasedAPIFlavor) Convert

func (f *ConfigBasedAPIFlavor) Convert(service, conversion string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*ConfigBasedAPIFlavor) ConvertRequestFromAOG

func (f *ConfigBasedAPIFlavor) ConvertRequestFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*ConfigBasedAPIFlavor) ConvertRequestToAOG

func (f *ConfigBasedAPIFlavor) ConvertRequestToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*ConfigBasedAPIFlavor) ConvertResponseFromAOG

func (f *ConfigBasedAPIFlavor) ConvertResponseFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*ConfigBasedAPIFlavor) ConvertResponseToAOG

func (f *ConfigBasedAPIFlavor) ConvertResponseToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*ConfigBasedAPIFlavor) ConvertStreamResponseFromAOG

func (f *ConfigBasedAPIFlavor) ConvertStreamResponseFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*ConfigBasedAPIFlavor) ConvertStreamResponseToAOG

func (f *ConfigBasedAPIFlavor) ConvertStreamResponseToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*ConfigBasedAPIFlavor) GetConverterPipeline

func (f *ConfigBasedAPIFlavor) GetConverterPipeline(service, conv string) *convert.ConverterPipeline

func (*ConfigBasedAPIFlavor) GetStreamResponseEpilog

func (f *ConfigBasedAPIFlavor) GetStreamResponseEpilog(service string) []string

func (*ConfigBasedAPIFlavor) GetStreamResponseProlog

func (f *ConfigBasedAPIFlavor) GetStreamResponseProlog(service string) []string

func (*ConfigBasedAPIFlavor) InstallRoutes

func (f *ConfigBasedAPIFlavor) InstallRoutes(gateway *gin.Engine)

func (*ConfigBasedAPIFlavor) Name

func (f *ConfigBasedAPIFlavor) Name() string

type DefaultMetricsCollector

type DefaultMetricsCollector struct{}

DefaultMetricsCollector is the default metrics collector

func (*DefaultMetricsCollector) CollectMetrics

func (c *DefaultMetricsCollector) CollectMetrics(metrics HandlerMetrics)

type Event

type Event struct {
	Header  Header  `json:"header"`
	Payload Payload `json:"payload"`
}

type FlavorDef

type FlavorDef struct {
	Version  string                      `yaml:"version"`
	Name     string                      `yaml:"name"`
	Services map[string]FlavorServiceDef `yaml:"services"`
}

func GetFlavorDef

func GetFlavorDef(flavor string) FlavorDef

func LoadFlavorDef

func LoadFlavorDef(flavor string) (FlavorDef, error)

type FlavorServiceDef

type FlavorServiceDef struct {
	Protocol              string                    `yaml:"protocol"`
	ExposeProtocol        string                    `yaml:"expose_protocol"`
	TaskType              string                    `yaml:"task_type"`
	Endpoints             []string                  `yaml:"endpoints"`
	InstallRawRoutes      bool                      `yaml:"install_raw_routes"`
	DefaultModel          string                    `yaml:"default_model"`
	RequestUrl            string                    `yaml:"url"`
	RequestExtraUrl       string                    `yaml:"extra_url"`
	AuthType              string                    `yaml:"auth_type"`
	AuthApplyUrl          string                    `yaml:"auth_apply_url"`
	RequestSegments       int                       `yaml:"request_segments"`
	ExtraHeaders          string                    `yaml:"extra_headers"`
	SupportModels         []string                  `yaml:"support_models"`
	ModelSelector         ModelSelector             `yaml:"model_selector"`
	RequestToAOG          types.FlavorConversionDef `yaml:"request_to_aog"`
	RequestFromAOG        types.FlavorConversionDef `yaml:"request_from_aog"`
	ResponseToAOG         types.FlavorConversionDef `yaml:"response_to_aog"`
	ResponseFromAOG       types.FlavorConversionDef `yaml:"response_from_aog"`
	StreamResponseToAOG   types.FlavorConversionDef `yaml:"stream_response_to_aog"`
	StreamResponseFromAOG types.FlavorConversionDef `yaml:"stream_response_from_aog"`
}

type GRPCInvoker

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

GRPCInvoker implements the invocation of GRPC services

func (*GRPCInvoker) Invoke

func (g *GRPCInvoker) Invoke(sp *types.ServiceProvider, content types.HTTPContent) (*http.Response, error)

Invoke implements GRPC service invocation

type GRPCServiceHandler

type GRPCServiceHandler interface {
	PrepareRequest(content types.HTTPContent, target *types.ServiceTarget) (*grpc_client.ModelInferRequest, error)
	ProcessResponse(inferResponse *grpc_client.ModelInferResponse) (*http.Response, error)

	PrepareStreamRequest(content types.HTTPContent, st *ServiceTask) (*grpc_client.ModelInferRequest, error)
	ProcessStreamResponse(streamResponse *grpc_client.ModelStreamInferResponse, wsConnID string) (*http.Response, bool, error)
}

GRPCServiceHandler define the interface for handling GRPC service requests

func NewGRPCServiceHandler

func NewGRPCServiceHandler(serviceType string) GRPCServiceHandler

type HTTPInvoker

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

HTTPInvoker implements the invocation of HTTP services

func (*HTTPInvoker) Invoke

func (h *HTTPInvoker) Invoke(sp *types.ServiceProvider, content types.HTTPContent) (*http.Response, error)

Invoke implements HTTP service invocation

type HandlerMetrics

type HandlerMetrics struct {
	StartTime   time.Time
	Duration    time.Duration
	HandlerName string
}

HandlerMetrics is used to record handler performance metrics

type Header struct {
	Action       string                 `json:"action"`
	TaskID       string                 `json:"task_id"`
	Streaming    string                 `json:"streaming"`
	Event        string                 `json:"event"`
	ErrorCode    string                 `json:"error_code,omitempty"`
	ErrorMessage string                 `json:"error_message,omitempty"`
	Attributes   map[string]interface{} `json:"attributes"`
}

type ImageToImageMiddleware

type ImageToImageMiddleware struct {
	BaseMiddleware
}

func NewImageToImageMiddleware

func NewImageToImageMiddleware() *ImageToImageMiddleware

func (*ImageToImageMiddleware) Handle

func (m *ImageToImageMiddleware) Handle(st *ServiceTask) error

type ImageToVideoMiddleware

type ImageToVideoMiddleware struct {
	BaseMiddleware
}

func NewImageToVideoMiddleware

func NewImageToVideoMiddleware() *ImageToVideoMiddleware

func (*ImageToVideoMiddleware) Handle

func (m *ImageToVideoMiddleware) Handle(st *ServiceTask) error

type Input

type Input struct{}

type Invoker

type Invoker interface {
	Invoke(sp *types.ServiceProvider, content types.HTTPContent) (*http.Response, error)
}

Invoker defines the interface for service invocation

func NewInvoker

func NewInvoker(task *ServiceTask, providerType string) Invoker

NewInvoker creates the corresponding invoker

type MetricsCollector

type MetricsCollector interface {
	CollectMetrics(metrics HandlerMetrics)
}

MetricsCollector collects handler performance metrics

type MiddlewareHandler

type MiddlewareHandler struct {
	BaseHandler
}

MiddlewareHandler handles middleware logic

func (*MiddlewareHandler) Handle

func (h *MiddlewareHandler) Handle(ctx *ServiceContext) error

type ModelSelector

type ModelSelector struct {
	ModelInRequest  string `yaml:"request"`
	ModelInResponse string `yaml:"response"`
}

type Output

type Output struct {
	Sentence struct {
		BeginTime int64  `json:"begin_time"`
		EndTime   *int64 `json:"end_time"`
		Text      string `json:"text"`
		Words     []struct {
			BeginTime   int64  `json:"begin_time"`
			EndTime     *int64 `json:"end_time"`
			Text        string `json:"text"`
			Punctuation string `json:"punctuation"`
		} `json:"words"`
	} `json:"sentence"`
	Usage interface{} `json:"usage"`
}

type Params

type Params struct {
	Format                   string   `json:"format"`
	SampleRate               int      `json:"sample_rate"`
	VocabularyID             string   `json:"vocabulary_id"`
	DisfluencyRemovalEnabled bool     `json:"disfluency_removal_enabled"`
	LanguageHints            []string `json:"language_hints"`
}

type Payload

type Payload struct {
	TaskGroup  string `json:"task_group"`
	Task       string `json:"task"`
	Function   string `json:"function"`
	Model      string `json:"model"`
	Parameters Params `json:"parameters"`
	// Resources  []Resource `json:"resources"`
	Input  Input  `json:"input"`
	Output Output `json:"output,omitempty"`
}

type PluginBasedAPIFlavor added in v0.7.0

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

PluginBasedAPIFlavor 基于插件 manifest 动态创建的 APIFlavor 实现与内置 ConfigBasedAPIFlavor 相同的接口

func NewPluginBasedAPIFlavor added in v0.7.0

func NewPluginBasedAPIFlavor(manifest *sdktypes.PluginManifest) (*PluginBasedAPIFlavor, error)

NewPluginBasedAPIFlavor 从插件 manifest 创建 APIFlavor

func (*PluginBasedAPIFlavor) Convert added in v0.7.0

func (f *PluginBasedAPIFlavor) Convert(service string, conversion string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*PluginBasedAPIFlavor) ConvertRequestFromAOG added in v0.7.0

func (f *PluginBasedAPIFlavor) ConvertRequestFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*PluginBasedAPIFlavor) ConvertRequestToAOG added in v0.7.0

func (f *PluginBasedAPIFlavor) ConvertRequestToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*PluginBasedAPIFlavor) ConvertResponseFromAOG added in v0.7.0

func (f *PluginBasedAPIFlavor) ConvertResponseFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*PluginBasedAPIFlavor) ConvertResponseToAOG added in v0.7.0

func (f *PluginBasedAPIFlavor) ConvertResponseToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*PluginBasedAPIFlavor) ConvertStreamResponseFromAOG added in v0.7.0

func (f *PluginBasedAPIFlavor) ConvertStreamResponseFromAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*PluginBasedAPIFlavor) ConvertStreamResponseToAOG added in v0.7.0

func (f *PluginBasedAPIFlavor) ConvertStreamResponseToAOG(service string, content types.HTTPContent, ctx convert.ConvertContext) (types.HTTPContent, error)

func (*PluginBasedAPIFlavor) GetStreamResponseEpilog added in v0.7.0

func (f *PluginBasedAPIFlavor) GetStreamResponseEpilog(service string) []string

func (*PluginBasedAPIFlavor) GetStreamResponseProlog added in v0.7.0

func (f *PluginBasedAPIFlavor) GetStreamResponseProlog(service string) []string

func (*PluginBasedAPIFlavor) InitServiceDefaultInfo added in v0.7.0

func (f *PluginBasedAPIFlavor) InitServiceDefaultInfo()

InitServiceDefaultInfo 初始化插件的服务默认信息 插件需要手动初始化服务信息,因为不依赖内置 template

func (*PluginBasedAPIFlavor) InstallRoutes added in v0.7.0

func (f *PluginBasedAPIFlavor) InstallRoutes(server *gin.Engine)

func (*PluginBasedAPIFlavor) Name added in v0.7.0

func (f *PluginBasedAPIFlavor) Name() string

type PluginInvoker added in v0.7.0

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

PluginInvoker implements plugin service invocation with strict capability-based routing. Core principle: Route based on capabilities declared in manifest without implicit degradation.

func NewPluginInvoker added in v0.7.0

func NewPluginInvoker(task *ServiceTask) *PluginInvoker

NewPluginInvoker creates a new plugin invoker

func (*PluginInvoker) Invoke added in v0.7.0

func (p *PluginInvoker) Invoke(sp *types.ServiceProvider, content types.HTTPContent) (resp *http.Response, err error)

Invoke implements plugin service invocation with capability-based routing.

type RequestConversionHandler

type RequestConversionHandler struct {
	BaseHandler
}

RequestConversionHandler handles request conversion

func (*RequestConversionHandler) Handle

type ResponseHandler

type ResponseHandler struct {
	BaseHandler
}

ResponseHandler optimizes stream response processing

func (*ResponseHandler) Handle

func (h *ResponseHandler) Handle(ctx *ServiceContext) error

type RetryableError

type RetryableError struct {
	Err error
}

RetryableError defines a retryable error

func (*RetryableError) Error

func (e *RetryableError) Error() string

type ServiceContext

type ServiceContext struct {
	Task       *ServiceTask
	Request    *types.HTTPContent
	Response   *http.Response
	Error      error
	Metrics    MetricsCollector
	RetryCount int
	MaxRetries int
}

ServiceContext contains the context information needed for service processing

func NewServiceContext

func NewServiceContext(task *ServiceTask) *ServiceContext

NewServiceContext creates a service context

type ServiceDefaultInfo

type ServiceDefaultInfo struct {
	Endpoints       []string `json:"endpoints"`
	DefaultModel    string   `json:"default_model"`
	RequestUrl      string   `json:"url"`
	RequestExtraUrl string   `json:"request_extra_url"`
	AuthType        string   `json:"auth_type"`
	RequestSegments int      `json:"request_segments"`
	ExtraHeaders    string   `json:"extra_headers"`
	SupportModels   []string `json:"support_models"`
	AuthApplyUrl    string   `json:"auth_apply_url"`
	Protocol        string   `json:"protocol"`
	TaskType        string   `json:"task_type"`
	ExposeProtocol  string   `json:"expose_protocol"`
}

func GetProviderServiceDefaultInfo

func GetProviderServiceDefaultInfo(flavor string, service string) ServiceDefaultInfo

type ServiceHandler

type ServiceHandler interface {
	Handle(ctx *ServiceContext) error
}

ServiceHandler defines the interface for handling service requests

type ServiceInvokerHandler

type ServiceInvokerHandler struct {
	BaseHandler
}

ServiceInvokerHandler handles service invocation

func (*ServiceInvokerHandler) Handle

func (h *ServiceInvokerHandler) Handle(ctx *ServiceContext) error

type ServiceScheduler

type ServiceScheduler interface {
	// Enqueue itself is a non-blocking API. It returns the task ID and
	// a chan to return results as the Restful service
	Enqueue(*types.ServiceRequest) (uint64, chan *types.ServiceResult)
	Start()
	TaskComplete(*ServiceTask, error)
}

func GetScheduler

func GetScheduler() ServiceScheduler

type ServiceTask

type ServiceTask struct {
	Request  *types.ServiceRequest
	Target   *types.ServiceTarget
	Ch       chan *types.ServiceResult
	Error    error
	Schedule types.ScheduleDetails
}

func (*ServiceTask) Run

func (st *ServiceTask) Run() error

func (*ServiceTask) String

func (st *ServiceTask) String() string

type ServiceTaskEvent

type ServiceTaskEvent struct {
	Type  ServiceTaskEventType
	Task  *ServiceTask
	Error error // only for ServiceTaskFailed
}

type ServiceTaskEventType

type ServiceTaskEventType int
const (
	ServiceTaskEnqueue ServiceTaskEventType = iota
	ServiceTaskFailed
	ServiceTaskDone
)

type SignAuthInfo

type SignAuthInfo struct {
	SecretId  string `json:"secret_id"`
	SecretKey string `json:"secret_key"`
}

type SignCommonParams

type SignCommonParams struct {
	Version string `json:"version"`
	Action  string `json:"action"`
	Region  string `json:"region"`
}

type SignParams

type SignParams struct {
	SecretId      string           `json:"secret_id"`
	SecretKey     string           `json:"secret_key"`
	RequestBody   string           `json:"request_body"`
	RequestUrl    string           `json:"request_url"`
	RequestMethod string           `json:"request_method"`
	RequestHeader http.Header      `json:"request_header"`
	CommonParams  SignCommonParams `json:"common_params"`
}

type SpeechToTextHandler

type SpeechToTextHandler struct {
	BaseGRPCHandler
}

SpeechToTextHandler handles speech-to-text service

func NewSpeechToTextHandler

func NewSpeechToTextHandler() *SpeechToTextHandler

func (*SpeechToTextHandler) PrepareRequest

func (*SpeechToTextHandler) ProcessResponse

func (h *SpeechToTextHandler) ProcessResponse(inferResponse *grpc_client.ModelInferResponse) (*http.Response, error)

type SpeechToTextMiddleware

type SpeechToTextMiddleware struct {
	BaseMiddleware
}

SpeechToTextMiddleware Handles SpeechToText-related requests

func NewSpeechToTextMiddleware

func NewSpeechToTextMiddleware() *SpeechToTextMiddleware

func (*SpeechToTextMiddleware) Handle

func (m *SpeechToTextMiddleware) Handle(st *ServiceTask) error

type SpeechToTextWSHandler

type SpeechToTextWSHandler struct {
	BaseGRPCHandler
}

func NewSpeechToTextWSHandler

func NewSpeechToTextWSHandler() *SpeechToTextWSHandler

func (*SpeechToTextWSHandler) PrepareRequest

PrepareRequest Implementing non-streaming request preparation

func (*SpeechToTextWSHandler) PrepareStreamRequest

func (h *SpeechToTextWSHandler) PrepareStreamRequest(content types.HTTPContent, st *ServiceTask) (*grpc_client.ModelInferRequest, error)

PrepareStreamRequest Prepare a streaming request

func (*SpeechToTextWSHandler) ProcessResponse

func (h *SpeechToTextWSHandler) ProcessResponse(inferResponse *grpc_client.ModelInferResponse) (*http.Response, error)

ProcessResponse Implementing non-streaming response processing

func (*SpeechToTextWSHandler) ProcessStreamResponse

func (h *SpeechToTextWSHandler) ProcessStreamResponse(streamResponse *grpc_client.ModelStreamInferResponse, wsConnID string) (*http.Response, bool, error)

ProcessStreamResponse Process streaming responses

type SpeechToTextWSMiddleware

type SpeechToTextWSMiddleware struct {
	BaseMiddleware
}

SpeechToTextWSMiddleware handles WebSocket speech recognition requests

func NewSpeechToTextWSMiddleware

func NewSpeechToTextWSMiddleware() *SpeechToTextWSMiddleware

func (*SpeechToTextWSMiddleware) Handle

type SpeechToTextWSRemoteHandler

type SpeechToTextWSRemoteHandler struct {
	BaseGRPCHandler
}

func NewSpeechToTextWSRemoteHandler

func NewSpeechToTextWSRemoteHandler() *SpeechToTextWSRemoteHandler

type StreamProcessor

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

StreamProcessor handles stream response processing

func NewStreamProcessor

func NewStreamProcessor(ctx *ServiceContext, mode *types.StreamMode, reqFlavor, targetFlavor APIFlavor) *StreamProcessor

func (*StreamProcessor) Process

func (sp *StreamProcessor) Process(reader *bufio.Reader) error

type TaskMiddleware

type TaskMiddleware interface {
	Handle(st *ServiceTask) error
}

func GetMiddleware

func GetMiddleware(serviceName string) []TaskMiddleware

GetMiddleware Returns the corresponding middleware chain based on the service type

type TencentSignAuthenticator

type TencentSignAuthenticator struct {
	AuthInfo     string                `json:"auth_info"`
	Req          http.Request          `json:"request"`
	ProviderInfo types.ServiceProvider `json:"provider_info"`
	ReqBody      string                `json:"req_body"`
}

func (*TencentSignAuthenticator) Authenticate

func (s *TencentSignAuthenticator) Authenticate() error

type TextToImageHandler

type TextToImageHandler struct {
	BaseGRPCHandler
}

TextToImageHandler handles text-to-image service

func NewTextToImageHandler

func NewTextToImageHandler() *TextToImageHandler

func (*TextToImageHandler) PrepareRequest

func (*TextToImageHandler) ProcessResponse

func (h *TextToImageHandler) ProcessResponse(inferResponse *grpc_client.ModelInferResponse) (*http.Response, error)

type TextToImageMiddleware

type TextToImageMiddleware struct {
	BaseMiddleware
}

TextToImageMiddleware Handles image-related requests

func NewTextToImageMiddleware

func NewTextToImageMiddleware() *TextToImageMiddleware

func (*TextToImageMiddleware) Handle

func (m *TextToImageMiddleware) Handle(st *ServiceTask) error

type TextToSpeechHandler

type TextToSpeechHandler struct {
	BaseGRPCHandler
}

TextToSpeechHandler handles text-to-speech service

func NewTextToSpeechHandler

func NewTextToSpeechHandler() *TextToSpeechHandler

func (*TextToSpeechHandler) PrepareRequest

func (*TextToSpeechHandler) PrepareStreamRequest

func (h *TextToSpeechHandler) PrepareStreamRequest(content types.HTTPContent, st *ServiceTask) (*grpc_client.ModelInferRequest, error)

func (*TextToSpeechHandler) ProcessResponse

func (h *TextToSpeechHandler) ProcessResponse(inferResponse *grpc_client.ModelInferResponse) (*http.Response, error)

func (*TextToSpeechHandler) ProcessStreamResponse

func (h *TextToSpeechHandler) ProcessStreamResponse(streamResponse *grpc_client.ModelStreamInferResponse, wsConnID string) (*http.Response, bool, error)

type TextToSpeechMiddleware

type TextToSpeechMiddleware struct {
	BaseMiddleware
}

func NewTextToSpeechMiddleware

func NewTextToSpeechMiddleware() *TextToSpeechMiddleware

func (*TextToSpeechMiddleware) Handle

func (m *TextToSpeechMiddleware) Handle(st *ServiceTask) error

Jump to

Keyboard shortcuts

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