rewrite

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	ActionDropFeed            Action = "drop_feed"
	ActionCreateOrUpdateLabel Action = "create_or_update_label"
)

type Config

type Config []Rule

func (*Config) From

func (c *Config) From(app *config.App)

func (*Config) Validate

func (c *Config) Validate() error

type Dependencies

type Dependencies struct {
	LLMFactory    llm.Factory // NOTE: String() with cache.
	ObjectStorage object.Storage
}

type Factory

--- Factory code block ---

func NewFactory

func NewFactory(mockOn ...component.MockOption) Factory

type Rewriter

type Rewriter interface {
	component.Component
	config.Watcher

	// Labels applies rewrite rules to the given labels and returns the modified labels.
	// Note: this method modifies the input labels in place.
	// If a rule's action is ActionDropFeed, it returns nil to indicate the item should be dropped.
	Labels(ctx context.Context, labels model.Labels) (model.Labels, error)
}

--- Interface code block ---

type Rule

type Rule struct {
	// If is the condition to check before applying the rule.
	// If not set, the rule will be applied.
	If []string

	// SourceLabel specifies which label's value to use as source text.
	// Default is model.LabelContent.
	SourceLabel string

	// SkipTooShortThreshold is the threshold of the source text length.
	// If the source text is shorter than this threshold, it will be skipped.
	SkipTooShortThreshold *int

	// Transform used to transform the source text.
	// If not set, transform to original source text.
	Transform *Transform

	// Match used to match the text after transform.
	// If not set, match all.
	Match string

	// Action determines what to do if matchs.
	Action Action

	// Label is the label to create or update.
	Label string
	// contains filtered or unexported fields
}

func (*Rule) From

func (r *Rule) From(c *config.RewriteRule)

func (*Rule) Validate

func (r *Rule) Validate() error

type Speaker added in v0.5.0

type Speaker struct {
	Name  string
	Role  string
	Voice string
}

type ToPodcast added in v0.5.0

type ToPodcast struct {
	LLM                        string
	EstimateMaximumDuration    time.Duration
	TranscriptAdditionalPrompt string
	TTSLLM                     string
	Speakers                   []Speaker
	// contains filtered or unexported fields
}

type ToText

type ToText struct {
	Type ToTextType

	// LLM is the name of the LLM to use.
	// Only used when Type is ToTextTypePrompt.
	LLM string

	// Prompt is the prompt for LLM completion.
	// The source text will automatically be injected into the prompt.
	// Only used when Type is ToTextTypePrompt.
	Prompt string
	// contains filtered or unexported fields
}

type ToTextType added in v0.3.0

type ToTextType string
const (
	ToTextTypePrompt      ToTextType = "prompt"
	ToTextTypeCrawl       ToTextType = "crawl"
	ToTextTypeCrawlByJina ToTextType = "crawl_by_jina"
)

type Transform

type Transform struct {
	ToText    *ToText
	ToPodcast *ToPodcast
}

Jump to

Keyboard shortcuts

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