pub struct LLMEntityExtractor { /* private fields */ }Expand description
LLM-based entity extractor that uses actual language model calls
Implementations§
Source§impl LLMEntityExtractor
impl LLMEntityExtractor
Sourcepub fn new(ollama_client: OllamaClient, entity_types: Vec<String>) -> Self
pub fn new(ollama_client: OllamaClient, entity_types: Vec<String>) -> Self
Create a new LLM-based entity extractor
§Arguments
ollama_client- Ollama client for LLM inferenceentity_types- List of entity types to extract (e.g., [“PERSON”, “LOCATION”, “ORGANIZATION”])
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Set temperature for LLM generation (default: 0.1)
Sourcepub fn with_max_tokens(self, max_tokens: usize) -> Self
pub fn with_max_tokens(self, max_tokens: usize) -> Self
Set maximum tokens for LLM generation (default: 1500)
Sourcepub async fn extract_from_chunk(
&self,
chunk: &TextChunk,
) -> Result<(Vec<Entity>, Vec<Relationship>)>
pub async fn extract_from_chunk( &self, chunk: &TextChunk, ) -> Result<(Vec<Entity>, Vec<Relationship>)>
Extract entities and relationships from a text chunk using LLM
This is the REAL extraction that makes actual LLM API calls. Expected time: 15-30 seconds per chunk depending on chunk size and model.
Sourcepub async fn extract_additional(
&self,
chunk: &TextChunk,
previous_entities: &[EntityData],
previous_relationships: &[RelationshipData],
) -> Result<(Vec<Entity>, Vec<Relationship>)>
pub async fn extract_additional( &self, chunk: &TextChunk, previous_entities: &[EntityData], previous_relationships: &[RelationshipData], ) -> Result<(Vec<Entity>, Vec<Relationship>)>
Extract additional entities in a gleaning round (continuation)
This is used after the initial extraction to catch missed entities.
Sourcepub async fn check_completion(
&self,
chunk: &TextChunk,
entities: &[EntityData],
relationships: &[RelationshipData],
) -> Result<bool>
pub async fn check_completion( &self, chunk: &TextChunk, entities: &[EntityData], relationships: &[RelationshipData], ) -> Result<bool>
Check if extraction is complete using LLM judgment
Uses the LLM to determine if all significant entities have been extracted.
Auto Trait Implementations§
impl Freeze for LLMEntityExtractor
impl !RefUnwindSafe for LLMEntityExtractor
impl Send for LLMEntityExtractor
impl Sync for LLMEntityExtractor
impl Unpin for LLMEntityExtractor
impl UnsafeUnpin for LLMEntityExtractor
impl !UnwindSafe for LLMEntityExtractor
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> 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