fix(cookbook): resolve AttributeError and update imports in GraphRAG notebook

This commit is contained in:
KaifAhmad1
2025-12-22 23:44:22 +05:30
parent ab9624fb39
commit ab4fa0e4c5
3 changed files with 11 additions and 7 deletions
@@ -214,17 +214,16 @@
"metadata": {},
"outputs": [],
"source": [
"from semantica.kg import GraphBuilder\n",
"from semantica.deduplication import DuplicateDetector, EntityMerger\n",
"from semantica.kg import GraphBuilder, EntityResolver\n",
"\n",
"# 1. Build & Vectorize\n",
"gb = GraphBuilder(merge_entities=True)\n",
"kg = gb.build([combined_results])\n",
"\n",
"# 2. Deduplicate\n",
"detector = DuplicateDetector(threshold=0.85)\n",
"duplicates = detector.detect_duplicates(kg['entities'])\n",
"kg_final = EntityMerger().merge_entities(kg, duplicates)\n",
"# Use EntityResolver for comprehensive deduplication and merging\n",
"resolver = EntityResolver(similarity_threshold=0.85)\n",
"kg_final = {**kg, 'entities': resolver.resolve_entities(kg['entities'])}\n",
"\n",
"# 3. Populate Vector Store for retrieval\n",
"texts = [str(c.text) for c in all_chunks]\n",
@@ -251,7 +250,7 @@
"outputs": [],
"source": [
"from semantica.context import ContextRetriever\n",
"from semantica.inference import InferenceEngine\n",
"from semantica.reasoning import InferenceEngine\n",
"\n",
"# 1. Initialize Retriever & Engine\n",
"retriever = ContextRetriever(\n",
@@ -0,0 +1,5 @@
RETINOL CLINICAL GUIDE
Mechanism: Binds to retinoic acid receptors to increase cellular turnover.
Precautions: Should not be used with high-concentration AHA/BHA exfoliants.
Synergy: Highly effective when paired with Niacinamide to offset potential erythema.
@@ -1 +1 @@
{"entities": [{"id": "hyaluronic_acid", "name": "Hyaluronic Acid", "type": "Ingredient", "properties": {"role": "Humectant"}}, {"id": "retinol", "name": "Retinol", "type": "Ingredient", "properties": {"role": "Anti-aging actives"}}, {"id": "niacinamide", "name": "Niacinamide", "type": "Ingredient", "properties": {"role": "Barrier repair"}}, {"id": "collagen", "name": "Collagen", "type": "Protein", "properties": {"location": "Dermal Matrix"}}], "relationships": [{"source": "retinol", "target": "collagen", "type": "STIMULATES", "properties": {"level": "High"}}, {"source": "hyaluronic_acid", "target": "niacinamide", "type": "COMPLEMENTS", "properties": {"benefit": "Hydration + Barrier"}}]}
{"entities": [{"id": "hyaluronic_acid", "name": "Hyaluronic Acid", "type": "Ingredient", "properties": {"role": "Humectant"}}, {"id": "retinol", "name": "Retinol", "type": "Ingredient", "properties": {"role": "Anti-aging actives"}}, {"id": "niacinamide", "name": "Niacinamide", "type": "Ingredient", "properties": {"role": "Barrier repair"}}], "relationships": [{"source": "hyaluronic_acid", "target": "niacinamide", "type": "COMPLEMENTS", "properties": {"benefit": "Hydration + Barrier"}}]}