middleware

package
v1.1.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArenaStateStoreSaveMiddleware

func ArenaStateStoreSaveMiddleware(config *pipeline.StateStoreConfig) pipeline.Middleware

ArenaStateStoreSaveMiddleware saves conversation state with telemetry to ArenaStateStore. This middleware captures validation results, turn metrics, and cost information for Arena testing and analysis.

func HistoryInjectionMiddleware

func HistoryInjectionMiddleware(history []types.Message) pipeline.Middleware

HistoryInjectionMiddleware prepends conversation history to the message list. This is useful for self-play scenarios where history needs to be explicitly provided before the LLM generates the next user message.

The middleware preserves any existing messages in the ExecutionContext and prepends the provided history, maintaining chronological order.

func MockScenarioContextMiddleware added in v1.1.0

func MockScenarioContextMiddleware(scenario *config.Scenario) pipeline.Middleware

MockScenarioContextMiddleware creates middleware that adds scenario context to the execution context for MockProvider scenario-specific responses.

func PersonaAssemblyMiddleware

func PersonaAssemblyMiddleware(
	persona *config.UserPersonaPack,
	region string,
	baseVariables map[string]string,
) pipeline.Middleware

PersonaAssemblyMiddleware assembles persona prompts using the same fragment/template system as PromptAssemblyMiddleware. Populates execCtx.SystemPrompt with the persona's assembled prompt.

This middleware mirrors the behavior of PromptAssemblyMiddleware but for personas: - Uses persona's BuildSystemPrompt() which handles fragment assembly - Supports template variable substitution with {{variable}} syntax - Injects persona-specific variables (goals, constraints, style) - Sets base variables for downstream template middleware

func ScenarioContextExtractionMiddleware

func ScenarioContextExtractionMiddleware(scenario *config.Scenario) pipeline.Middleware

func SelfPlayUserTurnContextMiddleware added in v1.1.3

func SelfPlayUserTurnContextMiddleware(scenario *config.Scenario) pipeline.Middleware

SelfPlayUserTurnContextMiddleware creates middleware that adds scenario context with next-turn numbering to the execution context for MockProvider while also setting clear, role-specific metadata keys.

func TurnIndexMiddleware added in v1.1.3

func TurnIndexMiddleware() pipeline.Middleware

TurnIndexMiddleware computes role-specific turn counters from the authoritative conversation history loaded into execCtx.Messages (typically via StateStoreLoadMiddleware). It sets clear, role-specific metadata keys that other middleware can consume. - arena_user_completed_turns: number of completed user messages - arena_user_next_turn: completed user messages + 1 (next user turn to generate) - arena_assistant_completed_turns: number of completed assistant messages - arena_assistant_next_turn: completed assistant messages + 1

Types

This section is empty.

Jump to

Keyboard shortcuts

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