kikocis/GraphRAG-SDK public
Changesets · Branches · Tags · Compare
| Changeset | 13be18c47915c3aaf8bb45da34ac07316f8190154faca126485186ad1d255fc7 |
|---|---|
| Author | Guy Korland <gkorland@gmail.com> · 2024-09-17 14:26 +03:00 |
| Committer | GitHub <noreply@github.com> · 2024-09-17 14:26 +03:00 |
| Parents | 9151e40c40ed |
1 file changed
modified README.md +21 −4
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | # GraphRAG-SDK |
| 2 | + | |
| 2 | 3 | [](https://app.falkordb.cloud) |
| 3 | 4 | [](https://hub.docker.com/r/falkordb/falkordb/) |
| 4 | 5 | [](https://discord.gg/6M4QwDXn2w) |
| 5 | -V2 | |
| 6 | 6 | |
| 7 | 7 | GraphRAG-SDK is a comprehensive solution for building Graph Retrieval-Augmented Generation (GraphRAG) applications, leveraging [FalkorDB](https://www.falkordb.com/) for optimal performance. |
| 8 | 8 | |
| @@ -24,6 +24,7 @@ | ||
| 24 | 24 | ### Prerequisites |
| 25 | 25 | |
| 26 | 26 | #### Graph Database |
| 27 | + | |
| 27 | 28 | GraphRAG-SDK relies on [FalkorDB](http://falkordb.com) as its graph engine and works with OpenAI/Gemini. |
| 28 | 29 | |
| 29 | 30 | Use [FalkorDB Cloud](https://app.falkordb.cloud/) to get credentials or start FalkorDB locally: |
| @@ -31,7 +32,9 @@ | ||
| 31 | 32 | ```sh |
| 32 | 33 | docker run -p 6379:6379 -p 3000:3000 -it --rm -v ./data:/data falkordb/falkordb:latest |
| 33 | 34 | ``` |
| 35 | + | |
| 34 | 36 | #### LLM Models |
| 37 | + | |
| 35 | 38 | Currently, this SDK supports the following LLMs API: |
| 36 | 39 | |
| 37 | 40 | * [OpenAI](https://openai.com/index/openai-api) Recommended model:`gpt-4o` |
| @@ -45,15 +48,16 @@ | ||
| 45 | 48 | ``` |
| 46 | 49 | OPENAI_API_KEY="OPENAI_API_KEY" |
| 47 | 50 | GOOGLE_API_KEY="GOOGLE_API_KEY" |
| 48 | - | |
| 49 | 51 | ``` |
| 50 | 52 | |
| 51 | 53 | </details> |
| 52 | 54 | |
| 53 | 55 | ## Basic Usage |
| 56 | + | |
| 54 | 57 | [](https://colab.research.google.com/github/FalkorDB/GraphRAG-SDK/blob/main/examples/movies/demo-movies.ipynb) |
| 55 | 58 | |
| 56 | 59 | The following example demonstrates the basic usage of this SDK to create a GraphRAG using URLs with auto-detected ontology. |
| 60 | + | |
| 57 | 61 | ```python |
| 58 | 62 | from dotenv import load_dotenv |
| 59 | 63 | |
| @@ -98,10 +102,13 @@ | ||
| 98 | 102 | print(chat.send_message("How this director connected to Keanu Reeves?")) |
| 99 | 103 | |
| 100 | 104 | ``` |
| 105 | + | |
| 101 | 106 | ## Tools |
| 107 | + | |
| 102 | 108 | [](https://colab.research.google.com/github/FalkorDB/GraphRAG-SDK/blob/main/examples/ufc/demo-ufc.ipynb) |
| 103 | 109 | |
| 104 | 110 | ### Import source data |
| 111 | + | |
| 105 | 112 | The SDK supports the following file formats: |
| 106 | 113 | |
| 107 | 114 | |
| @@ -110,7 +117,7 @@ | ||
| 110 | 117 | * URL |
| 111 | 118 | * HTML |
| 112 | 119 | * CSV |
| 113 | -V2 | |
| 120 | + | |
| 114 | 121 | ```python |
| 115 | 122 | import os |
| 116 | 123 | from graphrag_sdk.classes.source import Source |
| @@ -122,7 +129,9 @@ | ||
| 122 | 129 | for file in os.listdir(src_files): |
| 123 | 130 | sources.append(Source(os.path.join(src_files, file))) |
| 124 | 131 | ``` |
| 132 | + | |
| 125 | 133 | ### Ontology |
| 134 | + | |
| 126 | 135 | You can either auto-detect the ontology from your data or define it manually. Additionally, you can set `Boundaries` for ontology auto-detection. |
| 127 | 136 | |
| 128 | 137 | Once the ontology is created, you can review, modify, and update it as needed before using it to build the Knowledge Graph (KG). |
| @@ -157,11 +166,13 @@ | ||
| 157 | 166 | with open("ontology.json", "w", encoding="utf-8") as file: |
| 158 | 167 | file.write(json.dumps(ontology.to_json(), indent=2)) |
| 159 | 168 | ``` |
| 169 | + | |
| 160 | 170 | After generating the initial ontology, you can review it and make any necessary modifications to better fit your data and requirements. This might include refining entity types or adjusting relationships. |
| 161 | 171 | |
| 162 | 172 | Once you are satisfied with the ontology, you can proceed to use it for creating and managing your Knowledge Graph (KG). |
| 163 | 173 | |
| 164 | 174 | ### Knowledge Graph |
| 175 | + | |
| 165 | 176 | Now, you can use the SDK to create a Knowledge Graph (KG) from your sources and ontology. |
| 166 | 177 | |
| 167 | 178 | ```python |
| @@ -178,9 +189,11 @@ | ||
| 178 | 189 | |
| 179 | 190 | kg.process_sources(sources) |
| 180 | 191 | ``` |
| 192 | + | |
| 181 | 193 | You can update the KG at any time by processing more sources with the `process_sources` method. |
| 182 | 194 | |
| 183 | 195 | ### Graph RAG |
| 196 | + | |
| 184 | 197 | At this point, you have a Knowledge Graph that can be queried using this SDK. You can use the `ask` method for single questions or `chat_session` for conversations. |
| 185 | 198 | |
| 186 | 199 | ```python |
| @@ -197,10 +210,13 @@ | ||
| 197 | 210 | ``` |
| 198 | 211 | |
| 199 | 212 | ## Multi Agent - Orchestrator |
| 213 | + | |
| 200 | 214 | [](https://colab.research.google.com/github/FalkorDB/GraphRAG-SDK/blob/main/examples/trip/demo_orchestrator_trip.ipynb) |
| 201 | 215 | |
| 202 | 216 | The GraphRAG-SDK supports KG agents. Each agent is an expert in the data it has learned, and the orchestrator orchestrates the agents. |
| 217 | + | |
| 203 | 218 | ### Agents |
| 219 | + | |
| 204 | 220 | See the [Basic Usage](#basic-usage) section to understand how to create KG objects for the agents. |
| 205 | 221 | |
| 206 | 222 | ```python |
| @@ -234,10 +250,10 @@ | ||
| 234 | 250 | kg=attractions_kg, |
| 235 | 251 | introduction="I'm an attractions agent, specialized in finding the best tourist attractions for you.", |
| 236 | 252 | ) |
| 237 | - | |
| 238 | 253 | ``` |
| 239 | 254 | |
| 240 | 255 | ### Orchestrator - Multi-Agent System |
| 256 | + | |
| 241 | 257 | The orchestrator manages the usage of agents and handles questioning. |
| 242 | 258 | |
| 243 | 259 | ```python |
| @@ -257,6 +273,7 @@ | ||
| 257 | 273 | ``` |
| 258 | 274 | |
| 259 | 275 | ## Support |
| 276 | + | |
| 260 | 277 | Connect with our community for support and discussions. If you have any questions, don’t hesitate to contact us through one of the methods below: |
| 261 | 278 | |
| 262 | 279 | * [Discord](https://discord.com/invite/6M4QwDXn2w) |