You can use the InfraNodus API to enhance your existing prompts with the insights obtained from analyzing the underlying context or knowledge base.
This will help your AI RAG workflow have more context for the user's query and retrieve better results.
If you would like to see a visualization of how it works to better understand the logic, you can see our tutorial on augmenting your RAG workflow.
Here are the instructions step by step.
1. Upload Your Knowledge Base / Context to InfraNodus
Upload your knowledge base to InfraNodus, creating a graph from it. Note that you can use InfraNodus to import multiple sources: websites, YouTube channels, PDF documents, and to mix them together.
2. Get an Overview and Write Down the Graph's Name
Make sure that your knowledge base contains all the information you need. You can use our tutorial on optimizing the knowledge base to improve the context. When you're satisfied, copy the name of the graph.
3. Create a POST Request to the InfraNodus API
In your favorite AI tool (Make, n8n, Dify), create a new service / tool that would make a POST request to the following URL:
https://infranodus.com/api/v1/graphAndStatements?doNotSave=true&addStats=true&includeGraphSummary=true&includeGraph=false&includeStatements=false
Note that it's important you have the following parameters added to your POST request link as outlined above:
- doNotSave=true (just generate the graph, do not add new content to InfraNodus)
- addStats=true (you need this for the graph parameters)
- includeGraphSummary=true (you need this to generate a quick outline of the knowledge graph)
Use the following JSON object for your POST request body:
{
"name": "your_graph_name",
"aiTopics": true
}
Remember that you also need to send the API authorization token and the content type in the `headers` section of this POST request:
{
"Content-Type": "application/json",
"Authorization": "Bearer your_api_token_here"
}
This request will return the following JSON object:
{
"entriesAndGraphOfContext": {
"statements": [],
"graph": {},
"graphSummary": "WHAT YOU EXPECT TO SEE HERE"
}
}
You can then use the "entriesAndGraphOfContext.graphSummary" string to augment your AI prompts.
For instance, you can add this to the original user query or system prompt asking the model to make sure it will always retrieve those topics from the original knowledge base.
You also have an option to send the text every time you make a request. In this case, do not specify anything in the "name" field and add the text itself in the "text" field. Then you will be regenerating the graph every time and it won't be saved in your InfraNodus database.
Finally, you also have more data about the underlying knowledge graph if you use the endpoint
https://infranodus.com/api/v1/dotGraphFromText?doNotSave=true&addStats=true&optimize=develop
With the same parameters. It returns condensed information about the graph in addition to the `graphSummary` result about the graph's structure. That may also be useful for you.
Here is an example of how this workflow would look like in Dify:
Note that the InfraNodus enhancer module is a tool based on the POST request above, but you can also use the HTTP request node in Dify to make the request directly.
The flow here is:
1) User starts interaction
2) If / then operator sees if the InfraNodus variable is empty
3) If it is empty, make the InfraNodus request (as above) to retrieve graph insights on the original context
4) Save it into the variable assigner node (so it can be reused in the If / Then condition)
5) Use the output of InfraNodus (or the variable assigner output) to create a prompt that would enrich the original user's query in case it's too general
6) Run knowledge retrieval RAG to extract the most relevant statements
7) Use the output of the RAG search AND the original query AND the InfraNodus-generated insight about the material to generate another prompt that would answer the original query.
8) Output the results
Comments
0 comments
Please sign in to leave a comment.