Skip to main content

Policy

Struct Policy 

Source
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 nothing

Fields§

§field: String

Dotted 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

Source

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.

Source

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.

Source

pub fn has_dial(&self) -> bool

Whether this backend has any reasoning control at all.

Source

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.

Source

pub fn has_levels(&self) -> bool

Whether it has graded levels, as opposed to only off/on.

Source

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.

Source

pub fn default_effort(&self) -> Option<&str>

The effort in force when nothing was asked and nothing was configured.

Source

pub fn resolve(&self, requested: Option<&str>) -> Wire

Resolve a requested level into what this request carries.

Source

pub fn resolve_at( &self, requested: Option<&str>, base_url: Option<&str>, ) -> Wire

The same, with the endpoint in hand: Ollama ignores reasoning_effort on its native port and think = false 422s everywhere else, so which switch is the off switch is a property of where the request is going.

Source

pub fn describe(&self, requested: Option<&str>) -> String

A sentence for a report: what this ask becomes on this backend.

Trait Implementations§

Source§

impl Clone for Policy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Policy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Policy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Policy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Policy

Source§

impl PartialEq for Policy

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Policy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Policy

Auto Trait Implementations§

§

impl Forget for Policy

§

impl Freeze for Policy
where *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
where RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send,

§

impl Sync for Policy
where RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync,

§

impl Unpin for Policy
where *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin,

§

impl UnsafeUnpin for Policy

§

impl UnwindSafe for Policy

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more