> ## Documentation Index
> Fetch the complete documentation index at: https://r2r-patch-decruft-openapi-json.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Graph

Knowledge graph search settings can be configured both server-side and at runtime. Runtime settings are passed as a dictionary to the search and RAG endpoints. You may refer to the [search API documentation here](/api-reference/endpoint/search) for additional materials.

```python
kg_search_settings = {
    "use_kg_search": True,
    "kg_search_type": "global",
    "kg_search_level": None,
    "generation_config": {
        "model": "gpt-4",
        "temperature": 0.1
    },
    "entity_types": ["Person", "Organization"],
    "relationships": ["worksFor", "foundedBy"],
    "max_community_description_length": 65536,
    "max_llm_queries_for_global_search": 250,
    "local_search_limits": {"__Entity__": 20, "__Relationship__": 20, "__Community__": 20}
}

response = client.search("query", kg_search_settings=kg_search_settings)
```

**KGSearchSettings**

1. `use_kg_search` (bool): Whether to use knowledge graph search
2. `kg_search_type` (str): Type of knowledge graph search ('global' or 'local')
3. `kg_search_level` (Optional\[str]): Level of knowledge graph search
4. `generation_config` (Optional\[GenerationConfig]): Configuration for knowledge graph search generation
5. `entity_types` (list): Types of entities to search for
6. `relationships` (list): Types of relationships to search for
7. `max_community_description_length` (int): Maximum length of community descriptions (default: 65536)
8. `max_llm_queries_for_global_search` (int): Maximum number of LLM queries for global search (default: 250)
9. `local_search_limits` (dict\[str, int]): Limits for local search results by type

These settings provide fine-grained control over the search process in R2R, including vector search, hybrid search, and knowledge graph search configurations.
