InputSanitizationMiddleware

org.llm4s.llmconnect.middleware.InputSanitizationMiddleware
class InputSanitizationMiddleware(maxTotalCharacters: Int, forbiddenPatterns: Seq[Regex]) extends LLMMiddleware

Middleware that sanitizes and validates input prompts.

Can enforce max length limits and reject inputs containing forbidden patterns.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def name: String

Human-readable name for logging/debugging.

Human-readable name for logging/debugging.

Attributes

Definition Classes
override def wrap(client: LLMClient): LLMClient

Wrap the given LLMClient, returning a new client with added behavior.

Wrap the given LLMClient, returning a new client with added behavior.

Implementations should delegate all LLMClient methods to next, adding behavior before/after delegation as needed.

Value parameters

next

the next client in the pipeline

Attributes

Returns

a new LLMClient with this middleware's behavior added

Definition Classes