# GraphRAGApi Method | HTTP request | Description ------------- | ------------- | ------------- [**build_collection_graph**](GraphRAGApi.md#build-collection-graph) | **POST** /graph/{collection-id}/build | Build a knowledge graph for a collection.| **POST** /graph/{collection_id}/build | Build a knowledge graph for a collection. [**delete_collection_graph**](GraphRAGApi.md#delete-collection-graph) | **DELETE** /graph/{collection-id} | Delete the knowledge graph for a collection.| **DELETE** /graph/{collection_id} | Delete the knowledge graph for a collection. [**get_collection_graph**](GraphRAGApi.md#get-collection-graph) | **GET** /graph/{collection-id} | Read a renderable subgraph of a collection&| **GET** /graph/{collection_id} | Read a renderable subgraph of a collection's knowledge graph. [**get_collection_graph_node**](GraphRAGApi.md#get-collection-graph-node) | **GET** /graph/{collection-id}/node | Get full detail for one knowledge-graph node.| **GET** /graph/{collection_id}/node | Get full detail for one knowledge-graph node. [**get_collection_graph_status**](GraphRAGApi.md#get-collection-graph-status) | **GET** /graph/{collection-id}/status | Get graph build status for a collection.| **GET** /graph/{collection_id}/status | Get graph build status for a collection. [**get_graph_config**](GraphRAGApi.md#get-graph-config) | **GET** /graph/config | Get GraphRAG configuration.| **GET** /graph/config | Get GraphRAG configuration. [**search_collection_graph_labels**](GraphRAGApi.md#search-collection-graph-labels) | **GET** /graph/{collection-id}/labels | Search entity names in a collection&| **GET** /graph/{collection_id}/labels | Search entity names in a collection's knowledge graph. # **build_collection_graph** > JobDetails build_collection_graph(collection_id, build_collection_graph_request=build_collection_graph_request) Build a knowledge graph for a collection. Triggers an asynchronous job that extracts entities and relationships from document chunks to build a knowledge graph using LightRAG. Returns 409 Conflict if a build is already in progress. ### Example * Bearer Authentication (bearerAuth): ```python import h2ogpte.rest_sync from h2ogpte.rest_sync.models.build_collection_graph_request import BuildCollectionGraphRequest from h2ogpte.rest_sync.models.job_details import JobDetails from h2ogpte.rest_sync.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = h2ogpte.rest_sync.Configuration( host = "https://h2ogpte.genai.h2o.ai/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure Bearer authorization: bearerAuth configuration = h2ogpte.rest_sync.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with h2ogpte.rest_sync.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = h2ogpte.rest_sync.GraphRAGApi(api_client) collection_id = 'collection_id_example' # str | The collection ID to build the graph for. build_collection_graph_request = h2ogpte.rest_sync.BuildCollectionGraphRequest() # BuildCollectionGraphRequest | (optional) try: # Build a knowledge graph for a collection. api_response = api_instance.build_collection_graph(collection_id, build_collection_graph_request=build_collection_graph_request) print("The response of GraphRAGApi->build_collection_graph:\n") pprint(api_response) except Exception as e: print("Exception when calling GraphRAGApi->build_collection_graph: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **collection_id** | **str**| The collection ID to build the graph for. | **build_collection_graph_request** | [**BuildCollectionGraphRequest**](BuildCollectionGraphRequest.md)| | [optional] ### Return type [**JobDetails**](JobDetails.md) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **201** | Graph build job created | - | **400** | Bad request | - | **401** | Unauthorized - Invalid or missing API key | - | **403** | Forbidden | - | **409** | A graph build is already in progress for this collection. | - | # **delete_collection_graph** > delete_collection_graph(collection_id) Delete the knowledge graph for a collection. Tears down the collection's knowledge graph: removes the stored tarball from object storage, drops the in-memory per-collection lock and event loop, removes the local LightRAG cache directory, and resets graph_status to 'none'. The collection itself is unaffected. Auto-RAG selection will revert to normal RAG until a new graph is built. ### Example * Bearer Authentication (bearerAuth): ```python import h2ogpte.rest_sync from h2ogpte.rest_sync.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = h2ogpte.rest_sync.Configuration( host = "https://h2ogpte.genai.h2o.ai/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure Bearer authorization: bearerAuth configuration = h2ogpte.rest_sync.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with h2ogpte.rest_sync.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = h2ogpte.rest_sync.GraphRAGApi(api_client) collection_id = 'collection_id_example' # str | The collection whose graph should be deleted. try: # Delete the knowledge graph for a collection. api_instance.delete_collection_graph(collection_id) except Exception as e: print("Exception when calling GraphRAGApi->delete_collection_graph: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **collection_id** | **str**| The collection whose graph should be deleted. | ### Return type void (empty response body) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **204** | Graph deleted successfully. | - | **401** | Unauthorized - Invalid or missing API key | - | **403** | Forbidden | - | # **get_collection_graph** > KnowledgeGraphData get_collection_graph(collection_id, label=label, max_depth=max_depth, max_nodes=max_nodes) Read a renderable subgraph of a collection's knowledge graph. Returns nodes and edges of the knowledge graph for visualization (issue #11529). With label \"*\" (the default) returns the whole-graph view, degree-ranked and capped at max_nodes with is_truncated set; with a specific entity name returns the BFS neighborhood around that node (used by the viewer's expand-on-click). Read-only; node ids (entity names) and edge (source, target) pairs are the stable addresses a future edit API will target. ### Example * Bearer Authentication (bearerAuth): ```python import h2ogpte.rest_sync from h2ogpte.rest_sync.models.knowledge_graph_data import KnowledgeGraphData from h2ogpte.rest_sync.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = h2ogpte.rest_sync.Configuration( host = "https://h2ogpte.genai.h2o.ai/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure Bearer authorization: bearerAuth configuration = h2ogpte.rest_sync.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with h2ogpte.rest_sync.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = h2ogpte.rest_sync.GraphRAGApi(api_client) collection_id = 'collection_id_example' # str | The collection whose graph to read. label = '*' # str | Entity name to center the subgraph on, or \"*\" for the whole-graph view. (optional) (default to '*') max_depth = 3 # int | BFS depth when label is a specific entity. (optional) (default to 3) max_nodes = 1000 # int | Node cap for the returned subgraph (server clamps to its limit). (optional) (default to 1000) try: # Read a renderable subgraph of a collection's knowledge graph. api_response = api_instance.get_collection_graph(collection_id, label=label, max_depth=max_depth, max_nodes=max_nodes) print("The response of GraphRAGApi->get_collection_graph:\n") pprint(api_response) except Exception as e: print("Exception when calling GraphRAGApi->get_collection_graph: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **collection_id** | **str**| The collection whose graph to read. | **label** | **str**| Entity name to center the subgraph on, or \"*\" for the whole-graph view. | [optional] [default to '*'] **max_depth** | **int**| BFS depth when label is a specific entity. | [optional] [default to 3] **max_nodes** | **int**| Node cap for the returned subgraph (server clamps to its limit). | [optional] [default to 1000] ### Return type [**KnowledgeGraphData**](KnowledgeGraphData.md) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | Successful operation | - | **401** | Unauthorized - Invalid or missing API key | - | **403** | Forbidden | - | **404** | No knowledge graph exists for this collection. | - | # **get_collection_graph_node** > KnowledgeGraphNodeDetail get_collection_graph_node(collection_id, name) Get full detail for one knowledge-graph node. Returns a node's properties, its incident edges, and the source chunks (text and origin filename) that produced it, for the graph viewer's detail panel. Source chunks are the graph's own provenance records captured at build time. ### Example * Bearer Authentication (bearerAuth): ```python import h2ogpte.rest_sync from h2ogpte.rest_sync.models.knowledge_graph_node_detail import KnowledgeGraphNodeDetail from h2ogpte.rest_sync.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = h2ogpte.rest_sync.Configuration( host = "https://h2ogpte.genai.h2o.ai/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure Bearer authorization: bearerAuth configuration = h2ogpte.rest_sync.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with h2ogpte.rest_sync.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = h2ogpte.rest_sync.GraphRAGApi(api_client) collection_id = 'collection_id_example' # str | The collection whose graph to read. name = 'name_example' # str | The entity name (node id) to fetch. try: # Get full detail for one knowledge-graph node. api_response = api_instance.get_collection_graph_node(collection_id, name) print("The response of GraphRAGApi->get_collection_graph_node:\n") pprint(api_response) except Exception as e: print("Exception when calling GraphRAGApi->get_collection_graph_node: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **collection_id** | **str**| The collection whose graph to read. | **name** | **str**| The entity name (node id) to fetch. | ### Return type [**KnowledgeGraphNodeDetail**](KnowledgeGraphNodeDetail.md) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | Successful operation | - | **401** | Unauthorized - Invalid or missing API key | - | **403** | Forbidden | - | **404** | No knowledge graph exists for this collection, or the node was not found. | - | # **get_collection_graph_status** > GetCollectionGraphStatus200Response get_collection_graph_status(collection_id) Get graph build status for a collection. Returns the current knowledge graph build status and metadata. ### Example * Bearer Authentication (bearerAuth): ```python import h2ogpte.rest_sync from h2ogpte.rest_sync.models.get_collection_graph_status200_response import GetCollectionGraphStatus200Response from h2ogpte.rest_sync.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = h2ogpte.rest_sync.Configuration( host = "https://h2ogpte.genai.h2o.ai/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure Bearer authorization: bearerAuth configuration = h2ogpte.rest_sync.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with h2ogpte.rest_sync.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = h2ogpte.rest_sync.GraphRAGApi(api_client) collection_id = 'collection_id_example' # str | The collection ID to check. try: # Get graph build status for a collection. api_response = api_instance.get_collection_graph_status(collection_id) print("The response of GraphRAGApi->get_collection_graph_status:\n") pprint(api_response) except Exception as e: print("Exception when calling GraphRAGApi->get_collection_graph_status: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **collection_id** | **str**| The collection ID to check. | ### Return type [**GetCollectionGraphStatus200Response**](GetCollectionGraphStatus200Response.md) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | Successful operation | - | **401** | Unauthorized - Invalid or missing API key | - | **403** | Forbidden | - | # **get_graph_config** > GetGraphConfig200Response get_graph_config() Get GraphRAG configuration. Returns GraphRAG configuration including allowed LLM models for graph building. ### Example * Bearer Authentication (bearerAuth): ```python import h2ogpte.rest_sync from h2ogpte.rest_sync.models.get_graph_config200_response import GetGraphConfig200Response from h2ogpte.rest_sync.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = h2ogpte.rest_sync.Configuration( host = "https://h2ogpte.genai.h2o.ai/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure Bearer authorization: bearerAuth configuration = h2ogpte.rest_sync.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with h2ogpte.rest_sync.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = h2ogpte.rest_sync.GraphRAGApi(api_client) try: # Get GraphRAG configuration. api_response = api_instance.get_graph_config() print("The response of GraphRAGApi->get_graph_config:\n") pprint(api_response) except Exception as e: print("Exception when calling GraphRAGApi->get_graph_config: %s\n" % e) ``` ### Parameters This endpoint does not need any parameter. ### Return type [**GetGraphConfig200Response**](GetGraphConfig200Response.md) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | Successful operation | - | **401** | Unauthorized - Invalid or missing API key | - | # **search_collection_graph_labels** > SearchCollectionGraphLabels200Response search_collection_graph_labels(collection_id, q=q, limit=limit) Search entity names in a collection's knowledge graph. Fuzzy-searches entity names (node labels) for the graph viewer's entity search. Without a query, returns the most-connected entities. ### Example * Bearer Authentication (bearerAuth): ```python import h2ogpte.rest_sync from h2ogpte.rest_sync.models.search_collection_graph_labels200_response import SearchCollectionGraphLabels200Response from h2ogpte.rest_sync.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1 # See configuration.py for a list of all supported configuration parameters. configuration = h2ogpte.rest_sync.Configuration( host = "https://h2ogpte.genai.h2o.ai/api/v1" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure Bearer authorization: bearerAuth configuration = h2ogpte.rest_sync.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with h2ogpte.rest_sync.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = h2ogpte.rest_sync.GraphRAGApi(api_client) collection_id = 'collection_id_example' # str | The collection whose graph to search. q = 'q_example' # str | Search text; empty returns the most-connected entities. (optional) limit = 100 # int | Maximum number of labels to return. (optional) (default to 100) try: # Search entity names in a collection's knowledge graph. api_response = api_instance.search_collection_graph_labels(collection_id, q=q, limit=limit) print("The response of GraphRAGApi->search_collection_graph_labels:\n") pprint(api_response) except Exception as e: print("Exception when calling GraphRAGApi->search_collection_graph_labels: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **collection_id** | **str**| The collection whose graph to search. | **q** | **str**| Search text; empty returns the most-connected entities. | [optional] **limit** | **int**| Maximum number of labels to return. | [optional] [default to 100] ### Return type [**SearchCollectionGraphLabels200Response**](SearchCollectionGraphLabels200Response.md) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | Successful operation | - | **401** | Unauthorized - Invalid or missing API key | - | **403** | Forbidden | - | **404** | No knowledge graph exists for this collection. | - |