GraphRAG-SDK v0.2

New release

Table of Contents

We’re excited to announce the release of GraphRAG-SDK v0.2, packed with powerful new features that take knowledge graph-based AI applications to the next level. Whether you’re working with multi-model AI systems, multiple knowledge graphs, or multi-agent environments, this update brings new capabilities to simplify your workflow and enhance your insights.

Let’s dive into the major updates in v0.2, complete with code examples to help you get started.

New Features in GraphRAG-SDK v0.2

Multi-Model Support: Integrating Google Gemini and OpenAI GPT Models

GraphRAG-SDK v0.2 adds support for Google’s Gemini models in addition to OpenAI’s GPT models, giving you the flexibility to choose the right model for your needs. You can now switch seamlessly between models depending on your use case, maximizing accuracy and insights.

Here’s a quick example of how you can configure your model setup:

            from graphrag_sdk.models.openai import OpenAiGenerativeModel

# Initialize GPT-4 from OpenAI
model = OpenAiGenerativeModel(model_name="gpt-4o")

# Initialize Gemini-1.5 from Google
from graphrag_sdk.models.gemini import GeminiGenerativeModel
model = GeminiGenerativeModel(model_name="gemini-1.5-flash-001")

        

With this, you can effortlessly switch between AI models for enhanced flexibility.

Multi-Knowledge Graph with Auto Ontology Discovery

Managing multiple knowledge graphs is now easier than ever with auto-ontology discovery. GraphRAG-SDK v0.2 allows you to automatically generate ontologies for each domain, eliminating manual work and ensuring optimal data structure.

Check out how simple it is to work with multiple knowledge graphs:

            # Import Data
urls = ["https://www.rottentomatoes.com/m/matrix"]
sources = [URL(url) for url in urls]
# Model
model = OpenAiGenerativeModel(model_name="gpt-4o")

# Ontology Auto-Detection
ontology = Ontology.from_sources(
    sources=sources,
    model=model,
)
# Query across multiple graphs
results = graph_rag.query("Explain the impact of inflation on healthcare costs.")
print(json.dumps(ontology.to_json(), indent=4))

        

This feature ensures that each knowledge graph is structured perfectly for the domain in question, reducing setup time and manual effort.

Expanded Source Formats: Now Supports URLs, CSV, and JSON

Data ingestion just got easier! GraphRAG-SDK now supports a broader range of data formats, including URLs, CSV, and JSON. This makes it simpler to integrate and query data from a wide array of sources.

Here’s an example of importing data from various sources:

            from graphrag_sdk.source import Source
your_file = “...csv/…json/…url” 
Source = Source(your_file)

        

Whether your data lives on the web, in structured files, or elsewhere, this new feature streamlines the process of integrating and querying knowledge graphs.

Multi-Agent System & Orchestrator: Build AI Ecosystems with Ease

GraphRAG-SDK v0.2 introduces support for multi-agent systems, complete with an orchestrator to coordinate and manage the interactions between agents. This is ideal for building more complex, AI-driven ecosystems where different agents handle specialized tasks.

 

Here’s an example of how to set up a multi-agent system:

            from graphrag_sdk.orchestrator import Orchestrator
from graphrag_sdk.agents.kg_agent import KGAgent
from graphrag_sdk.models.openai import OpenAiGenerativeModel

# To create the ontology, see the full documentation and examples on our https://github.com/FalkorDB/GraphRAG-SDK/
restaurants_ontology = Ontology(...)
attractions_ontology = Ontology(...)

# Define the model
model = OpenAiGenerativeModel("gpt-4o")

# Create the KG from the predefined ontology.
# Restaurants KG
restaurants_kg = KnowledgeGraph(
    name="restaurants",
    ontology=restaurants_ontology,
    model_config=KnowledgeGraphModelConfig.with_model(model),
)

# Attractions KG
attractions_kg = KnowledgeGraph(
    name="attractions",
    ontology=attractions_ontology,
    model_config=KnowledgeGraphModelConfig.with_model(model),
)
# The following agent is specialized in finding restaurants.
restaurants_agent = KGAgent(
    agent_id="restaurants_agent",
    kg=restaurants_kg,
    introduction="I'm a restaurant agent, specialized in finding the best restaurants for you.",
)

# The following agent is specialized in finding tourist attractions.
attractions_agent = KGAgent(
    agent_id="attractions_agent",
    kg=attractions_kg,
    introduction="I'm an attractions agent, specialized in finding the best attractions for you.",
)

# Initialize the orchestrator and register agents
orchestrator = Orchestrator(
    model,
    backstory="You are a trip planner, and you want to provide the best possible itinerary for your clients.",
)
orchestrator.register_agent(restaurants_agent)
orchestrator.register_agent(attractions_agent)

# Query the orchestrator
runner = 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.")
print(runner.output)

        

This functionality is perfect for scaling AI workflows, allowing different agents to specialize in different aspects of a problem while the orchestrator ensures smooth coordination.

Ready to Get Started?

With the release of GraphRAG-SDK v0.2, managing multiple AI models, working with complex knowledge graphs, and building multi-agent systems has never been easier. Start experimenting with these powerful new features and see how they can enhance your AI-driven knowledge graph applications.

Install the latest version via PyPI:

            pip install graphrag_sdk

        

Explore the full documentation and examples on our https://github.com/FalkorDB/GraphRAG-SDK/ 

 

Happy coding! 👨‍💻👩‍💻

– PyPI: https://pypi.org/project/graphrag_sdk/ 

GraphRAG, CodeGraph and Graph DBMS news, guides and opinions delivered weekly. No spam, cancel anytime.