MCPcopy Create free account
hub / github.com/Emmimal/control-layer / ResponseSchema

Class ResponseSchema

control_layer.py:127–148  ·  view source on GitHub ↗

Output contract the LLM response must satisfy.

Source from the content-addressed store, hash-verified

125
126
127class ResponseSchema(BaseModel):
128 """Output contract the LLM response must satisfy."""
129 required_keys: List[str] = Field(default_factory=list)
130 max_length: Optional[int] = None
131 min_length: Optional[int] = None
132 forbidden_phrases: List[str] = Field(default_factory=list)
133 must_contain: List[str] = Field(default_factory=list)
134 must_be_json: bool = False
135
136 @field_validator("max_length")
137 @classmethod
138 def max_positive(cls, v):
139 if v is not None and v <= 0:
140 raise ValueError("max_length must be positive")
141 return v
142
143 @model_validator(mode="after")
144 def min_lt_max(self):
145 if self.min_length and self.max_length:
146 if self.min_length >= self.max_length:
147 raise ValueError("min_length must be < max_length")
148 return self
149
150
151# =============================================================================

Callers 15

demo_4_fallback_routerFunction · 0.90
demo_5_benchmarkFunction · 0.90
simple_layerFunction · 0.90

Calls

no outgoing calls