pub struct GuardrailEngine { /* private fields */ }Expand description
双方向インラインガードレールエンジン。
Implementations§
Source§impl GuardrailEngine
impl GuardrailEngine
Sourcepub fn new(
fast_fail_config: FastFailConfig,
window_config: WindowConfig,
multitask_config: MultiTaskScannerConfig,
hallucination_config: HallucinationVerifierConfig,
streaming_config: StreamingVerifierConfig,
) -> Self
pub fn new( fast_fail_config: FastFailConfig, window_config: WindowConfig, multitask_config: MultiTaskScannerConfig, hallucination_config: HallucinationVerifierConfig, streaming_config: StreamingVerifierConfig, ) -> Self
新規 GuardrailEngine を構築する。
Sourcepub fn default_engine() -> Self
pub fn default_engine() -> Self
デフォルト設定でエンジンを生成する。
Sourcepub fn pre_scan_text(&self, text: &str) -> Result<(), GuardrailViolation>
pub fn pre_scan_text(&self, text: &str) -> Result<(), GuardrailViolation>
入力テキストに対する階層型 Fast-Fail 判定を実行する。
- Tier 0: Aho-Corasick DFA による決定論的走査 (<0.1ms)。
- Tier 1: 512 トークン超長文に対する縮約窓切り出しと境界スキャン。
Sourcepub fn evaluate_multitask(
&self,
inj_logit: f64,
tox_logit: f64,
pii_logit: f64,
) -> MultiTaskScanResult
pub fn evaluate_multitask( &self, inj_logit: f64, tox_logit: f64, pii_logit: f64, ) -> MultiTaskScanResult
マルチタスク動的マーカーロジットから脅威判定および自由エネルギーを評価する。
Sourcepub fn verify_outbound(
&self,
context: &str,
claim: &str,
mock_logits: Option<[f64; 3]>,
) -> HallucinationVerificationResult
pub fn verify_outbound( &self, context: &str, claim: &str, mock_logits: Option<[f64; 3]>, ) -> HallucinationVerificationResult
事後ハルシネーション検証を実行する。
Sourcepub fn create_stream_interceptor(
&self,
context: String,
) -> SpeculativeStreamInterceptor
pub fn create_stream_interceptor( &self, context: String, ) -> SpeculativeStreamInterceptor
投機的ストリーム検証インターセプターを取得する。
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
ガードレール全体の有効化フラグを取得する。
Sourcepub fn fast_fail(&self) -> &FastFailScanner
pub fn fast_fail(&self) -> &FastFailScanner
Fast-Fail スキャナーへの参照を取得する。
Sourcepub fn window_config(&self) -> &WindowConfig
pub fn window_config(&self) -> &WindowConfig
縮約窓設定への参照を取得する。
Sourcepub fn multitask_config(&self) -> &MultiTaskScannerConfig
pub fn multitask_config(&self) -> &MultiTaskScannerConfig
マルチタスクスキャナー設定への参照を取得する。
Sourcepub fn hallucination_config(&self) -> &HallucinationVerifierConfig
pub fn hallucination_config(&self) -> &HallucinationVerifierConfig
ハルシネーション検証設定への参照を取得する。
Sourcepub fn streaming_config(&self) -> &StreamingVerifierConfig
pub fn streaming_config(&self) -> &StreamingVerifierConfig
ストリーミング検証設定への参照を取得する。
Sourcepub fn max_body_bytes(&self) -> usize
pub fn max_body_bytes(&self) -> usize
最大許容リクエストボディバイト数を取得する。
Sourcepub fn with_max_body_bytes(self, max: usize) -> Self
pub fn with_max_body_bytes(self, max: usize) -> Self
最大許容リクエストボディバイト数をカスタマイズ設定する。
Trait Implementations§
Source§impl Clone for GuardrailEngine
impl Clone for GuardrailEngine
Source§fn clone(&self) -> GuardrailEngine
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GuardrailEngine
impl RefUnwindSafe for GuardrailEngine
impl Send for GuardrailEngine
impl Sync for GuardrailEngine
impl Unpin for GuardrailEngine
impl UnsafeUnpin for GuardrailEngine
impl UnwindSafe for GuardrailEngine
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
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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