Skip to main content

GuardrailEngine

Struct GuardrailEngine 

Source
pub struct GuardrailEngine { /* private fields */ }
Expand description

双方向インラインガードレールエンジン。

Implementations§

Source§

impl GuardrailEngine

Source

pub fn new( fast_fail_config: FastFailConfig, window_config: WindowConfig, multitask_config: MultiTaskScannerConfig, hallucination_config: HallucinationVerifierConfig, streaming_config: StreamingVerifierConfig, ) -> Self

新規 GuardrailEngine を構築する。

Source

pub fn default_engine() -> Self

デフォルト設定でエンジンを生成する。

Source

pub fn pre_scan_text(&self, text: &str) -> Result<(), GuardrailViolation>

入力テキストに対する階層型 Fast-Fail 判定を実行する。

  1. Tier 0: Aho-Corasick DFA による決定論的走査 (<0.1ms)。
  2. Tier 1: 512 トークン超長文に対する縮約窓切り出しと境界スキャン。
Source

pub fn evaluate_multitask( &self, inj_logit: f64, tox_logit: f64, pii_logit: f64, ) -> MultiTaskScanResult

マルチタスク動的マーカーロジットから脅威判定および自由エネルギーを評価する。

Source

pub fn verify_outbound( &self, context: &str, claim: &str, mock_logits: Option<[f64; 3]>, ) -> HallucinationVerificationResult

事後ハルシネーション検証を実行する。

Source

pub fn create_stream_interceptor( &self, context: String, ) -> SpeculativeStreamInterceptor

投機的ストリーム検証インターセプターを取得する。

Source

pub fn is_enabled(&self) -> bool

ガードレール全体の有効化フラグを取得する。

Source

pub fn fast_fail(&self) -> &FastFailScanner

Fast-Fail スキャナーへの参照を取得する。

Source

pub fn window_config(&self) -> &WindowConfig

縮約窓設定への参照を取得する。

Source

pub fn multitask_config(&self) -> &MultiTaskScannerConfig

マルチタスクスキャナー設定への参照を取得する。

Source

pub fn hallucination_config(&self) -> &HallucinationVerifierConfig

ハルシネーション検証設定への参照を取得する。

Source

pub fn streaming_config(&self) -> &StreamingVerifierConfig

ストリーミング検証設定への参照を取得する。

Source

pub fn max_body_bytes(&self) -> usize

最大許容リクエストボディバイト数を取得する。

Source

pub fn with_max_body_bytes(self, max: usize) -> Self

最大許容リクエストボディバイト数をカスタマイズ設定する。

Trait Implementations§

Source§

impl Clone for GuardrailEngine

Source§

fn clone(&self) -> GuardrailEngine

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 Default for GuardrailEngine

Source§

fn default() -> Self

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

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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

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