Documentation
¶
Index ¶
- Constants
- func BodyProcessConfigCheck(config *BodyProcessConfig) error
- func EstimateContentToken(val string) int64
- func GetAuditData(ev Event) ([]byte, error)
- func GetEventTokens(ev Event) int64
- func GetHTTPClient() *http.Client
- func ProductRuleConfLoad(filename string) (productRuleConf, error)
- func SetAuditData(ev Event, data []byte) error
- func SetHTTPClient(client *http.Client)
- type BPError
- type BodyProcessConfig
- type BodyProcessor
- func (bp *BodyProcessor) AddProcessor(p EventProcessor)
- func (bp *BodyProcessor) Close() error
- func (bp *BodyProcessor) CreateEventDecoder(fac EventDecoderFac)
- func (bp *BodyProcessor) CreateEventEncoder(fac EventEncoderFac)
- func (bp *BodyProcessor) FillBuffer() error
- func (bp *BodyProcessor) GetSource() io.ReadCloser
- func (bp *BodyProcessor) OnReject(fn func(error, *BodyProcessor))
- func (bp *BodyProcessor) Read(p []byte) (n int, err error)
- func (bp *BodyProcessor) RejectionResponse() *RejectionError
- type ConfModBodyProcess
- type ContentAudit
- type ContentTypeDecoder
- type Event
- type EventDecoder
- type EventDecoderFac
- type EventDecoderFacWithReq
- type EventEncoder
- type EventEncoderFac
- type EventProcessor
- type EventProcessorFunc
- type GeneralEncoder
- type JsonDecoder
- type LineDecoder
- type ModuleBodyProcess
- func (m *ModuleBodyProcess) DoRequestProcess(req *bfe_basic.Request, conf *BodyProcessConfig) *BodyProcessor
- func (m *ModuleBodyProcess) DoResponseProcess(req *bfe_basic.Request, res *bfe_http.Response, conf *BodyProcessConfig) *BodyProcessor
- func (m *ModuleBodyProcess) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error
- func (m *ModuleBodyProcess) Name() string
- type ModuleBodyProcessState
- type ProcConf
- type ProcessRuleTable
- type ProductRules
- type ProductRulesFile
- type QuotaUsage
- type RawEvent
- type RejectionError
- type SSEEvent
- func (e *SSEEvent) AppendDataLine(b []byte)
- func (e *SSEEvent) GetAuditData() []byte
- func (e *SSEEvent) GetData() []byte
- func (e *SSEEvent) GetQuotaUsage() QuotaUsage
- func (e *SSEEvent) SetData(v []byte)
- func (e *SSEEvent) SetEvent(v *string)
- func (e *SSEEvent) SetID(v *string)
- func (e *SSEEvent) SetJsonField(jpath string, newValue string) error
- func (e *SSEEvent) ToBytes() []byte
- type SSEEventDecoder
- type TextFilterContactItem
- type TextFilterDetailItem
- type TextFilterResult
Constants ¶
View Source
const ( ModBodyProcess = "mod_body_process" BodyProcessResponseConfigKey = "mod_body_process.response_config" )
View Source
const UnknownModel = "unknown"
Variables ¶
This section is empty.
Functions ¶
func BodyProcessConfigCheck ¶
func BodyProcessConfigCheck(config *BodyProcessConfig) error
func EstimateContentToken ¶ added in v1.8.3
func GetAuditData ¶
func GetEventTokens ¶
func GetHTTPClient ¶
func ProductRuleConfLoad ¶
func SetAuditData ¶
func SetHTTPClient ¶
Types ¶
type BodyProcessConfig ¶
type BodyProcessor ¶
type BodyProcessor struct {
// contains filtered or unexported fields
}
BodyProcessor 扩展中断支持
func NewBodyProcessor ¶
func NewBodyProcessor(source io.ReadCloser) *BodyProcessor
NewBodyProcessor 创建处理器
func (*BodyProcessor) AddProcessor ¶
func (bp *BodyProcessor) AddProcessor(p EventProcessor)
func (*BodyProcessor) CreateEventDecoder ¶
func (bp *BodyProcessor) CreateEventDecoder(fac EventDecoderFac)
func (*BodyProcessor) CreateEventEncoder ¶
func (bp *BodyProcessor) CreateEventEncoder(fac EventEncoderFac)
func (*BodyProcessor) FillBuffer ¶
func (bp *BodyProcessor) FillBuffer() error
FillBuffer 公开的缓冲区填充方法 安全地从源读取并处理一个数据块
func (*BodyProcessor) GetSource ¶
func (bp *BodyProcessor) GetSource() io.ReadCloser
func (*BodyProcessor) OnReject ¶
func (bp *BodyProcessor) OnReject(fn func(error, *BodyProcessor))
注册中断回调
func (*BodyProcessor) Read ¶
func (bp *BodyProcessor) Read(p []byte) (n int, err error)
Read 实现io.Reader接口(支持中断)
func (*BodyProcessor) RejectionResponse ¶
func (bp *BodyProcessor) RejectionResponse() *RejectionError
RejectionResponse 获取中断响应(如在反向代理中使用)
type ConfModBodyProcess ¶
type ConfModBodyProcess struct {
Basic struct {
ProductRulePath string
}
Log struct {
OpenDebug bool
}
}
func (*ConfModBodyProcess) Check ¶
func (cfg *ConfModBodyProcess) Check(confRoot string) error
type ContentAudit ¶
type ContentAudit struct {
// contains filtered or unexported fields
}
func NewContentAudit ¶
func NewContentAudit(urlStr string, replace bool) (*ContentAudit, error)
type ContentTypeDecoder ¶
type ContentTypeDecoder struct {
// contains filtered or unexported fields
}
func (*ContentTypeDecoder) Decode ¶
func (ctd *ContentTypeDecoder) Decode() ([]Event, error)
type Event ¶
type Event interface {
// GetType() string
// GetData() []byte
ToBytes() []byte // 转换为字节数组
}
type EventDecoder ¶
type EventDecoder interface {
// return:
// events, nil - len(events) > 0, success
// events, nil - len(events) = 0, 没有更多数据, eof
// nil, error - 发生错误
Decode() ([]Event, error)
}
func NewContentTypeDecoder ¶
func NewContentTypeDecoder(source io.Reader, contentType string) (EventDecoder, error)
func NewJsonDecoder ¶
func NewJsonDecoder(source io.Reader) (EventDecoder, error)
func NewLineDecoder ¶
func NewLineDecoder(source io.Reader) (EventDecoder, error)
func NewSSEEventDecoder ¶
func NewSSEEventDecoder(source io.Reader) (EventDecoder, error)
type EventDecoderFac ¶
type EventDecoderFac func(source io.Reader) (EventDecoder, error)
type EventDecoderFacWithReq ¶
type EventEncoder ¶
func NewGeneralEncoder ¶
func NewGeneralEncoder(dest io.Writer) (EventEncoder, error)
type EventEncoderFac ¶
type EventEncoderFac func(dest io.Writer) (EventEncoder, error)
type EventProcessor ¶
type EventProcessorFunc ¶
ProcessorFunc 简化处理器实现
func NewCalcCompletionQuota ¶
func NewCalcCompletionQuota(req *bfe_basic.Request) EventProcessorFunc
type GeneralEncoder ¶
type GeneralEncoder struct {
// contains filtered or unexported fields
}
type JsonDecoder ¶
type JsonDecoder struct {
// contains filtered or unexported fields
}
func (*JsonDecoder) Decode ¶
func (dec *JsonDecoder) Decode() ([]Event, error)
type LineDecoder ¶
type LineDecoder struct {
// contains filtered or unexported fields
}
func (*LineDecoder) Decode ¶
func (dec *LineDecoder) Decode() ([]Event, error)
type ModuleBodyProcess ¶
type ModuleBodyProcess struct {
// contains filtered or unexported fields
}
func NewModuleBodyProcess ¶
func NewModuleBodyProcess() *ModuleBodyProcess
func (*ModuleBodyProcess) DoRequestProcess ¶
func (m *ModuleBodyProcess) DoRequestProcess(req *bfe_basic.Request, conf *BodyProcessConfig) *BodyProcessor
func (*ModuleBodyProcess) DoResponseProcess ¶
func (m *ModuleBodyProcess) DoResponseProcess(req *bfe_basic.Request, res *bfe_http.Response, conf *BodyProcessConfig) *BodyProcessor
func (*ModuleBodyProcess) Init ¶
func (m *ModuleBodyProcess) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error
func (*ModuleBodyProcess) Name ¶
func (m *ModuleBodyProcess) Name() string
type ModuleBodyProcessState ¶
type ProcessRuleTable ¶
type ProcessRuleTable struct {
// contains filtered or unexported fields
}
func NewTokenRuleTable ¶
func NewTokenRuleTable() *ProcessRuleTable
func (*ProcessRuleTable) Search ¶
func (t *ProcessRuleTable) Search(product string) (processRuleList, bool)
func (*ProcessRuleTable) Update ¶
func (t *ProcessRuleTable) Update(conf productRuleConf)
type ProductRules ¶
type ProductRules map[string]processRuleList
type ProductRulesFile ¶
type ProductRulesFile map[string]processRuleFileList
type QuotaUsage ¶ added in v1.8.3
type QuotaUsage struct {
//return from reponse
PromptTokens int64 // number of tokens in the prompt
CompletionTokens int64 // number of tokens in the completion
UsedQuota int64 // used quota for this request
//estimate for current response
CurrentTokens int64 //effect when IsGuess is true
IsGuess bool //true = is estimate
}
type RejectionError ¶
RejectionError 自定义错误类型
func (*RejectionError) Error ¶
func (e *RejectionError) Error() string
type SSEEvent ¶
type SSEEvent struct {
ID *string
Event *string
DataLines [][]byte
Retry *int
Comments [][]byte
RawLines [][]byte
// contains filtered or unexported fields
}
func (*SSEEvent) AppendDataLine ¶ added in v1.8.3
func (*SSEEvent) GetAuditData ¶ added in v1.8.3
func (*SSEEvent) GetQuotaUsage ¶ added in v1.8.3
func (e *SSEEvent) GetQuotaUsage() QuotaUsage
func (*SSEEvent) SetJsonField ¶ added in v1.8.3
type SSEEventDecoder ¶
type SSEEventDecoder struct {
// contains filtered or unexported fields
}
func (*SSEEventDecoder) Decode ¶
func (d *SSEEventDecoder) Decode() ([]Event, error)
type TextFilterContactItem ¶
type TextFilterDetailItem ¶
type TextFilterResult ¶
type TextFilterResult struct {
Code int32
Message string
RequestId string
RiskLevel string
RiskCode string
SentimentScore float32
ResultText string
Details []TextFilterDetailItem
Contacts []TextFilterContactItem
}
Click to show internal directories.
Click to hide internal directories.