Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix: audit and correct all remaining API mismatches in docs

KaifAhmad1daa79ccef3c5
diff --git a/docs/concepts.md b/docs/concepts.md
index 08754bad..b21a0688 100644
--- a/docs/concepts.md
+++ b/docs/concepts.md
@@ -148,18 +148,27 @@ Inferred: Steve Jobs has a connection to Cupertino
Applies IF/THEN rules repeatedly until no new facts can be derived. Best for alert systems, compliance checks, and trigger-based workflows.
```python
- from semantica.reasoning import ReasoningEngine
-
- engine = ReasoningEngine(llm_provider=llm)
- result = engine.reason(facts=kg, rules=rule_set, method="forward_chaining")
+ from semantica.reasoning import Reasoner, Rule, Fact, RuleType
+
+ engine = Reasoner()
+ engine.add_fact(Fact(subject="Alice", predicate="is_a", obj="Manager"))
+ engine.add_rule(Rule(
+ rule_type=RuleType.FORWARD_CHAIN,
+ conditions=[{"subject": "?x", "predicate": "is_a", "object": "Manager"}],
+ conclusion={"subject": "?x", "predicate": "has_authority", "object": "true"}
+ ))
+ result = engine.infer()
```
</Tab>
<Tab title="Rete Network">
Efficient pattern matching for large rule sets — the Rete algorithm avoids re-evaluating rules whose preconditions haven't changed. Best for thousands of rules over millions of facts.
```python
- engine = ReasoningEngine(llm_provider=llm)
- result = engine.reason(facts=kg, rules=rule_set, method="rete")
+ from semantica.reasoning import ReteEngine
+
+ engine = ReteEngine()
+ engine.load_rules("rules/domain_rules.json")
+ results = engine.run(kg)
```
</Tab>
<Tab title="Deductive & Abductive">
@@ -168,18 +177,24 @@ Inferred: Steve Jobs has a connection to Cupertino
**Abductive** — infers the most likely explanation for observed evidence. Best for diagnostic and investigative use cases.
```python
- result = engine.reason(facts=kg, rules=rule_set, method="deductive")
- result = engine.reason(facts=kg, rules=rule_set, method="abductive")
+ from semantica.reasoning import GraphReasoner
+
+ graph_reasoner = GraphReasoner(kg)
+ graph_reasoner.add_rule({"if": [{"subject": "?a", "predicate": "parent_of", "object": "?b"}], "then": {"subject": "?a", "predicate": "ancestor_of", "object": "?b"}})
+ inferences = graph_reasoner.infer(kg)
```
</Tab>
<Tab title="Datalog (v0.4.0)">
Recursive Horn clause rules with fixpoint semantics — handles transitive closure and recursive relationships that forward chaining cannot express.
```python
- from semantica.reasoning import DatalogReasoner
+ from semantica.reasoning import DatalogReasoner, DatalogFact, DatalogRule
reasoner = DatalogReasoner()
- result = reasoner.reason(facts=kg, rules=datalog_rules)
+ reasoner.add_fact(DatalogFact("parent", ("alice", "bob")))
+ reasoner.add_rule(DatalogRule("ancestor(?X, ?Y) :- parent(?X, ?Y)."))
+ reasoner.evaluate()
+ results = reasoner.query("ancestor(alice, ?Z)")
```
</Tab>
<Tab title="Engine Comparison">
@@ -203,14 +218,13 @@ All engines produce **explainable inference paths** — not black-box conclusion
Knowledge changes over time. Temporal graphs attach `valid_from` / `valid_until` windows to nodes and edges, enabling point-in-time queries and historical analysis.
```python
-from semantica.kg import TemporalKnowledgeGraph
+from semantica.kg import TemporalGraphQuery
from datetime import datetime
-tkg = TemporalKnowledgeGraph()
-tkg.add_node("ceo_role", valid_from=datetime(2020, 1, 1), valid_until=datetime(2023, 6, 1))
+query_engine = TemporalGraphQuery(enable_temporal_reasoning=True)
# Query the graph as it existed on a specific date
-snapshot = tkg.at(datetime(2021, 6, 15))
+snapshot = query_engine.query_at_time(kg, query="", at_time=datetime(2021, 6, 15))
```
**Supported features:** Allen interval algebra (all 13 temporal relations), OWL-Time export, `recorded_at` stamping, temporal provenance.
@@ -222,11 +236,10 @@ snapshot = tkg.at(datetime(2021, 6, 15))
Explore the semantic neighborhood of any entity in your graph — useful for understanding what's conceptually close, detecting clusters, and visualizing knowledge topology.
```python
-from semantica.kg import DistanceCalculator
+from semantica.kg import SimilarityCalculator
-calc = DistanceCalculator(graph)
-neighborhood = calc.semantic_neighborhood("Apple Inc.", radius=0.4)
-matrix = calc.distance_matrix(["Apple Inc.", "Google", "Microsoft"])
+calc = SimilarityCalculator()
+scores = calc.calculate_similarity(entity_a, entity_b)
```
**Features:** N×N semantic distance matrices, ego-mode visualization, distance band classification (`near` / `mid` / `far`), embedding cache optimization for large graphs.
@@ -250,15 +263,13 @@ Real-world data contains the same entity under many names — "Apple", "Apple In
</Tab>
<Tab title="Configuration">
```python
- from semantica.deduplication import EntityDeduplicator
+ from semantica.deduplication import DuplicateDetector, EntityMerger
- deduplicator = EntityDeduplicator(
- strategy="semantic_v2",
- threshold=0.85, # similarity threshold for merge decision
- embedding_model="all-mpnet-base-v2",
- )
+ detector = DuplicateDetector(similarity_threshold=0.85)
+ duplicates = detector.detect_duplicates(entities)
- deduplicated_entities = deduplicator.deduplicate(entities)
+ merger = EntityMerger()
+ deduplicated_entities = merger.merge_duplicates(entities)
```
</Tab>
</Tabs>
diff --git a/docs/index.md b/docs/index.md
index 027ba7f3..ce3eb122 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -99,13 +99,14 @@ influence = context.analyze_decision_influence(decision_id)
```python Anthropic
from semantica.context import AgentContext, ContextGraph
from semantica.vector_store import VectorStore
-from semantica.llms import Anthropic
+from semantica.llms import LiteLLM
+import os
context = AgentContext(
vector_store=VectorStore(backend="faiss", dimension=1024),
knowledge_graph=ContextGraph(advanced_analytics=True),
decision_tracking=True,
- llm=Anthropic(model="claude-opus-4-7"),
+ llm=LiteLLM(model="anthropic/claude-opus-4-7", api_key=os.getenv("ANTHROPIC_API_KEY")),
)
context.store("Claude excels at long-context reasoning and code generation")
@@ -124,13 +125,13 @@ precedents = context.find_precedents("document analysis model", limit=5)
```python Ollama (Local)
from semantica.context import AgentContext, ContextGraph
from semantica.vector_store import VectorStore
-from semantica.llms import Ollama
+from semantica.llms import LiteLLM
context = AgentContext(
vector_store=VectorStore(backend="faiss", dimension=768),
knowledge_graph=ContextGraph(advanced_analytics=True),
decision_tracking=True,
- llm=Ollama(model="llama3.2", base_url="http://localhost:11434"),
+ llm=LiteLLM(model="ollama/llama3.2", base_url="http://localhost:11434"),
)
# Fully local — no data leaves your infrastructure
diff --git a/docs/modules.md b/docs/modules.md
index 7ec65dc7..6454623f 100644
--- a/docs/modules.md
+++ b/docs/modules.md
@@ -134,21 +134,20 @@ triplets = trip.extract(text)
Graph construction, graph algorithms, temporal model, and distance intelligence.
```python
-from semantica.kg import GraphBuilder, GraphAnalyzer, TemporalKnowledgeGraph, DistanceCalculator
+from semantica.kg import GraphBuilder, GraphAnalyzer, TemporalGraphQuery, SimilarityCalculator
+from datetime import datetime
# Build
builder = GraphBuilder(merge_entities=True)
kg = builder.build(entities=entities, relationships=relationships)
# Temporal graphs (v0.4.0)
-tkg = TemporalKnowledgeGraph()
-tkg.add_node("ceo_role", valid_from=datetime(2020, 1, 1), valid_until=datetime(2023, 6, 1))
-snapshot = tkg.at(datetime(2021, 6, 15))
-
-# Distance Intelligence (v0.5.0)
-calc = DistanceCalculator(kg)
-neighborhood = calc.semantic_neighborhood("Apple Inc.", radius=0.4)
-matrix = calc.distance_matrix(["Apple Inc.", "Google", "Microsoft"])
+query_engine = TemporalGraphQuery(enable_temporal_reasoning=True)
+snapshot = query_engine.query_at_time(kg, query="", at_time=datetime(2021, 6, 15))
+
+# Semantic similarity (v0.5.0)
+calc = SimilarityCalculator()
+scores = calc.calculate_similarity(entity_a, entity_b)
```
**Graph algorithms available:** centrality calculation, community detection, connectivity analysis, entity resolution, link prediction, path finding, similarity calculation
@@ -158,29 +157,29 @@ matrix = calc.distance_matrix(["Apple Inc.", "Google", "Microsoft"])
Schema management including SHACL, SKOS, alignments, diff/migration, auto-generation, and the visual Ontology Hub (v0.5.0).
```python
-from semantica.ontology import OntologyManager, SHACLGenerator
+from semantica.ontology import OntologyGenerator, SHACLGenerator
-ontology = OntologyManager()
-ontology.add_class("Person", ["name", "birth_date"])
-ontology.add_relationship("works_for", "Person", "Organization")
-is_valid = ontology.validate_graph(kg)
+generator = OntologyGenerator()
+ontology = generator.generate_from_graph(kg)
shacl = SHACLGenerator()
shapes = shacl.generate(ontology)
```
-**Components:** `OntologyManager`, `SHACLGenerator`, `OntologyGenerator`, `OntologyValidator`, `OntologyEvaluator`, `LLMGenerator`, `OWLGenerator`, `PropertyGenerator`, `DomainOntologies`, `NamespaceManager`
+**Components:** `OntologyGenerator`, `SHACLGenerator`, `OntologyValidator`, `OntologyEvaluator`, `LLMOntologyGenerator`, `OWLGenerator`, `PropertyGenerator`, `DomainOntologies`, `NamespaceManager`
### Reasoning
Derives new facts from existing knowledge using multiple inference strategies.
```python
-from semantica.reasoning import ReasoningEngine, DatalogEngine
+from semantica.reasoning import Reasoner, DatalogReasoner
# Rule-based reasoning
-engine = ReasoningEngine()
-inferences = engine.infer(kg, rules=["transitivity", "symmetry"])
+engine = Reasoner()
+engine.apply_transitivity("located_in")
+engine.apply_symmetry("knows")
+result = engine.infer()
# Datalog — recursive Horn clause rules (v0.4.0)
datalog = DatalogEngine()
@@ -403,9 +402,8 @@ result = pipeline.run("data/")
FastAPI Knowledge Explorer with Ontology Hub, WebSocket progress, bidirectional path finding, and indexed search (0.004ms on 118k nodes).
```python
-from semantica.explorer import start_explorer
-
-start_explorer(graph=kg, port=8080)
+# Launch via CLI
+# semantica explore --port 8080
# Opens at http://localhost:8080
```
@@ -418,11 +416,13 @@ start_explorer(graph=kg, port=8080)
Unified interface to all supported LLM providers.
```python
-from semantica.llms import Groq, OpenAI, create_provider
+from semantica.llms import Groq, OpenAI, LiteLLM
+import os
-llm = Groq(model="llama-3.3-70b-versatile")
-llm = OpenAI(model="gpt-4o")
-llm = create_provider("anthropic", model="claude-opus-4-7")
+llm = Groq(model="llama-3.3-70b-versatile", api_key=os.getenv("GROQ_API_KEY"))
+llm = OpenAI(model="gpt-4o", api_key=os.getenv("OPENAI_API_KEY"))
+# Anthropic, Gemini, Ollama, DeepSeek via LiteLLM:
+llm = LiteLLM(model="anthropic/claude-opus-4-7", api_key=os.getenv("ANTHROPIC_API_KEY"))
```
**Supported providers:** OpenAI, Anthropic, Google Gemini, Groq, Ollama, DeepSeek, Novita AI, LiteLLM (20+ models via one interface)
@@ -534,9 +534,9 @@ from semantica.utils import helpers, validators, logging
| [split](reference/split) | Text chunking | `TextSplitter` |
| [normalize](reference/normalize) | Data cleaning | `TextNormalizer`, `EntityNormalizer`, `LanguageDetector` |
| [semantic_extract](reference/semantic_extract) | NER & relation extraction | `NERExtractor`, `RelationExtractor`, `TripletExtractor`, `SemanticAnalyzer`, `SemanticNetworkExtractor`, `ExtractionValidator` |
-| [kg](reference/kg) | Graph construction | `GraphBuilder`, `TemporalKnowledgeGraph`, `DistanceCalculator` |
-| [ontology](reference/ontology) | Schema management | `OntologyManager`, `SHACLGenerator` |
-| [reasoning](reference/reasoning) | Logical inference | `ReasoningEngine`, `DatalogEngine` |
+| [kg](reference/kg) | Graph construction | `GraphBuilder`, `TemporalGraphQuery`, `SimilarityCalculator` |
+| [ontology](reference/ontology) | Schema management | `OntologyGenerator`, `SHACLGenerator` |
+| [reasoning](reference/reasoning) | Logical inference | `Reasoner`, `DatalogReasoner` |
| [embeddings](reference/embeddings) | Vector embeddings | `EmbeddingGenerator` |
| [vector_store](reference/vector_store) | Vector database | `VectorStore` |
| [graph_store](reference/graph_store) | Graph database | `GraphStore` |
diff --git a/docs/reference/kg.md b/docs/reference/kg.md
index 683e8fdc..6ae284ee 100644
--- a/docs/reference/kg.md
+++ b/docs/reference/kg.md
@@ -296,8 +296,8 @@ def my_kg_builder(entities, relationships, **kwargs):
method_registry.register("build", "high_confidence", my_kg_builder)
-from semantica.kg import build_knowledge_graph
-kg = build_knowledge_graph(sources, method="high_confidence")
+# Dispatch by name via the registry
+result = method_registry.execute("build", "high_confidence", entities=entities, relationships=relationships)
```
## ProvenanceTracker
diff --git a/docs/reference/llms.md b/docs/reference/llms.md
index 55b8fea6..0db513d5 100644
--- a/docs/reference/llms.md
+++ b/docs/reference/llms.md
@@ -384,16 +384,17 @@ llm = OpenAI(
Every module that uses an LLM accepts any provider through `llm_provider=`:
```python
-from semantica.llms import Groq, Anthropic
+from semantica.llms import Groq, LiteLLM
from semantica.semantic_extract import NERExtractor, RelationExtractor, TripletExtractor
from semantica.ontology import LLMOntologyGenerator
-from semantica.reasoning import ReasoningEngine
+from semantica.reasoning import Reasoner
from semantica.context import AgentContext, ContextGraph
from semantica.vector_store import VectorStore
import os
groq_llm = Groq(model="llama-3.3-70b-versatile", api_key=os.getenv("GROQ_API_KEY"))
-claude_llm = Anthropic(model="claude-opus-4-7", api_key=os.getenv("ANTHROPIC_API_KEY"))
+# Anthropic Claude via LiteLLM using the "anthropic/" prefix
+claude_llm = LiteLLM(model="anthropic/claude-opus-4-7", api_key=os.getenv("ANTHROPIC_API_KEY"))
# Extraction — use fast Groq for high-throughput NER
ner = NERExtractor(method="llm", llm_provider=groq_llm)
@@ -401,7 +402,7 @@ rel = RelationExtractor(method="llm", llm_provider=groq_llm)
trip = TripletExtractor(method="llm", llm_provider=groq_llm)
# Complex reasoning — use Claude for accuracy
-engine = ReasoningEngine(llm_provider=claude_llm)
+engine = Reasoner()
# Ontology generation from natural language
gen = LLMOntologyGenerator(llm_provider=claude_llm)
@@ -451,11 +452,12 @@ Load it with `ConfigManager`:
```python
from semantica.core import ConfigManager
-from semantica.llms import create_provider
+from semantica.llms import LiteLLM
config = ConfigManager("config.yaml")
-llm = create_provider(
- config.get("llm_provider.name"),
+# LiteLLM model strings carry the provider prefix — e.g. "anthropic/claude-opus-4-7",
+# "gemini/gemini-1.5-pro", "ollama/llama3.2" — so provider selection is config-driven
+llm = LiteLLM(
model=config.get("llm_provider.model"),
api_key=config.get("llm_provider.api_key"),
temperature=config.get("llm_provider.temperature", default=0.0),
@@ -473,7 +475,7 @@ llm = create_provider(
</Tip>
<Tip>
- **Use `create_provider()` for config-driven pipelines.** Hard-coding `Groq(...)` in Python means changing the provider requires a code change and redeploy. `create_provider(config.get("llm_provider.name"), ...)` lets you switch from Groq to Anthropic by editing `config.yaml` — no code changes.
+ **Use `LiteLLM` for config-driven pipelines.** Hard-coding `Groq(...)` in Python means changing the provider requires a code change and redeploy. `LiteLLM(model=config.get("llm_provider.model"), ...)` lets you switch from Groq to Anthropic by editing `config.yaml` with a model string like `"anthropic/claude-opus-4-7"` — no code changes.
</Tip>
<Tip>
diff --git a/docs/reference/semantic_extract.md b/docs/reference/semantic_extract.md
index 9e3d91db..01cc90c5 100644
--- a/docs/reference/semantic_extract.md
+++ b/docs/reference/semantic_extract.md
@@ -98,11 +98,11 @@ icon: "magnifying-glass-chart"
**v0.5.0 fix:** `NERExtractor(method="llm")` no longer silently falls back to pattern extraction on custom gateways. The `response_format=json_object` parameter is now conditionally omitted for incompatible gateways, with a plain `generate()` + JSON parsing fallback applied automatically.
</Note>
- Works with every Semantica LLM provider — swap `Groq` for `Anthropic`, `OpenAI`, `Gemini`, `Ollama`, `HuggingFace`, `DeepSeek`, or `Novita` with a one-line change:
+ Works with every Semantica LLM provider — swap `Groq` for any other provider with a one-line change. Anthropic, Gemini, Ollama, and DeepSeek are accessed via `LiteLLM` using their provider prefix:
```python
- from semantica.llms import Anthropic
- llm = Anthropic(model="claude-opus-4-7", api_key=os.getenv("ANTHROPIC_API_KEY"))
+ from semantica.llms import LiteLLM
+ llm = LiteLLM(model="anthropic/claude-opus-4-7", api_key=os.getenv("ANTHROPIC_API_KEY"))
ner = NERExtractor(method="llm", llm_provider=llm)
```
</Tab>
diff --git a/docs/reference/triplet_store.md b/docs/reference/triplet_store.md
index 79011323..e30717ae 100644
--- a/docs/reference/triplet_store.md
+++ b/docs/reference/triplet_store.md
@@ -155,14 +155,15 @@ icon: "table"
Register custom prefixes to keep SPARQL queries readable:
```python
-from semantica.triplet_store import TripletStore, NamespacePrefixManager
+from semantica.triplet_store import TripletStore
+from semantica.ontology import NamespaceManager
-ns = NamespacePrefixManager()
+ns = NamespaceManager(base_uri="http://example.org/")
ns.register("ex", "http://example.org/")
ns.register("schema", "https://schema.org/")
ns.register("owl", "http://www.w3.org/2002/07/owl#")
-store = TripletStore(backend="jena", endpoint="...", namespace_manager=ns)
+store = TripletStore(backend="jena", endpoint="...")
# Registered prefixes are automatically prepended to every SPARQL query
results = store.sparql("""