pub struct JsonModeEnforcer {
pub max_retries: usize,
}Expand description
Wraps generation to produce valid JSON output.
Strategy (applied in order):
- If the text already parses as JSON — return it as-is.
- Try to extract the first
{…}or[…]substring and parse that. - If still not valid JSON — wrap the text in
{"response": "<text>"}.
Fields§
§max_retries: usizeMaximum extraction/wrap attempts (unused here; reserved for future streaming use).
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsonModeEnforcer
impl RefUnwindSafe for JsonModeEnforcer
impl Send for JsonModeEnforcer
impl Sync for JsonModeEnforcer
impl Unpin for JsonModeEnforcer
impl UnsafeUnpin for JsonModeEnforcer
impl UnwindSafe for JsonModeEnforcer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more