= LLM Knowledge Graph Builder Backend
== API Reference
=== Connect to Neo4j Graph Database
-----
POST /connect
-----
This API is used to authenticate and connect frontend to backend using NEO4j database credential.
Based on the response from this API, the frontend UI displays the connection status and the database type icon, such as GDS DB or Aura DB.
**API Parameters :**
* `uri`= Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
----
{
"status": "Success",
"data": {
"db_vector_dimension": 384,
"application_dimension": 384,
"message": "Connection Successful",
"gds_status": true,
"write_access": true,
"elapsed_api_time": "1.52",
"gcs_file_cache": "True"
}
}
----
=== Upload Files from Local
----
POST /upload
----
This API handles the uploading of large files by breaking them into smaller chunks.
This method ensures that large files can be uploaded efficiently without overloading the server.
***API Parameters***
* `file`=The file to be uploaded, received in chunks,
* `chunkNumber`=The current chunk number being uploaded,
* `totalChunks`=The total number of chunks the file is divided into (each chunk of 1Mb size),
* `originalname`=The original name of the file,
* `model`=The model associated with the file,
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"file_size": 393322,
"file_name": "Untitled Diagram.png",
"file_extension": "png",
"message": "Chunk 1/1 saved"
},
"message": "Source Node Created Successfully"
}
....
=== User defined schema
----
POST /schema
----
This API gets the labels and relationships from existing Neo4j database data. Users can set the schema for graph generation (i.e., nodes and relationship labels) in the settings panel.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"triplets": [
"Location-HAS_DIPLOMATIC_MISSIONS->Entity",
"Location-FORMED->Alliance",
"Company-HAS_TECH_ROLE_COMPOSITION->Demographic",
"Objective-INCLUDES->Feature",
"Location-IS_LARGEST_URBAN_AREA_OF->Location",
"Country-DECLARED_AS->Government Type",
"Ecoregion-LOCATED_IN->Region",
"Organization-SUFFERED_CASUALTIES->Number",
"Company-HAS->Judicial System",
"Organization-ELECTED_BY->Legislative Body",
"Location-TOOK_IN->Population Group",
"Location-NUMBER_OF->Count",
"Organization-PROVIDES->Infrastructure",
"Location-HAS->Team",
"Country-FOCUSES_ON->Category"
]
},
"message": "Total elapsed API time 1.56"
}
....
=== Graph schema from input text
----
POST /populate_graph_schema
----
The API is used to populate a graph schema based on the provided input text, model, and schema description flag.
**API Parameters :**
* `input_text`=The input text used to populate the graph schema.
* `model`=The model to be used for populating the graph schema.
* `is_schema_description_checked`=A flag indicating whether the schema description should be considered.
* `is_local_storage`= Generate the generalized graph schema based on input text if value is false
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"triplets": [
"User-PURCHASES->Product",
"Product-SOLD_BY->Store",
"Product-HAS->Warranty"
]
}
}
....
=== Unstructured sources scan other than local
----
POST /url/scan
----
This API creates Document source nodes for all supported sources, including S3 buckets, GCS buckets, Wikipedia, web pages, YouTube videos, and local files
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name
* `model`= LLM model,
* `source_url`= <s3 bucket url or youtube url> ,
* `aws_access_key_id`= AWS access key,
* `aws_secret_access_key`= AWS secret key,
* `wiki_query`= Wikipedia query sources,
* `gcs_project_id`= GCS project id,
* `gcs_bucket_name`= GCS bucket name,
* `gcs_bucket_folder`= GCS bucket folder,
* `source_type`= s3 bucket/ gcs bucket/ youtube/Wikipedia as source type
* `gcs_project_id`=Form(None),
* `access_token`=Form(None),
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"elapsed_api_time": "3.22"
},
"success_count": 1,
"failed_count": 0,
"message": "Source Node created successfully for source type: Wikipedia and source: ",
"file_name": [
{
"fileName": "Google_DeepMind",
"fileSize": 8074,
"url": "https://en.wikipedia.org/wiki/Google_DeepMind",
"language": "en",
"status": "Success"
}
]
}
....
=== Extration of nodes and relations from content
----
POST /extract :
----
This API is responsible for -
** Reading the content of source provided in the form of langchain Document object from respective langchain loaders
** Dividing the document into multiple chunks, and make below relations -
*** PART_OF - relation from Document node to all chunk nodes
*** FIRST_CHUNK - relation from document node to first chunk node
*** NEXT_CHUNK - relation from a chunk pointing to next chunk of the document.
*** HAS_ENTITY - relation between chunk node and entities extracted from LLM.
** Extracting nodes and relations in the form of GraphDocument from respective LLM.
** Update embedding of chunks and create vector index.
** Update K-Nearest Neighbors graph for similar chunks.
**Implementation :**
** For multiple sources of content -
*** Local file - User can upload pdf file from their device.
*** s3 bucket - User passes the bucket url and all the pdf files inside folders and subfolders will be listed.
*** GCS bucket - User passes gcs project id, gcs bucket name and folder name, do google authentication to access all the pdf files under that folder and its subfolders and if folder name is not passed by user, all the pdf files under the bucket and its subfolders will be listed if user have read access of the bucket.
*** Web Sources -
**** Wikipedia - Wikipedia 1st page content is rendered url passed by user.
**** Youtube - Youtube video transcript is processed and if no transcript is available then respective error is thrown.
**** Web urls - Text Content from any web url is processed for generating graph.
** Langchain's LLMGraphTransformer library is used to get nodes and relations in the form of GraphDocument from LLMs. User and System prompts, LLM chain, graphDocument schema are defined in the library itself.
** SentenceTransformer embeddingds are used by default, also embeddings are made configurable to use either OpenAIEmbeddings or VertexAIEmbeddings.
** Vector index is created in databse on embeddingds created for chunks.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name
* `model`= LLM model,
* `file_name` = File uploaded from device
* `source_url`= <s3 bucket url or youtube url> ,
* `aws_access_key_id`= AWS access key,
* `aws_secret_access_key`= AWS secret key,
* `wiki_query`= Wikipedia query sources,
* `gcs_project_id`=GCS project id,
* `gcs_bucket_name`= GCS bucket name,
* `gcs_bucket_folder`= GCS bucket folder,
* `gcs_blob_filename` = GCS file name,
* `source_type`= local file/ s3 bucket/ gcs bucket/ youtube/ Wikipedia as source,
* `allowedNodes=Node labels passed from settings panel,
* `allowedRelationship`=Relationship labels passed from settings panel,
* `token_chunk_size`= chunk split size,
* `chunk_overlap`= numric value of chunk overlap,
* `chunks_to_combine`= value of combine chunks to process for extraction,
* `language`=Language in which wikipedia content will be extracted,
* `retry_condition`= re-process the file based on selection,
* `additional_instructions`= additional instruction for LLM while extraction,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"fileName": "Untitled Diagram.png",
"nodeCount": 19,
"relationshipCount": 33,
"total_processing_time": 15.91,
"status": "Completed",
"model": "openai_gpt_4.5",
"success_count": 1,
"chunkNodeCount": 5,
"chunkRelCount": 23,
"entityNodeCount": 14,
"entityEntityRelCount": 10,
"communityNodeCount": 0,
"communityRelCount": 0,
"db_url": "neo4j+s://demo.neo4jlabs.com:7687",
"api_name": "extract",
"source_url": null,
"wiki_query": null,
"source_type": "local file",
"logging_time": "2025-04-10 17:06:17 UTC",
"elapsed_api_time": "30.65",
"userName": "persistent",
"database": "persistent1",
"aws_access_key_id": null,
"gcs_bucket_name": null,
"gcs_bucket_folder": null,
"gcs_blob_filename": null,
"gcs_project_id": null,
"language": null,
"retry_condition": "",
"email": null,
"create_connection": "0.29",
"create_list_chunk_and_document": "1.75",
"total_chunks": 5,
"get_status_document_node": "0.06",
"update_source_node": "0.50",
"processed_combine_chunk_0-5": "12.85",
"processed_chunk_detail_0-5": {
"update_embedding": "0.74",
"entity_extraction": "6.54",
"save_graphDocuments": "4.81",
"relationship_between_chunk_entity": "0.56"
},
"Processed_source": "16.40",
"Per_entity_latency": "0.8421052631578947/s"
},
"file_source": "local file"
}
....
=== Get list of sources
----
POST /sources_list
----
List all sources (Document nodes) present in Neo4j graph database.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": [
{
"fileName": "About Amazon.pdf",
"fileSize": 163931,
"errorMessage": "",
"fileSource": "local file",
"nodeCount": 62,
"model": "OpenAI GPT 4",
"fileType": "pdf",
"processingTime": 122.71,
"relationshipCount": 187,
"status": "Completed",
"updatedAt": {
"_DateTime__date": {
"_Date__ordinal": 738993,
"_Date__year": 2024,
"_Date__month": 4,
"_Date__day": 17
},
"_DateTime__time": {
"_Time__ticks": 28640715768000,
"_Time__hour": 7,
"_Time__minute": 57,
"_Time__second": 20,
"_Time__nanosecond": 715768000,
"_Time__tzinfo": null
}
}
}
],
"message": "Total elapsed API time 3.20"
}
....
=== Post processing after graph generation
----
POST /post_processing :
----
This API is called at the end of document processing to create k-nearest neighbor relationships between similar chunks of documents based on KNN_MIN_SCORE, which is 0.8 by default, compute community clusters, generate community summaries, and recreate a full-text index on all labels in the database so Neo4j Bloom can make use of it.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name
* `tasks`= List of tasks to perform,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": [
{
"filename": "Google",
"chunkNodeCount": 100,
"chunkRelCount": 1310,
"entityNodeCount": 670,
"entityEntityRelCount": 775,
"communityNodeCount": 289,
"communityRelCount": 883,
"nodeCount": 1059,
"relationshipCount": 2968
},
{
"filename": "Germany",
"chunkNodeCount": 100,
"chunkRelCount": 1402,
"entityNodeCount": 780,
"entityEntityRelCount": 813,
"communityNodeCount": 422,
"communityRelCount": 1079,
"nodeCount": 1302,
"relationshipCount": 3294
}
],
"message": "All tasks completed successfully"
}
....
=== Chat with Data
----
POST /chat_bot
----
The API responsible for a chatbot system designed to leverage multiple AI models and a Neo4j graph database, providing answers to user queries. It interacts with AI models from OpenAI and Google's Vertex AI etc and utilizes embedding models to enhance the retrieval of relevant information. It utilises different retrievers (Retrieval Detail) to extract relevant information to the user query and uses LLM to formulate the answer. If no relevant information found the chatbot gracefully conveys to user.
**Components :**
** Embedding Models - Includes OpenAI Embeddings, VertexAI Embeddings, and SentenceTransformer Embeddings(Default) to support vector-based query operations.
** AI Models - OpenAI GPT 3.5, GPT 4o, GPT 40 mini, gemini_1.5_flash can be configured for the chatbot backend to generate responses and process natural language.
** Graph Database (Neo4jGraph) - Manages interactions with the Neo4j database, retrieving, and storing conversation histories.
** Response Generation - Utilizes Vector Embeddings from the Neo4j database, chat history, and the knowledge base of the LLM used.
** Chat Modes - Vector , Graph, Vector + Graph, Fulltext, Vector + Graph+Fulltext, Entity Search + Vector, Global search Vector
**API Parameters :**
* `uri`= Neo4j uri
* `userName`= Neo4j database username
* `password`= Neo4j database password
* `model`= LLM model
* `question`= User query for the chatbot
* `session_id`= Session ID used to maintain the history of chats during the user's connection
* `mode` = chat mode to use
* `document_names` = the names of documents to be filtered works for vector mode and vector+Graph mode,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"session_id": "f4e352bf-f57a-4a15-819e-68d2ffca82a2",
"message": "Germany has sixteen constituent states, collectively referred to as Länder.",
"info": {
"sources": [
"https://en.wikipedia.org/wiki/Germany"
],
"model": "gpt-4.5-preview",
"nodedetails": {
"chunkdetails": [
{
"id": "0c92f93e837e6b31f8d2429dd76c3db4ab37ce14",
"score": 1.0
},
{
"id": "ac8c9c1e05c718cc612160d6580caf1af97dfb1f",
"score": 0.9455
},
{
"id": "b91415a3bbfb99d64b3a2aa8b1413bebd5b5650e",
"score": 0.9307
}
],
"entitydetails": [],
"communitydetails": []
},
"total_tokens": 2493,
"response_time": 5.53,
"mode": "graph_vector_fulltext",
"entities": {
"entityids": [
"4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8329",
"4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7783",
"4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8327",
"4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7780",
"4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8512",
"4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8157",
"4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8549",
"4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7823"
],
"relationshipids": [
"5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:146149",
"5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:145082",
"5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:146554",
"5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:140377"
]
},
"metric_details": {
"question": "how many states in germany",
"contexts": "Document start\nThis Document belongs to the source https://en.wikipedia.org/wiki/Germany\nContent: Text Content:\nGermany, officially the Federal Republic of Germany, is a country in Central Europe. It lies between the Baltic Sea and the North Sea to the north and the Alps to the south. Its sixteen constituent states have a total population of over 82 million in an area of 357,596 km2 (138,069 sq mi), making it the most populous member state of the European Union. It borders Denmark to the north, Poland and the Czech Republic to the east, Austria and Switzerland to the south,\n----\n sixteen constituent states which are collectively referred to as Länder. Each state (Land) has its own constitution, and is largely autonomous in regard to its internal organisation. As of 2017, Germany is divided into 401 districts (Kreise) at a municipal level; these consist of 294 rural districts and 107 urban districts. === Law === Germany has a civil law system based on Roman law with some references to Germanic law. The Bundesverfassungsgericht (Federal\n----\n resort. == Demographics == With a population of 84.7 million according to the 2023 German census, Germany is the most populous member state of the European Union, the second-most populous country in Europe after Russia, and the nineteenth-most populous country in the world. Its population density stands at 236 inhabitants per square kilometre (610 inhabitants/sq mi). The fertility rate of 1.57 children born per woman (2022 estimates) is below the replacement rate of 2\n----\nEntities:\nAdministrative Division:107 urban districts\nAdministrative Division:294 rural districts\nAdministrative Division:401 districts\nAdministrative Division:sixteen constituent states\nArea:357,596 km2\nBody of Water:Baltic Sea\nBrand:Volkswagen\nCompany:Deutsche Telekom\nConcept:defence\nCountry:Austria\nCountry:Czech Republic\nCountry:Denmark\nCountry:Federal Republic of Germany\nCountry:Germany\nCountry:Hungary\nCountry:Poland\nCountry:Switzerland\nCountry:Ukraine\nCountry:United States\nCountry:West Germany\nEnergy Source:40% renewable sources\nGeographical Feature:Alps\nGeographical Feature:North Sea\nGroup:East Germans\nInitiative:Energiewende\nKingdom:East Francia\nLaw System:Germanic law\nLaw System:Roman law\nLaw System:civil law system\nLegal Domain:constitutional matters\nLegal Power:judicial review\nLocation:Berlin\nName:Länder\nOrganization Membership:founding member of the European Economic Community\nOrganization:Bundesverfassungsgericht\nOrganization:European Economic Community\nOrganization:European Union\nOrganization:Federal Constitutional Court\nOrganization:German Supreme Court\nOrganization:North German Confederation\nOrganization:Population Division of the United Nations Department of Economic and Social Affairs\nOrganization:coalition\nPercentage:11% between 1990 and 2015\nPercentage:65%\nPerson:Bismarck\nPopulation:over 82 million\nRank:14th highest emitting nation of greenhouse gases\nRanking:fourth globally in number of science and engineering research papers published\nRanking:fourth in research and development expenditure\nRanking:third in quality-adjusted Nature Index\nRegion:Central Europe\nResearch Institution:Fraunhofer Society\nResearch Institution:Helmholtz Association\nResearch Institution:Leibniz Association\nResearch Institution:Max Planck Society\nStatistic:percentage of migrants in population\nTerritory:Western sectors\n----\nRelationships:\nAdministrative Division:401 districts CONSISTS_OF Administrative Division:107 urban districts\nAdministrative Division:401 districts CONSISTS_OF Administrative Division:294 rural districts\nAdministrative Division:sixteen constituent states REFERRED_AS Name:Länder\nAdministrative Division:sixteen constituent states REFERRED_TO_AS Name:Länder\nCountry:Austria BORDERS Country:Germany\nCountry:Czech Republic BORDERS Country:Germany\nCountry:Federal Republic of Germany ALSO_KNOWN_AS Country:West Germany\nCountry:Federal Republic of Germany FOUNDING_MEMBER_OF Organization:European Economic Community\nCountry:Federal Republic of Germany FOUNDING_MEMBER_OF Organization:European Union\nCountry:Federal Republic of Germany HAS_STATUS Organization Membership:founding member of the European Economic Community\nCountry:Germany ANNEXED Country:Austria\nCountry:Germany BORDERED_BY Body of Water:Baltic Sea\nCountry:Germany BORDERED_BY Geographical Feature:North Sea\nCountry:Germany BORDERS Body of Water:Baltic Sea\nCountry:Germany BORDERS Country:Austria\nCountry:Germany BORDERS Country:Czech Republic\nCountry:Germany BORDERS Country:Denmark\nCountry:Germany BORDERS Country:Poland\nCountry:Germany BORDERS Country:Switzerland\nCountry:Germany BORDERS Geographical Feature:Alps\nCountry:Germany BORDERS Geographical Feature:North Sea\nCountry:Germany COMPRISES Administrative Division:sixteen constituent states\nCountry:Germany CONQUERED Country:Denmark\nCountry:Germany DIVIDED_INTO Administrative Division:401 districts\nCountry:Germany HAS_ADMINISTRATIVE_DIVISION Administrative Division:sixteen constituent states\nCountry:Germany HAS_AREA Area:357,596 km2\nCountry:Germany HAS_BRANDS Brand:Volkswagen\nCountry:Germany HAS_BRANDS Company:Deutsche Telekom\nCountry:Germany HAS_ENERGY_TRANSITION Initiative:Energiewende\nCountry:Germany HAS_FEATURE Geographical Feature:Alps\nCountry:Germany HAS_FEATURE Geographical Feature:North Sea\nCountry:Germany HAS_INSTITUTION Organization:Bundesverfassungsgericht\nCountry:Germany HAS_LAW_SYSTEM Law System:civil law system\nCountry:Germany HAS_PART Administrative Division:sixteen constituent states\nCountry:Germany HAS_POPULATION Population:over 82 million\nCountry:Germany HAS_RECYCLING_RATE Percentage:65%\nCountry:Germany HAS_RESEARCH_INSTITUTION Research Institution:Fraunhofer Society\nCountry:Germany HAS_RESEARCH_INSTITUTION Research Institution:Helmholtz Association\nCountry:Germany HAS_RESEARCH_INSTITUTION Research Institution:Leibniz Association\nCountry:Germany HAS_RESEARCH_INSTITUTION Research Institution:Max Planck Society\nCountry:Germany HAS_ROLE Organization:European Union\nCountry:Germany HAS_TERRITORY Area:357,596 km2\nCountry:Germany INVADED Country:Poland\nCountry:Germany LOCATED_IN Region:Central Europe\nCountry:Germany MEETS_POWER_DEMAND Energy Source:40% renewable sources\nCountry:Germany MEMBER_OF Organization:European Union\nCountry:Germany OFFICIALLY_KNOWN_AS Country:Federal Republic of Germany\nCountry:Germany ORGANIZED_INTO Country:Federal Republic of Germany\nCountry:Germany PLAYS_ROLE_IN Organization:European Union\nCountry:Germany RANKS_IN Ranking:fourth globally in number of science and engineering research papers published\nCountry:Germany RANKS_IN Ranking:fourth in research and development expenditure\nCountry:Germany RANKS_IN Ranking:third in quality-adjusted Nature Index\nCountry:Germany RANKS_SECOND_AFTER Country:United States\nCountry:Germany RANKS_SEVENTH_IN Statistic:percentage of migrants in population\nCountry:Germany RECEIVED_REFUGEES_FROM Country:Ukraine\nCountry:Germany REDUCED_ENERGY_CONSUMPTION Percentage:11% between 1990 and 2015\nCountry:Germany WAS_EMITTING_NATION Rank:14th highest emitting nation of greenhouse gases\nCountry:Hungary OPENED_BORDER_WITH Country:Austria\nCountry:Poland BORDERS Country:Germany\nCountry:Switzerland BORDERS Country:Germany\nGroup:East Germans EMIGRATED_VIA Country:Austria\nKingdom:East Francia STRETCHED_FROM Geographical Feature:North Sea\nKingdom:East Francia STRETCHED_TO Geographical Feature:Alps\nLaw System:civil law system BASED_ON Law System:Roman law\nLaw System:civil law system REFERENCES Law System:Germanic law\nLocation:Berlin IS_HUB Country:Germany\nOrganization:Bundesverfassungsgericht HAS_POWER Legal Power:judicial review\nOrganization:Bundesverfassungsgericht IS Organization:German Supreme Court\nOrganization:Bundesverfassungsgericht REFERRED_AS Organization:Federal Constitutional Court\nOrganization:Bundesverfassungsgericht RESPONSIBLE_FOR Legal Domain:constitutional matters\nOrganization:Federal Constitutional Court DEFINED_TERM Concept:defence\nOrganization:North German Confederation EXCLUDED Country:Austria\nOrganization:Population Division of the United Nations Department of Economic and Social Affairs LISTED_AS_HOST_TO Country:Germany\nOrganization:coalition OPERATES_IN Country:Switzerland\nPerson:Bismarck CONCLUDED_WAR Country:Denmark\nTerritory:Western sectors MERGED_TO_FORM Country:Federal Republic of Germany\nDocument end\n",
"answer": "Germany has sixteen constituent states, collectively referred to as Länder."
}
},
"user": "chatbot"
}
}
....
=== Get entities from chunks
----
/chunk_entities
----
This API is used to get the entities and relations associated with a particular chunk and chunk metadata.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `nodedetails` = Node element id's to get information(chunks,entities,communities),
* `entities` = entities received from the retriver for graph based modes,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"nodes": [
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7787",
"labels": [
"Country",
"Location"
],
"properties": {
"id": "Germany",
"description": null
}
},
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7779",
"labels": [
"Organization"
],
"properties": {
"id": "European Union",
"description": null
}
},
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:5977",
"labels": [
"Organization"
],
"properties": {
"id": "coalition",
"description": null
}
}
],
"relationships": [
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:146579",
"type": "RANKS_SECOND_AFTER",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7787",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:5973"
},
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:145089",
"type": "BORDERS",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7782",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7787"
},
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:146509",
"type": "HAS_BRANDS",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7787",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8457"
},
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:146121",
"type": "HAS_POWER",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8326",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8345"
}
],
"chunk_data": [
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7678",
"id": "0c92f93e837e6b31f8d2429dd76c3db4ab37ce14",
"position": 1,
"text": "Germany, officially the Federal Republic of Germany, is a country in Central Europe. It lies between the Baltic Sea and the North Sea to the north and the Alps to the south. Its sixteen constituent states have a total population of over 82 million in an area of 357,596 km2 (138,069 sq mi), making it the most populous member state of the European Union. It borders Denmark to the north, Poland and the Czech Republic to the east, Austria and Switzerland to the south,",
"content_offset": 0,
"fileName": "Germany",
"length": 468,
"embedding": null,
"fileSource": "Wikipedia",
"fileType": "text",
"url": "https://en.wikipedia.org/wiki/Germany"
},
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7747",
"id": "ac8c9c1e05c718cc612160d6580caf1af97dfb1f",
"position": 70,
"text": " sixteen constituent states which are collectively referred to as Länder. Each state (Land) has its own constitution, and is largely autonomous in regard to its internal organisation. As of 2017, Germany is divided into 401 districts (Kreise) at a municipal level; these consist of 294 rural districts and 107 urban districts. === Law === Germany has a civil law system based on Roman law with some references to Germanic law. The Bundesverfassungsgericht (Federal",
"content_offset": 33460,
"fileName": "Germany",
"length": 467,
"embedding": null,
"fileSource": "Wikipedia",
"fileType": "text",
"url": "https://en.wikipedia.org/wiki/Germany"
},
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7773",
"id": "b91415a3bbfb99d64b3a2aa8b1413bebd5b5650e",
"position": 96,
"text": " resort. == Demographics == With a population of 84.7 million according to the 2023 German census, Germany is the most populous member state of the European Union, the second-most populous country in Europe after Russia, and the nineteenth-most populous country in the world. Its population density stands at 236 inhabitants per square kilometre (610 inhabitants/sq mi). The fertility rate of 1.57 children born per woman (2022 estimates) is below the replacement rate of 2",
"content_offset": 46388,
"fileName": "Germany",
"length": 476,
"embedding": null,
"fileSource": "Wikipedia",
"fileType": "text",
"url": "https://en.wikipedia.org/wiki/Germany"
}
]
},
"message": "Total elapsed API time 0.55"
}
....
=== View graph for a file
----
POST /graph_query
----
This API is used to visualize graphs for a particular document or list of multiple documents;
it will return documents, chunks, entities, relationships and communities to the front-end to be shown in a graph visualization.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `document_names` = File name for which user wants to view graph,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"nodes": [
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10497",
"labels": [
"Document"
],
"properties": {
"fileName": "Untitled Diagram.png",
"communityNodeCount": 12,
"errorMessage": "",
"chunkRelCount": 28,
"fileSource": "local file",
"communityRelCount": 22,
"total_chunks": 5,
"processingTime": 15.91,
"entityNodeCount": 14,
"chunkNodeCount": 5,
"createdAt": "2025-04-10T16:33:22.331776000",
"entityEntityRelCount": 10,
"fileSize": 393322,
"model": "openai_gpt_4.5",
"nodeCount": 31,
"processed_chunk": 5,
"is_cancelled": false,
"relationshipCount": 60,
"fileType": "png",
"status": "Completed",
"updatedAt": "2025-04-10T17:06:15.896962000"
}
},
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10501",
"labels": [
"Chunk"
],
"properties": {
"fileName": "Untitled Diagram.png",
"content_offset": 9,
"page_number": 1,
"length": 21,
"id": "e6200cc319ae833a42f3ea85bd3f48fe57f528ac",
"position": 3
}
},
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10499",
"labels": [
"Chunk"
],
"properties": {
"fileName": "Untitled Diagram.png",
"content_offset": 0,
"page_number": 1,
"length": 1,
"id": "091385be99b45f459a231582d583ec9f3fa3d194",
"position": 1
}
},
{
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10503",
"labels": [
"Chunk"
],
"properties": {
"fileName": "Untitled Diagram.png",
"content_offset": 113,
"page_number": 1,
"length": 14,
"id": "2fe558452be341af4450be97b79ecdd8ea64b188",
"position": 5
}
}
],
"relationships": [
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:155207",
"type": "IN_COMMUNITY",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10515",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10907"
},
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:155845",
"type": "PARENT_COMMUNITY",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10907",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:11378"
},
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:155846",
"type": "PARENT_COMMUNITY",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:11378",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:11379"
},
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:153551",
"type": "HAS_ENTITY",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10503",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:10516"
}
]
},
"message": "Total elapsed API time 0.79"
}
....
=== Get neighbour nodes
----
POST /get_neighbours
----
This API is used to get the nearby nodes and relationships based on the element id of the node for graph visualization of details of specific nodes.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `elementId` = Element id of the node to retrive its neighbours,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"nodes": [
{
"summary": null,
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:11925",
"id": "0-554",
"text": null,
"title": "Western Sectors Control,",
"weight": 2,
"level": 0,
"labels": [
"__Community__"
],
"properties": {
"id": "0-554",
"title": "Western Sectors Control,"
},
"embedding": null
},
{
"summary": null,
"element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:5978",
"id": "United Kingdom",
"text": null,
"communities": [
554,
246,
16
],
"labels": [
"Country"
],
"properties": {
"id": "United Kingdom",
"title": " "
},
"embedding": null
}
],
"relationships": [
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:145729",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:7792",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8154",
"type": "CONTROLLED_BY"
},
{
"element_id": "5:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:145730",
"end_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:5978",
"start_node_element_id": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:8154",
"type": "CONTROLLED_BY"
}
]
},
"message": "Total elapsed API time 0.43"
}
....
=== Clear chat history
----
POST /clear_chat_bot
----
This API is used to clear the chat history which is saved in Neo4j DB.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `session_id` = User session id for QA chat,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"session_id": "f4e352bf-f57a-4a15-819e-68d2ffca82a2",
"message": "The chat history has been cleared.",
"user": "chatbot"
}
}
....
=== SSE event to update processing status
----
GET /update_extract_status
----
The API provides a continuous update on the extraction status of a specified file. It uses Server-Sent Events (SSE) to stream updates to the client.
**API Parameters :**
* `file_name`=The name of the file whose extraction status is being tracked,
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
**Response :**
[source,json,indent=0]
....
{
"fileName": "testFile.pdf",
"status": "Processing",
"processingTime": 0,
"nodeCount": 0,
"relationshipCount": 0,
"model": "OpenAI GPT 3.5",
"total_chunks": 3,
"fileSize": 92373,
"processed_chunk": 0
}
....
=== Delete selected documents
----
POST /delete_document_and_entities
----
**Overview :**
Deleteion of nodes and relations for multiple files is done through this API. User can choose multiple documents to be deleted, also user have option to delete only 'Document' and 'Chunk' nodes and keep the entities extracted from that document.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `filenames`= List of files to be deleted,
* `source_types`= Document sources(Wikipedia, youtube, etc.),
* `deleteEntities`= Boolean value to check entities deletion is requested or not,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{"status":"Success","message":"Deleted 1 documents with entities from database"}
....
=== Cancel processing job
----
/cancelled_job
----
This API is responsible for cancelling an in process job.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `filenames`= Name of the file whose processing need to be stopped,
* `source_types`= Source of the file,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"message":"Cancelled the processing job successfully"
}
....
=== Get the list of orphan nodes
----
POST /get_unconnected_nodes_list
----
The API retrieves a list of nodes in the graph database that are not connected to any other entity nodes,
and only to chunks that they were extracted from. So to say orphan nodes from an domain graph perspective.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": [
{
"e": {
"id": "46c949fb-b451-4b69-b3bd-87f26ac8f9e6",
"elementId": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:5853",
"labels": [
"Entity"
],
"embedding": null
},
"documents": [],
"chunkConnections": 0
},
{
"e": {
"id": "f4e352bf-f57a-4a15-819e-68d2ffca82a2",
"elementId": "4:8b7ad735-1828-4d80-b8c3-798dcbfdd95d:11380",
"labels": [
"Entity"
],
"embedding": null
},
"documents": [],
"chunkConnections": 0
}
],
"message": {
"total": 2
}
}
....
=== Deletion of orpahn nodes
----
POST /delete_unconnected_nodes
----
The API is used to delete unconnected entities from the neo4j database with the input provided as selection from the user.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `unconnected_entities_list`=selected entities list to delete of unconnected entities,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": [],
"message": "Unconnected entities delete successfully"
}
....
=== Get duplicate nodes
----
POST /get_duplicate_nodes
----
The API is used to fetch duplicate entities from database.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": [
{
"e": {
"id": "13 September 2024",
"elementId": "4:b104b2e7-e2ed-4902-b78b-7ad1518ca04f:14007",
"communities": [
2969,
383,
81
],
"labels": [
"__Entity__",
"Date"
],
"embedding": null
},
"similar": [
{
"id": "20 September 2024",
"elementId": "4:b104b2e7-e2ed-4902-b78b-7ad1518ca04f:14153",
"description": null,
"labels": [
"__Entity__",
"Date"
]
}
],
"documents": [],
"chunkConnections": 0
}
],
"message": {
"total": 1
}
}
....
=== Merge duplicate nodes
----
POST /merge_duplicate_nodes
----
The API is used to merge duplicate entities from database selected by user.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `duplicate_nodes_list`= selected entities list to merge of with similar entities,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": [
{
"totalMerged": 2
}
],
"message": "Duplicate entities merged successfully"
}
....
=== Drop and create vector index
----
POST /drop_create_vector_index
----
The API is used to drop and create the vector index when vector index dimesion are different.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `isVectorIndexExist`= True or False based on whether vector index exist in database,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"message": "Drop and Re-Create vector index succesfully"
}
....
=== Reprocessing of sources
----
POST /retry_processing
----
This API is used to reprocess canceled, completed or failed file sources.
Users have 3 options to reprocess files:
* Start from beginning - In this condition file will be processed from the beginning i.e. 1st chunk again.
* Delete entities and start from beginning - If the file source is already processed and has any existing nodes and relationships then those will be deleted and the file will be reprocessed from the 1st chunk.
* Start from the last processed position - Canceled or failed files will be processed from the last successfully processed chunk position. This option is not available for completed files.
* Once the status is set to 'Reprocess', users can again click on Generate Graph to process the file for knowledge graph creation.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `file_name`= Name of the file which user want to Ready to Reprocess.
* `retry_condition` = One of the above 3 conditions which is selected for reprocessing.
* `email`= Logged in User Email,
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"message": "Status set to Ready to Reprocess for filename : $filename"
}
....
=== Evaluate response
----
POST /metric
----
The API responsible for evaluating the chatbot response for the different retrievers on the basis of different metrics
such as faithfulness and answer relevancy. This utilises the RAGAS library to calculate these metrics.
**API Parameters :**
* `question`= User query for the chatbot
* `context`= context retrieved by retrieval mode used for answer generation
* `answer`= answer generated by chatbot
* `model`= LLM model
* `mode`= Retrieval mode used for answer generationRetrieval mode used for answer generation
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"graph_vector_fulltext": {
"faithfulness": 1.0,
"answer_relevancy": 0.9118,
"context_entity_recall": 0.6667
}
}
}
....
=== Evaluate response with ground truth
----
POST /additional_metrics
----
The API responsible for a evaluating chatbot responses on the basis of different metrics such as context entity recall, semantic score, rouge score. This reuqire additional ground truth to be supplied by user. This utilises RAGAS library to calculate these metrics.
**API Parameters :**
* `question`= User query for the chatbot
* `context`= context retrieved by retrieval mode used for answer generation
* `answer`= answer generated by chatbot
* `reference`= ground truth/ expected answer provided by user
* `model`= LLM model
* `mode`= Retrieval mode used for answer generationRetrieval mode used for answer generation
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"graph_vector_fulltext": {
"rouge_score": 1.0,
"semantic_score": 0.9842
}
}
}
....
=== Fetch chunk text
----
POST /fetch_chunktext
----
The API responsible for a fetching text associated with a particular chunk and chunk metadata.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name
* `document_name` = Name of document for which chunks needs to be fetched.
* `page no` = page number for multipage
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"pageitems": [
{
"text": "By T. Albert Illustrated by: maaillustrations.com Science has never been so much fun. Here is all that a child needs to know about water, rain, hail, sleet and water cycle. When Professor Mois Ture teaches- little readers read, learn and ask for more….. Published by Monkey Pen Ltd Dear Supporter, Thank you for downloading our childrens books. Monkey Pens Vision is to provide thousands of free childrens books to young readers around the globe. Please share our books with your friends and family to support our mission. Thank you Please make a donation on Patreon to support Monkey Pens Free Book Project: Hi, I am Professor Mois Ture and I will be telling you about water. You can call it RAIN. You can call it SNOW. You can call it SLEET. You can call it HAIL. But it’s WATER all the same. Did you ever wonder how",
"position": 1,
"pagenumber": 1
},
{
"text": " it HAIL. But it’s WATER all the same. Did you ever wonder how old water is or where it comes from? The answers may surprise you. The next time you see a pond or even a glass of water, think about how old that water might be. Do you really want to know ? I thought you did. Did you brush your teeth this morning? Well, some of the water that you used could have fallen from the sky yesterday, or a week, or month ago. It’s pretty new. But, some part of that water is very old and was around during the time of the dinosaurs, or even longer. Or maybe it’s a little newer; like from the time when the Pharaohs were building pyramids. You see there is only a limited amount of water and it gets recycled. Yep! It keeps going round and round. We call it the “Water Cycle.” Yes – You",
"position": 2,
"pagenumber": 2
}
],
"total_pages": 1
},
"message": "Total elapsed API time 0.48"
}
....
=== Backend Database connection
----
POST /backend_connection_configuation
----
The API responsible for create the connection obj from Neo4j DB based on environment variable and return the status for show/hide login dialog on UI
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": true,
"message": "Backend connection successful"
}
....
=== Visualize graph DB schema
----
POST /schema_visualization
----
User can visualize schema of the db through this API.
**API Parameters :**
* `uri`=Neo4j uri,
* `userName`= Neo4j db username,
* `password`= Neo4j db password,
* `database`= Neo4j database name,
* `email`= Logged in User Email
**Response :**
[source,json,indent=0]
....
{
"status": "Success",
"data": {
"nodes": [
{
"element_id": "-5374",
"labels": [
"Entity"
],
"properties": {
"name": "Entity",
"indexes": [
"id,description"
],
"constraints": []
}
},
],
"relationships": [
{
"element_id": "-44223",
"end_node_element_id": "-5411",
"start_node_element_id": "-5342",
"properties": {
"name": "OWNED"
},
"type": "OWNED"
},
]
},
"message": "Total elapsed API time 3.51"
}
....