{"id":43315885,"url":"https://github.com/FalkorDB/GraphRAG-SDK","last_synced_at":"2026-02-12T23:01:28.394Z","repository":{"id":242742926,"uuid":"748030359","full_name":"FalkorDB/GraphRAG-SDK","owner":"FalkorDB","description":"Build fast and accurate GenAI apps with GraphRAG SDK at scale.","archived":false,"fork":false,"pushed_at":"2026-01-27T14:18:12.000Z","size":3992,"stargazers_count":555,"open_issues_count":27,"forks_count":72,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-01-27T23:36:12.624Z","etag":null,"topics":["falkordb","genai","graph-database","graphrag","knowledge-graph","llm","open-source","rag","sdk"],"latest_commit_sha":null,"homepage":"https://www.falkordb.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FalkorDB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-25T05:54:20.000Z","updated_at":"2026-01-27T14:20:15.000Z","dependencies_parsed_at":"2024-12-15T14:27:30.382Z","dependency_job_id":"a23fef06-c534-435a-b20c-0c3ffc54d4e4","html_url":"https://github.com/FalkorDB/GraphRAG-SDK","commit_stats":null,"previous_names":["falkordb/rag-sdk","falkordb/graphrag-sdk"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/FalkorDB/GraphRAG-SDK","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkorDB%2FGraphRAG-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkorDB%2FGraphRAG-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkorDB%2FGraphRAG-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkorDB%2FGraphRAG-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FalkorDB","download_url":"https://codeload.github.com/FalkorDB/GraphRAG-SDK/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkorDB%2FGraphRAG-SDK/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29385001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T22:07:52.078Z","status":"ssl_error","status_checked_at":"2026-02-12T22:07:49.026Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["falkordb","genai","graph-database","graphrag","knowledge-graph","llm","open-source","rag","sdk"],"created_at":"2026-02-01T22:00:53.357Z","updated_at":"2026-02-12T23:01:28.388Z","avatar_url":"https://github.com/FalkorDB.png","language":"Python","funding_links":[],"categories":["GraphRAG Infrastructure"],"sub_categories":["Libraries"],"readme":"# GraphRAG \r\n[![Dockerhub](https://img.shields.io/docker/pulls/falkordb/falkordb?label=Docker)](https://hub.docker.com/r/falkordb/falkordb/)\r\n[![pypi](https://badge.fury.io/py/graphrag_sdk.svg)](https://pypi.org/project/graphrag_sdk/)\r\n[![Discord](https://img.shields.io/discord/1146782921294884966?style=flat-square)](https://discord.gg/6M4QwDXn2w)\r\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)\r\n\r\n\u003cp align=\"center\"\u003e\r\n  \u003cimg alt=\"FalkorDB GraphRAG-SDK README Banner\" src=\"images/FalkorDB GraphRAG-SDK README Banner.png\" width=\"1500\"\u003e\r\n\u003c/p\u003e\r\n\r\n### Build fast and accurate GenAI apps with GraphRAG SDK at scale\r\n\r\nSimplify the development of your next GenAI application with GraphRAG-SDK, a specialized toolkit for building Graph Retrieval-Augmented Generation (GraphRAG) systems. It integrates knowledge graphs, ontology management, and state-of-the-art LLMs to deliver accurate, efficient, and customizable RAG workflows.\r\n\r\n# GraphRAG Setup\r\n### Database Setup\r\n\r\n[![Try Free](https://img.shields.io/badge/Try%20Free-FalkorDB%20Cloud-FF8101?labelColor=FDE900\u0026style=for-the-badge\u0026link=https://app.falkordb.cloud)](https://app.falkordb.cloud)\r\n\r\nOr use on premise with Docker:\r\n\r\n```sh\r\ndocker run -p 6379:6379 -p 3000:3000 -it --rm  -v ./data:/data falkordb/falkordb:latest\r\n```\r\n\r\n### Dependencies:\r\n```sh\r\npip install graphrag_sdk\r\n```\r\n\r\n### Configure Credentials. See [.env](.env.template) for examples.\r\n\r\n* [LiteLLM](https://docs.litellm.ai): A framework supporting inference of large language models, allowing flexibility in deployment and use cases.  \r\n  To choose vendor use the prefix \"specific_vendor/your_model\", for example \"openai/gpt-4.1\".\r\n* [OpenAI](https://openai.com/index/openai-api) Recommended model:`gpt-4.1`\r\n* [Google](https://makersuite.google.com/app/apikey) Recommended model:`gemini-2.0-flash`\r\n* [Azure-OpenAI](https://ai.azure.com) Recommended model:`gpt-4.1`\r\n* [Ollama](https://ollama.com/) Available only to the Q\u0026A step. Recommended models: `llama3`. Ollama models are suitable for the Q\u0026A step only (after the knowledge graph (KG) created).\r\n\r\n\r\n# How to use\r\n[![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)\r\n[![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)\r\n\r\n### Environment Configuration\r\n\r\nBefore using the SDK, configure your environment variables:\r\n\r\n```bash\r\n# FalkorDB Connection (defaults are for on-premises)\r\nexport FALKORDB_HOST=\"localhost\" \r\nexport FALKORDB_PORT=6379 \r\nexport FALKORDB_USERNAME=\"your-username\"  # optional for on-premises\r\nexport FALKORDB_PASSWORD=\"your-password\"  # optional for on-premises\r\n\r\n# LLM Provider (choose one)\r\nexport OPENAI_API_KEY=\"your-key\"  # or GOOGLE_API_KEY, GROQ_API_KEY, etc.\r\n```\r\n\r\n## Quick Start with Existing Knowledge Graph\r\n\r\nIf you already have a knowledge graph in FalkorDB, you can quickly set up GraphRAG by extracting the ontology from your existing graph:\r\n\r\n```python\r\nimport os\r\nfrom falkordb import FalkorDB\r\nfrom graphrag_sdk import KnowledgeGraph\r\nfrom graphrag_sdk.ontology import Ontology\r\nfrom graphrag_sdk.models.litellm import LiteModel\r\nfrom graphrag_sdk.model_config import KnowledgeGraphModelConfig\r\n\r\ngraph_name = \"my_existing_graph\"\r\n\r\n# Connect to FalkorDB using environment variables\r\ndb = FalkorDB(\r\n    host=os.getenv(\"FALKORDB_HOST\", \"localhost\"),\r\n    port=int(os.getenv(\"FALKORDB_PORT\", 6379)),\r\n    username=os.getenv(\"FALKORDB_USERNAME\"),  # optional for on-premises\r\n    password=os.getenv(\"FALKORDB_PASSWORD\")   # optional for on-premises\r\n)\r\n\r\n# Select graph\r\ngraph = db.select_graph(graph_name)\r\n\r\n# Extract ontology from existing knowledge graph\r\nontology = Ontology.from_kg_graph(graph)\r\n\r\n# Configure model and create GraphRAG instance\r\nmodel = LiteModel()  # Default is OpenAI GPT-4.1, can specify different model\r\nmodel_config = KnowledgeGraphModelConfig.with_model(model)\r\n\r\n# Create KnowledgeGraph instance\r\nkg = KnowledgeGraph(\r\n    name=graph_name,\r\n    model_config=model_config,\r\n    ontology=ontology,\r\n    host=os.getenv(\"FALKORDB_HOST\", \"localhost\"),\r\n    port=int(os.getenv(\"FALKORDB_PORT\", 6379)),\r\n    username=os.getenv(\"FALKORDB_USERNAME\"),\r\n    password=os.getenv(\"FALKORDB_PASSWORD\")\r\n)\r\n\r\n# Start chat session\r\nchat = kg.chat_session()\r\n\r\n# Ask questions\r\nresponse = chat.send_message(\"What products are available?\")\r\nprint(response[\"response\"])\r\n\r\n# Ask follow-up questions\r\nresponse = chat.send_message(\"Tell me which one of them is the most expensive\")\r\nprint(response[\"response\"])\r\n```\r\n\r\n## Creating Knowledge Graphs from Scratch\r\n\r\n### Step 1: Creating Ontologies\r\nAutomate 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)\r\n\r\n```python\r\nfrom dotenv import load_dotenv\r\nimport json\r\nfrom graphrag_sdk.source import URL\r\nfrom graphrag_sdk import KnowledgeGraph, Ontology\r\nfrom graphrag_sdk.models.litellm import LiteModel\r\nfrom graphrag_sdk.model_config import KnowledgeGraphModelConfig\r\nload_dotenv()\r\n\r\n# Import Data\r\nurls = [\"https://www.rottentomatoes.com/m/side_by_side_2012\",\r\n\"https://www.rottentomatoes.com/m/matrix\",\r\n\"https://www.rottentomatoes.com/m/matrix_revolutions\",\r\n\"https://www.rottentomatoes.com/m/matrix_reloaded\",\r\n\"https://www.rottentomatoes.com/m/speed_1994\",\r\n\"https://www.rottentomatoes.com/m/john_wick_chapter_4\"]\r\n\r\nsources = [URL(url) for url in urls]\r\n\r\n# Model - vendor: openai, model: gpt-4.1 -\u003e openai/gpt-4.1\r\nmodel = LiteModel(model_name=\"openai/gpt-4.1\")\r\n\r\n# Ontology Auto-Detection\r\nontology = Ontology.from_sources(\r\n    sources=sources,\r\n    model=model,\r\n)\r\n# Save the ontology to the disk as a json file.\r\nwith open(\"ontology.json\", \"w\", encoding=\"utf-8\") as file:\r\n    file.write(json.dumps(ontology.to_json(), indent=2))\r\n```\r\n\r\n### Step 2: Creating a knowledge graph agent\r\nBuild, query, and manage knowledge graphs optimized for retrieval and augmentation tasks. \r\nLeverages FalkorDB for high-performance graph querying and multi-tenancy.\r\n\r\n```python\r\n# After approving the ontology, load it from disk.\r\nontology_file = \"ontology.json\"\r\nwith open(ontology_file, \"r\", encoding=\"utf-8\") as file:\r\n    ontology = Ontology.from_json(json.loads(file.read()))\r\n\r\nkg = KnowledgeGraph(\r\n    name=\"kg_name\",\r\n    model_config=KnowledgeGraphModelConfig.with_model(model),\r\n    ontology=ontology,\r\n    host=\"127.0.0.1\",\r\n    port=6379,\r\n    # username=falkor_username, # optional\r\n    # password=falkor_password  # optional\r\n)\r\n\r\nkg.process_sources(sources)\r\n```\r\n\r\n### Step 3: Query your Graph RAG\r\n\r\nAt this point, you have a Knowledge Graph that can be queried using this SDK. Use the method `chat_session` for start a conversation.\r\n\r\n```python\r\n# Conversation\r\nchat = kg.chat_session()\r\nresponse = chat.send_message(\"Who is the director of the movie The Matrix?\")\r\nprint(response)\r\nresponse = chat.send_message(\"How this director connected to Keanu Reeves?\")\r\nprint(response)\r\n```\r\n\r\n## Next Steps\r\nWith these 3 steps now completed, you're ready to interact and query your knowledge graph.  Here are suggestions for use cases:\r\n\u003cp align=\"left\"\u003e\r\n  \u003cimg alt=\"GraphRAG-SDK Use Cases Banner from FalkorDB\" src=\"images/use-cases.png\" width=\"800\"\u003e\r\n\u003c/p\u003e\r\n\r\n**Need help with your use case? let's [talk](https://www.falkordb.com/get-demo/)**\r\n\r\n\u003cbr /\u003e\r\n\r\n# Using Ollama\r\n\r\nOllama models are suitable for the Q\u0026A step only (after the knowledge graph has been created).\r\n\r\n## Setup\r\n\r\n```python\r\nfrom graphrag_sdk.models.ollama import OllamaGenerativeModel\r\n\r\n# Local Ollama (default: http://localhost:11434)\r\nqa_model = OllamaGenerativeModel(model_name=\"llama3:8b\")\r\n\r\n# Remote Ollama\r\nqa_model = OllamaGenerativeModel(\r\n    model_name=\"llama3:8b\",\r\n    api_base=\"http://remote-host:11434\"\r\n)\r\n```\r\n\r\n\u003cbr /\u003e\r\n\r\n# AI Agents with GraphRAG\r\n\r\n### Orchestrator\r\nThe GraphRAG-SDK supports Knowledge Graph-based agents. Each agent is an expert in his domain, and the orchestrator orchestrates the agents.\r\n\r\nCheck out the example:\r\n\r\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/FalkorDB/GraphRAG-SDK/blob/main/examples/trip/demo_orchestrator_trip.ipynb)\r\n\r\n\r\n### Agents\r\n\r\nSee the [Step 1](#how-to-use) section to understand how to create Knowledge Graph objects for the agents.\r\n\r\n```python\r\n# Define the model\r\nmodel = LiteModel(model_name=\"openai/gpt-4.1\")\r\n\r\n# Create the Knowledge Graph from the predefined ontology.\r\n# In this example, we will use the restaurants agent and the attractions agent.\r\nrestaurants_kg = KnowledgeGraph(\r\n    name=\"restaurants\",\r\n    ontology=restaurants_ontology,\r\n    model_config=KnowledgeGraphModelConfig.with_model(model),\r\n    host=\"127.0.0.1\",\r\n    port=6379,\r\n    # username=falkor_username, # optional\r\n    # password=falkor_password  # optional\r\n)\r\nattractions_kg = KnowledgeGraph(\r\n    name=\"attractions\",\r\n    ontology=attractions_ontology,\r\n    model_config=KnowledgeGraphModelConfig.with_model(model),\r\n    host=\"127.0.0.1\",\r\n    port=6379,\r\n    # username=falkor_username, # optional\r\n    # password=falkor_password  # optional\r\n)\r\n\r\n\r\n# The following agent is specialized in finding restaurants.\r\nrestaurants_agent = KGAgent(\r\n    agent_id=\"restaurants_agent\",\r\n    kg=restaurants_kg,\r\n    introduction=\"I'm a restaurant agent, specialized in finding the best restaurants for you.\",\r\n)\r\n\r\n# The following agent is specialized in finding tourist attractions.\r\nattractions_agent = KGAgent(\r\n    agent_id=\"attractions_agent\",\r\n    kg=attractions_kg,\r\n    introduction=\"I'm an attractions agent, specialized in finding the best tourist attractions for you.\",\r\n)\r\n```\r\n\r\n### Orchestrator - Multi-Agent System\r\n\r\nThe orchestrator manages the usage of agents and handles questioning.\r\n\r\n```python\r\n# Initialize the orchestrator while giving it the backstory.\r\norchestrator = Orchestrator(\r\n    model,\r\n    backstory=\"You are a trip planner, and you want to provide the best possible itinerary for your clients.\",\r\n)\r\n\r\n# Register the agents that we created above.\r\norchestrator.register_agent(restaurants_agent)\r\norchestrator.register_agent(attractions_agent)\r\n\r\n# Query the orchestrator.\r\nrunner = orchestrator.ask(\"Create a two-day itinerary for a trip to Rome. Please don't ask me any questions; just provide the best itinerary you can.\")\r\nprint(runner.output)\r\n\r\n```\r\n## Community\r\n\r\nHave questions or feedback? Reach out via:\r\n- [GitHub Issues](https://github.com/FalkorDB/GraphRAG-SDK/issues)\r\n- Join our [Discord](https://discord.com/invite/6M4QwDXn2w)\r\n\r\n⭐️ If you find this repository helpful, please consider giving it a star!\r\n\r\n## Additional Enhancement: Configuring your prompts\r\nWhen creating your Knowledge Graph (KG) agent, you can customize the prompts to tailor its behavior.\r\n\r\n💡 This step is optional but can enhance functionality.\r\n\r\nThere are five types of prompts:\r\n\r\n1. **`cypher_system_instruction`**  \r\n   - System instructions for the Cypher generation step.  \r\n   - **Note:** Ensure your prompt includes `{ontology}`.\r\n\r\n2. **`qa_system_instruction`**  \r\n   - System instructions for the Q\u0026A step.\r\n\r\n3. **`cypher_gen_prompt`**  \r\n   - The prompt used during the Cypher generation step.  \r\n   - **Note:** Include `{question}` in your prompt.\r\n\r\n4. **`cypher_gen_prompt_history`**  \r\n   - The prompt for Cypher generation when history needs to be considered.  \r\n   - **Note:** Include `{question}` and `{last_answer}` in your prompt.\r\n\r\n5. **`qa_prompt`**  \r\n   - The prompt used during the Q\u0026A step.  \r\n   - **Note:** Include `{question}`, `{context}`, and `{cypher}` in your prompt.\r\n\r\nHere’s an example configuration:\r\n\r\n```python\r\nkg = KnowledgeGraph(\r\n    name=\"kg_name\",\r\n    model_config=KnowledgeGraphModelConfig.with_model(model),\r\n    ontology=ontology,\r\n    cypher_system_instruction=cypher_system_instruction,\r\n    qa_system_instruction=qa_system_instruction,\r\n    cypher_gen_prompt=cypher_gen_prompt,\r\n    cypher_gen_prompt_history=cypher_gen_prompt_history,\r\n    qa_prompt=qa_prompt\r\n    host=\"127.0.0.1\",\r\n    port=6379,\r\n    # username=falkor_username, # optional\r\n    # password=falkor_password  # optional\r\n)\r\n```\r\n\r\n\r\n## FAQ\r\n**Which databases are supported?**\r\n\r\nGraphRAG-SDK is optimized for FalkorDB. Other backends may require adapters.\r\n\r\n**How scalable is the SDK?**\r\n\r\nGraphRAG-SDK is designed for multi-tenancy and large-scale applications. Performance depends on FalkorDB deployment configuration.\r\n\r\n**How does this SDK improve retrieval-augmented generation?**\r\n\r\nBy leveraging knowledge graphs, GraphRAG-SDK enables semantic relationships and ontology-driven queries that go beyond standard vector similarity.\r\n\r\n**Which file formats does the SDK support?**\r\n\r\nSupported formats include PDF, JSONL, CSV, HTML, TEXT, and URLs.\r\n\r\n**How does the SDK handle latency?**\r\n\r\nThe SDK is optimized for low-latency operations through FalkorDB, using techniques like query optimization and in-memory processing.\r\n\r\n**Does the SDK support multi-graph querying?**\r\n\r\nYes. Multi-graph querying is supported with APIs designed for cross-domain and hierarchical graph exploration.\r\n\r\n\u003cbr /\u003e\r\n\r\n# License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\r\n\r\nKeywords: RAG, graphrag, Retrieval-Augmented Generation, NLP, AI, Information Retrieval, Natural Language Processing, LLM, Embeddings, Semantic Search\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFalkorDB%2FGraphRAG-SDK","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFalkorDB%2FGraphRAG-SDK","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFalkorDB%2FGraphRAG-SDK/lists"}