Skip to content

Commit 3ffb066

Browse files
authored
Merge pull request #125 from FalkorDB/update-readme
update README
2 parents 239556e + 81bd7a7 commit 3ffb066

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,78 @@ pip install graphrag_sdk
4242
[![Get started](https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/get-started-badge.svg)](https://lightning.ai/muhammadqadora/studios/build-fast-accurate-genai-apps-advanced-rag-with-falkordb)
4343
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/FalkorDB/GraphRAG-SDK/blob/main/examples/movies/demo-movies.ipynb)
4444

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
90+
model_config = KnowledgeGraphModelConfig.with_model(model)
91+
92+
# Create KnowledgeGraph instance
93+
kg = KnowledgeGraph(
94+
name=graph_name,
95+
model_config=model_config,
96+
ontology=ontology,
97+
host=os.getenv("FALKORDB_HOST", "localhost"),
98+
port=int(os.getenv("FALKORDB_PORT", 6379)),
99+
username=os.getenv("FALKORDB_USERNAME"),
100+
password=os.getenv("FALKORDB_PASSWORD")
101+
)
102+
103+
# Start chat session
104+
chat = kg.chat_session()
105+
106+
# Ask questions
107+
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+
45117
### Step 1: Creating Ontologies
46118
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)
47119

0 commit comments

Comments
 (0)