Skip to main content

Module extract

Module extract 

Source
Expand description

Optional text → facts + entities extraction, the layer that makes the graph self-build.

The Agent Memory SDK is bring-your-own-links: crate::MemoryService::remember only stores the links the caller supplies, so a graph is only ever as rich as what the caller wires by hand. This module adds the missing commodity on top: an Extractor turns a paragraph of raw text into atomic facts, each tagged with the salient topics it mentions. crate::MemoryService::remember_extracted then stores those facts and wires the fact↔entity graph automatically, so why() has something to traverse without any manual relate().

Mirroring the crate::embedder pattern, the plug-point is dependency-free (bring your own LLM by implementing Extractor) while a batteries-included OllamaExtractor backend lives behind the extractor-http feature.

Structs§

ExtractedAttribute
One extracted entity attribute: entity.key = value.
ExtractedFact
One extracted, graph-ready fact: a self-contained sentence plus the salient topics it concerns. The topics become shared graph hubs, so two facts about the same topic are reachable from one another even with no textual overlap.
ExtractedRelation
One extracted entity→entity edge: subject -[predicate]-> object.
Extraction
Everything one passage yields: the atomic facts, the entity→entity edges between the topics they mention, and the attributes those entities carry.
OllamaExtractor
Extracts facts through a local Ollama /api/generate endpoint, keeping the model — and therefore the source text — on the user’s own machine.
OpenAiExtractor
Extracts through any OpenAI-compatible /v1/chat/completions endpoint.
OutlineExtractor
Deterministic, network-free extractor: it reads the structure a passage STATES instead of inferring it.

Enums§

ExtractError
Failure produced by an Extractor backend (e.g. a network-backed model that cannot be reached, or output that cannot be parsed into facts).
ExtractorSelection
What a caller must do to honour a requested extraction backend.

Constants§

DEFAULT_OLLAMA_URL
Default Ollama base URL for the generative extraction endpoint.

Traits§

Extractor
Turns a passage of raw text into atomic, graph-ready facts.

Functions§

select_extractor
Resolve an extraction backend name to what the caller must do about it.

Type Aliases§

DynExtractor
A shared, object-safe extractor. The MCP server and the language bindings hold one of these (an Option), so the extraction tool can be attached at runtime without the type being generic.