pub struct Policy {
pub field: String,
pub kind: Kind,
pub off: Option<OffSwitch>,
pub ollama_off: Option<OffSwitch>,
pub levels: Vec<String>,
pub map: BTreeMap<String, String>,
pub default: Option<String>,
}Expand description
One backend’s reasoning policy, as a manifest declares it.
[provider_profile.reasoning]
field = "reasoning_effort" # dotted path on the request body
kind = "level" # "level" (default) or "bool"
off = "none" # level kind: what turns it off
levels = ["low", "medium", "high"]
map = { minimal = "low", xhigh = "high" }
default = "medium" # when nothing was set; absent = send nothingFields§
§field: StringDotted path into the request body: reasoning_effort, or
chat_template_kwargs.enable_thinking.
kind: Kind§off: Option<OffSwitch>What disables reasoning on this backend: a level ("none"), a bool for a bool field, or a
body fragment when the switch lives somewhere else entirely
(chat_template_kwargs = { enable_thinking = false }). None = cannot be switched off.
ollama_off: Option<OffSwitch>The off switch to use instead of off when the base URL is Ollama itself, because Ollama
ignores reasoning_effort on its native port and think = false 422s anywhere else.
levels: Vec<String>The graded levels this wire accepts, weakest first. Empty = it has no graded dial (on/off only, or nothing at all).
map: BTreeMap<String, String>Declared vendor mappings, consulted before the ladder: minimal = "low", xhigh = "high".
default: Option<String>What to send when the user set nothing. Absent = send nothing and let the server default apply — which is the honest default, because an endpoint’s own default is not ours to guess.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn openai() -> Self
pub fn openai() -> Self
The real OpenAI API’s graded vocabulary. No off switch: reasoning_effort: "none" is not
something that endpoint accepts, and inventing it would be a 400.
default = medium is what a fresh install reasons at (#276): a route nobody configured
still gets a level this wire is known to take, and a route that declares no policy at all
still gets no field. SHIPPED_DEFAULT is the same answer the starter file writes live, and
the test below is what keeps the two from drifting apart.
Sourcepub fn llamacpp() -> Self
pub fn llamacpp() -> Self
What a llama.cpp server was measured to take on this fleet: a graded dial on some models,
none as the off switch everywhere, minimal silently meaning “no thinking”, and nothing
above high. A model that ignores the graded levels overrides this in a manifest.
default = medium for the reason openai declares it; a per-model entry that declares no
default (the off-only gemma shape) sends nothing, which is what a graded level would be
there: a level the server ignores, reported as if it had worked.
Sourcepub fn has_off(&self) -> bool
pub fn has_off(&self) -> bool
Whether this route can turn thinking off at all (#293). The switch in the dashboard’s
submenu is one of these: a route without an off draws it disabled, because the alternative
is a control that presses and changes nothing.
Sourcepub fn has_levels(&self) -> bool
pub fn has_levels(&self) -> bool
Whether it has graded levels, as opposed to only off/on.
Sourcepub fn vocabulary(&self) -> Vec<String>
pub fn vocabulary(&self) -> Vec<String>
The words this wire takes, as a menu should offer them (#275): the graded levels it
declared, plus its off switch when it has one.
The point of serving this instead of a union spelled in a front end is that a row offered
is a row that works. openai has no off switch — reasoning_effort: "none" is a 400
there — while llamacpp has none and only three rungs, and an off-only model can do
nothing but turn thinking off. Empty for a policy with no dial at all, which the menu says
in words instead of listing six dead ones.
Sourcepub fn default_effort(&self) -> Option<&str>
pub fn default_effort(&self) -> Option<&str>
The effort in force when nothing was asked and nothing was configured.
Sourcepub fn resolve(&self, requested: Option<&str>) -> Wire
pub fn resolve(&self, requested: Option<&str>) -> Wire
Resolve a requested level into what this request carries.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Policy
impl<'de> Deserialize<'de> for Policy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Policy
impl StructuralPartialEq for Policy
Auto Trait Implementations§
impl Forget for Policy
impl Freeze for Policywhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Value>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
PhantomData<String>: Freeze,
*const LeafNode<String, String> is !null: Freeze,
PhantomData<Box<(String, String)>>: Freeze,
impl Move for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policywhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const LeafNode<String, String> is !null: UnsafeUnpin,
PhantomData<Box<(String, String)>>: UnsafeUnpin,
impl UnwindSafe for Policywhere
RawVecInner: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BTreeMap<String, String>: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.