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 for additional materials.

1kg_search_settings = {
2 "use_kg_search": True,
3 "kg_search_type": "local",
4 "kg_search_level": None,
5 "generation_config": {
6 "model": "gpt-4",
7 "temperature": 0.1
8 },
9 "entity_types": ["Person", "Organization"],
10 "relationships": ["worksFor", "foundedBy"],
11 "max_community_description_length": 65536,
12 "max_llm_queries_for_global_search": 250,
13 "local_search_limits": {"__Entity__": 20, "__Relationship__": 20, "__Community__": 20}
14}
15
16response = 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.