pub struct LlmStrategy { /* private fields */ }Expand description
LLM-based retrieval strategy.
Uses an LLM to reason about which nodes are most relevant to the query. Includes ToC context for better navigation decisions.
§Example
use vectorless::retrieval::strategy::LlmStrategy;
use vectorless::llm::LlmClient;
let client = LlmClient::with_defaults();
let strategy = LlmStrategy::new(client)
.with_toc_context(true);Implementations§
Source§impl LlmStrategy
impl LlmStrategy
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default LLM client.
Sourcepub fn with_system_prompt(self, prompt: String) -> Self
pub fn with_system_prompt(self, prompt: String) -> Self
Set custom system prompt.
Sourcepub fn with_toc_context(self, include: bool) -> Self
pub fn with_toc_context(self, include: bool) -> Self
Enable or disable ToC context in prompts.
Trait Implementations§
Source§impl Clone for LlmStrategy
impl Clone for LlmStrategy
Source§fn clone(&self) -> LlmStrategy
fn clone(&self) -> LlmStrategy
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 RetrievalStrategy for LlmStrategy
impl RetrievalStrategy for LlmStrategy
Source§fn evaluate_node<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tree: &'life1 DocumentTree,
node_id: NodeId,
context: &'life2 RetrievalContext,
) -> Pin<Box<dyn Future<Output = NodeEvaluation> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn evaluate_node<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tree: &'life1 DocumentTree,
node_id: NodeId,
context: &'life2 RetrievalContext,
) -> Pin<Box<dyn Future<Output = NodeEvaluation> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Evaluate a single node’s relevance to the query. Read more
Source§fn evaluate_nodes<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 DocumentTree,
node_ids: &'life2 [NodeId],
context: &'life3 RetrievalContext,
) -> Pin<Box<dyn Future<Output = Vec<NodeEvaluation>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn evaluate_nodes<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 DocumentTree,
node_ids: &'life2 [NodeId],
context: &'life3 RetrievalContext,
) -> Pin<Box<dyn Future<Output = Vec<NodeEvaluation>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Evaluate multiple nodes in batch. Read more
Source§fn capabilities(&self) -> StrategyCapabilities
fn capabilities(&self) -> StrategyCapabilities
Get the capabilities of this strategy.
Source§fn suitable_for_complexity(&self, complexity: QueryComplexity) -> bool
fn suitable_for_complexity(&self, complexity: QueryComplexity) -> bool
Check if this strategy is suitable for the given query complexity.
Source§fn estimate_cost(&self, node_count: usize) -> StrategyCost
fn estimate_cost(&self, node_count: usize) -> StrategyCost
Estimate the cost of evaluating a set of nodes.
Auto Trait Implementations§
impl Freeze for LlmStrategy
impl !RefUnwindSafe for LlmStrategy
impl Send for LlmStrategy
impl Sync for LlmStrategy
impl Unpin for LlmStrategy
impl UnsafeUnpin for LlmStrategy
impl !UnwindSafe for LlmStrategy
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> 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 more