You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://colab.research.google.com/github/FalkorDB/GraphRAG-SDK/blob/main/examples/movies/demo-movies.ipynb)
44
44
45
+
### Environment Configuration
46
+
47
+
Before using the SDK, configure your environment variables:
48
+
49
+
```bash
50
+
# FalkorDB Connection (defaults are for on-premises)
51
+
export FALKORDB_HOST="localhost"
52
+
export FALKORDB_PORT=6379
53
+
export FALKORDB_USERNAME="your-username"# optional for on-premises
54
+
export FALKORDB_PASSWORD="your-password"# optional for on-premises
55
+
56
+
# LLM Provider (choose one)
57
+
export OPENAI_API_KEY="your-key"# or GOOGLE_API_KEY, GROQ_API_KEY, etc.
58
+
```
59
+
60
+
## Quick Start with Existing Knowledge Graph
61
+
62
+
If you already have a knowledge graph in FalkorDB, you can quickly set up GraphRAG by extracting the ontology from your existing graph:
63
+
64
+
```python
65
+
import os
66
+
from falkordb import FalkorDB
67
+
from graphrag_sdk import KnowledgeGraph
68
+
from graphrag_sdk.ontology import Ontology
69
+
from graphrag_sdk.models.litellm import LiteModel
70
+
from graphrag_sdk.model_config import KnowledgeGraphModelConfig
71
+
72
+
graph_name ="my_existing_graph"
73
+
74
+
# Connect to FalkorDB using environment variables
75
+
db = FalkorDB(
76
+
host=os.getenv("FALKORDB_HOST", "localhost"),
77
+
port=int(os.getenv("FALKORDB_PORT", 6379)),
78
+
username=os.getenv("FALKORDB_USERNAME"), # optional for on-premises
79
+
password=os.getenv("FALKORDB_PASSWORD") # optional for on-premises
80
+
)
81
+
82
+
# Select graph
83
+
graph = db.select_graph(graph_name)
84
+
85
+
# Extract ontology from existing knowledge graph
86
+
ontology = Ontology.from_kg_graph(graph)
87
+
88
+
# Configure model and create GraphRAG instance
89
+
model = LiteModel() # Default is OpenAI GPT-4.1, can specify different model
response = chat.send_message("What products are available?")
108
+
print(response["response"])
109
+
110
+
# Ask follow-up questions
111
+
response = chat.send_message("Tell me which one of them is the most expensive")
112
+
print(response["response"])
113
+
```
114
+
115
+
## Creating Knowledge Graphs from Scratch
116
+
45
117
### Step 1: Creating Ontologies
46
118
Automate ontology creation from unstructured data or define it manually - See [example](https://github.com/falkordb/GraphRAG-SDK/blob/main/examples/trip/demo_orchestrator_trip.ipynb)
0 commit comments