pub struct RenderContext {
pub task_type: Option<String>,
pub user_states: Vec<String>,
pub task_health: Option<TaskHealth>,
}Expand description
Runtime context for prompt rendering
Encapsulates the current state that determines which knowledge fragments should be included and how they should be prioritized.
§Examples
use llm_toolkit_expertise::render::RenderContext;
use llm_toolkit_expertise::context::TaskHealth;
let context = RenderContext::new()
.with_task_type("security-review")
.with_user_state("beginner")
.with_task_health(TaskHealth::AtRisk);Fields§
§task_type: Option<String>Current task type (e.g., “security-review”, “code-review”, “debug”)
user_states: Vec<String>User states (e.g., “beginner”, “expert”, “confused”)
task_health: Option<TaskHealth>Current task health status
Implementations§
Source§impl RenderContext
impl RenderContext
Sourcepub fn with_task_type(self, task_type: impl Into<String>) -> Self
pub fn with_task_type(self, task_type: impl Into<String>) -> Self
Set the task type
§Examples
use llm_toolkit_expertise::render::RenderContext;
let context = RenderContext::new()
.with_task_type("security-review");Sourcepub fn with_user_state(self, state: impl Into<String>) -> Self
pub fn with_user_state(self, state: impl Into<String>) -> Self
Add a user state
§Examples
use llm_toolkit_expertise::render::RenderContext;
let context = RenderContext::new()
.with_user_state("beginner")
.with_user_state("confused");Sourcepub fn with_task_health(self, health: TaskHealth) -> Self
pub fn with_task_health(self, health: TaskHealth) -> Self
Set the task health
§Examples
use llm_toolkit_expertise::render::RenderContext;
use llm_toolkit_expertise::context::TaskHealth;
let context = RenderContext::new()
.with_task_health(TaskHealth::AtRisk);Sourcepub fn matches(&self, profile: &ContextProfile) -> bool
pub fn matches(&self, profile: &ContextProfile) -> bool
Check if this context matches a ContextProfile
A context matches a profile if:
- Profile is
Always→ always matches - Profile is
Conditional:- If
task_typesis non-empty, current task_type must be in the list - If
user_statesis non-empty, at least one user_state must match - If
task_healthis set, current health must match
- If
§Examples
use llm_toolkit_expertise::render::RenderContext;
use llm_toolkit_expertise::context::{ContextProfile, TaskHealth};
let context = RenderContext::new()
.with_task_type("security-review")
.with_task_health(TaskHealth::AtRisk);
let profile = ContextProfile::Conditional {
task_types: vec!["security-review".to_string()],
user_states: vec![],
task_health: Some(TaskHealth::AtRisk),
};
assert!(context.matches(&profile));Sourcepub fn to_context_matcher(&self) -> ContextMatcher
pub fn to_context_matcher(&self) -> ContextMatcher
Convert to legacy ContextMatcher for backward compatibility
Note: ContextMatcher only supports a single user_state, so the first user_state from the Vec will be used.
Trait Implementations§
Source§impl Clone for RenderContext
impl Clone for RenderContext
Source§fn clone(&self) -> RenderContext
fn clone(&self) -> RenderContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RenderContext
impl Debug for RenderContext
Source§impl Default for RenderContext
impl Default for RenderContext
Source§fn default() -> RenderContext
fn default() -> RenderContext
Returns the “default value” for a type. Read more
Source§impl From<ContextMatcher> for RenderContext
Convert from legacy ContextMatcher
impl From<ContextMatcher> for RenderContext
Convert from legacy ContextMatcher
Source§fn from(matcher: ContextMatcher) -> Self
fn from(matcher: ContextMatcher) -> Self
Converts to this type from the input type.
Source§impl PartialEq for RenderContext
impl PartialEq for RenderContext
impl StructuralPartialEq for RenderContext
Auto Trait Implementations§
impl Freeze for RenderContext
impl RefUnwindSafe for RenderContext
impl Send for RenderContext
impl Sync for RenderContext
impl Unpin for RenderContext
impl UnwindSafe for RenderContext
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