pub enum ResponseFormat {
JsonObject,
JsonSchema(Value),
}Expand description
What the reply must look like — a validated OpenAI response_format. {"type":"text"}, like an
absent field, asks for nothing and never becomes a value.
Either kind is enforced by grammar: the reply CONTENT is one JSON value and nothing else, so a
generator runs it with the model’s reasoning off. json_schema.strict is accepted and changes
nothing: the schema’s keywords are enforced either way, and a keyword the grammar engine does
not implement is a 400 rather than dropped.
Also a 400, for the schema and for each tool’s parameters alike: a $ref that is not a
plain local pointer (# or #/…, no percent-encoding — #/$defs/… relative to a tool’s
own parameters works), and any $id, $anchor, $dynamicRef/$dynamicAnchor or
$recursiveRef/$recursiveAnchor; a schema nested too deep (counting references followed),
with too many references or JSON values, or too many distinct multipleOf steps; a step too
fine or too large for the engine to match quickly, or two steps anywhere in one schema whose
combination would be (checked pairwise whether or not they meet, so a few schemas are refused
that could have compiled); and an integer bound the engine’s arithmetic cannot hold.
The grammar is narrower than the schema in one respect, as llama.cpp’s is: a number the schema
leaves unbounded is limited in magnitude and in fraction digits (infr-llama’s NUMBER_LIMIT
and NUMBER_STEP, in its grammar module), and is not written in exponent form, so a model
cannot spin a digit string out to max_tokens. Where the schema’s own shape prevents that the
number stays as the schema bounds it: in subschemas the engine intersects (allOf,
applicators beside sibling keywords, a property matching a pattern property, definitions
referenced from such places), and without the fraction limit where the range is narrower than
its step or the schema’s own multipleOf cannot combine with it. Bounds, multipleOf,
const and enum the schema sets itself are kept. Strings, array lengths and nesting are not
bounded, as in llama.cpp.
Variants§
JsonObject
{"type":"json_object"}: one JSON object, of any shape.
JsonSchema(Value)
{"type":"json_schema","json_schema":{"schema":{..}}} — or llama.cpp’s
{"type":"json_object","schema":{..}} — one JSON value matching the schema. A
json_schema without a schema (or with a null one) is any JSON value, the empty schema
{}, as OpenAI and llama.cpp read it.
Implementations§
Trait Implementations§
Source§impl Clone for ResponseFormat
impl Clone for ResponseFormat
Source§impl Debug for ResponseFormat
impl Debug for ResponseFormat
Source§impl PartialEq for ResponseFormat
impl PartialEq for ResponseFormat
impl StructuralPartialEq for ResponseFormat
Auto Trait Implementations§
impl Forget for ResponseFormat
impl Freeze for ResponseFormatwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
impl Move for ResponseFormat
impl RefUnwindSafe for ResponseFormat
impl Send for ResponseFormat
impl Sync for ResponseFormat
impl Unpin for ResponseFormat
impl UnsafeUnpin for ResponseFormatwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
impl UnwindSafe for ResponseFormat
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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