convert

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConverters

func InitConverters() error

func RegisterConverter

func RegisterConverter(name string, factory func(any) (Converter, error))

Types

type ActionBasedOnPattern

type ActionBasedOnPattern struct {
	Trim    bool   `json:"trim"`
	Regex   bool   `json:"is_regex"`
	Pattern string `json:"pattern"`
	Action  string `json:"action"`
	// contains filtered or unexported fields
}

ActionBasedOnPattern Sometimes we detect that the content need to be drop or ignored For example, the last [DONE] message in openai event stream It is useless for non openai API clients, and should be dropped It detects the input content and decide whether to drop it

func (*ActionBasedOnPattern) Convert

func (*ActionBasedOnPattern) IsReusable

func (a *ActionBasedOnPattern) IsReusable() bool

type ConvertContext

type ConvertContext map[string]any

type Converter

type Converter interface {
	Convert(types.HTTPContent, ConvertContext) (types.HTTPContent, error)
	// IsReusable Whether this converter is reusable. i.e. stateless so can be used
	// for multiple conversions without the need to recreate everytime
	IsReusable() bool
}

func CreateConverter

func CreateConverter(name string, config any) (Converter, error)

func NewActionBasedOnPattern

func NewActionBasedOnPattern(config any) (Converter, error)

func NewHeaderConverter

func NewHeaderConverter(config any) (Converter, error)

func NewJsonataConverter

func NewJsonataConverter(config any) (Converter, error)

type ConverterPipeline

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

ConverterPipeline Itself is a Conveter

func NewConverterPipeline

func NewConverterPipeline(config []types.ConversionStepDef) (*ConverterPipeline, error)

func (*ConverterPipeline) Convert

func (*ConverterPipeline) IsReusable

func (p *ConverterPipeline) IsReusable() bool

type HeaderConverter

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

func (*HeaderConverter) Convert

func (*HeaderConverter) IsReusable

func (c *HeaderConverter) IsReusable() bool

type JsonataConverter

type JsonataConverter struct {
	Expression string
	// contains filtered or unexported fields
}

func (*JsonataConverter) Convert

func (*JsonataConverter) IsReusable

func (c *JsonataConverter) IsReusable() bool

Jump to

Keyboard shortcuts

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