pub struct EntityExtractor<P: LLMProvider> { /* private fields */ }Expand description
Entity extractor using LLM.
TigerStyle: Generic over provider for sim/production flexibility.
§Example
use umi_memory::extraction::{EntityExtractor, ExtractionOptions};
use umi_memory::llm::SimLLMProvider;
#[tokio::main]
async fn main() {
// Simulation provider for testing
let provider = SimLLMProvider::with_seed(42);
let extractor = EntityExtractor::new(provider);
let result = extractor
.extract("Alice works at Acme Corp", ExtractionOptions::default())
.await
.unwrap();
// Result contains entities and relations
assert!(!result.is_empty());
}Implementations§
Source§impl<P: LLMProvider> EntityExtractor<P>
impl<P: LLMProvider> EntityExtractor<P>
Sourcepub async fn extract(
&self,
text: &str,
options: ExtractionOptions,
) -> Result<ExtractionResult, ExtractionError>
pub async fn extract( &self, text: &str, options: ExtractionOptions, ) -> Result<ExtractionResult, ExtractionError>
Extract entities and relations from text.
§Arguments
text- Text to extract fromoptions- Extraction options (existing entities, min confidence)
§Returns
ExtractionResult with entities, relations, and raw text.
§Errors
Returns ExtractionError if text is empty or too long.
§Graceful Degradation
If the LLM fails or returns invalid JSON, a fallback “note” entity is created from the input text. This ensures extraction never fails due to LLM issues.
Sourcepub async fn extract_entities_only(
&self,
text: &str,
) -> Result<Vec<ExtractedEntity>, ExtractionError>
pub async fn extract_entities_only( &self, text: &str, ) -> Result<Vec<ExtractedEntity>, ExtractionError>
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for EntityExtractor<P>where
P: Freeze,
impl<P> RefUnwindSafe for EntityExtractor<P>where
P: RefUnwindSafe,
impl<P> Send for EntityExtractor<P>
impl<P> Sync for EntityExtractor<P>
impl<P> Unpin for EntityExtractor<P>where
P: Unpin,
impl<P> UnwindSafe for EntityExtractor<P>where
P: UnwindSafe,
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