pub struct ClassifierContext {
pub messages: Vec<Message>,
pub agent_name: String,
pub session_id: String,
pub allow_rules: Vec<String>,
pub soft_deny_rules: Vec<String>,
pub workspace_path: Option<String>,
pub project_type: Option<String>,
pub recent_files: Vec<String>,
pub risk_context: Option<RiskContext>,
}Available on crate feature
human-loop only.Expand description
分类器上下文 - 包含分类所需的所有信息
Fields§
§messages: Vec<Message>对话历史
agent_name: StringAgent 名称
session_id: String会话 ID
allow_rules: Vec<String>当前 allow 规则描述
soft_deny_rules: Vec<String>当前 soft_deny 规则描述
workspace_path: Option<String>工作区路径(可选)
project_type: Option<String>项目类型(可选): “rust” | “python” | “node” | “go” 等
recent_files: Vec<String>最近访问的文件列表
risk_context: Option<RiskContext>风险上下文
Implementations§
Source§impl ClassifierContext
impl ClassifierContext
Sourcepub fn new(agent_name: String, session_id: String) -> ClassifierContext
pub fn new(agent_name: String, session_id: String) -> ClassifierContext
创建空上下文
Sourcepub fn with_messages(self, messages: Vec<Message>) -> ClassifierContext
pub fn with_messages(self, messages: Vec<Message>) -> ClassifierContext
添加消息历史
Sourcepub fn with_allow_rules(self, rules: Vec<String>) -> ClassifierContext
pub fn with_allow_rules(self, rules: Vec<String>) -> ClassifierContext
设置 allow 规则
Sourcepub fn with_soft_deny_rules(self, rules: Vec<String>) -> ClassifierContext
pub fn with_soft_deny_rules(self, rules: Vec<String>) -> ClassifierContext
设置 soft_deny 规则
Sourcepub fn with_workspace_path(self, path: String) -> ClassifierContext
pub fn with_workspace_path(self, path: String) -> ClassifierContext
设置工作区路径
Sourcepub fn with_project_type(self, ptype: String) -> ClassifierContext
pub fn with_project_type(self, ptype: String) -> ClassifierContext
设置项目类型
Sourcepub fn with_recent_files(self, files: Vec<String>) -> ClassifierContext
pub fn with_recent_files(self, files: Vec<String>) -> ClassifierContext
设置最近访问的文件列表
Sourcepub fn with_risk_context(self, ctx: RiskContext) -> ClassifierContext
pub fn with_risk_context(self, ctx: RiskContext) -> ClassifierContext
设置风险上下文
Trait Implementations§
Source§impl Clone for ClassifierContext
impl Clone for ClassifierContext
Source§fn clone(&self) -> ClassifierContext
fn clone(&self) -> ClassifierContext
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 ClassifierContext
impl RefUnwindSafe for ClassifierContext
impl Send for ClassifierContext
impl Sync for ClassifierContext
impl Unpin for ClassifierContext
impl UnsafeUnpin for ClassifierContext
impl UnwindSafe for ClassifierContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request