InfraNodus can be used to build an advanced AI Q&A chatbot that will generate interesting research questions, conversation starters, and prompts that can be further integrated into an LLM workflow. In this example, we will demonstrate how you can do this using Dify — an open-source, no-code LLM app creation studio.
You can then embed this chatbot on any website or make it available via a public-facing link.
With this workflow, you can upload your knowledge base, research papers, or a whole website to InfraNodus, and it will be represented as a graph. This graph structure will be used to identify the blind spots and the gaps in the narrative. Based on those gaps, InfraNodus API will generate interesting research questions that bridge the topics that are not well connected and come up with innovative ideas.
You can use these questions as
1) conversation starter suggestions for the end-users of your chatbot
2) ideas to develop this content further (e.g. for product ideas or research)
2) prompts for your AI models / agents to ideate on top of an existing knowledge base or content
You can then integrate the responses into your Dify custom chatbot so that your users can interact with your knowledge base using an embeddable chat directly from your website or build a more complex workflow where the questions generated by InfraNodus are further processed by an LLM application or agent of your choice.
This application can be very interesting for making the model develop a new idea based on a collection of research papers or to prompt a model to come up with a new business idea based on your own or your competitors' website.
Here is how it works:
Step 1: Generate a knowledge graph using InfraNodus
For this example, we will ingest this whole support portal — https://support.noduslabs.com. This can be done using InfraNodus' own URL import tool or with an external tool like Firecrawl that can scrape the whole website and save the data as MD (markdown) files, which can then be imported into Infranodus.
As a result, we will get a graph that will look something like this:
Note how this graph allows us to have a general overview of the knowledge base: the concepts and topics inside, their relations, and gaps between them. Something we cannot do with any other existing RAG system.
Step 2: Optimize your knowledge base
The next important step is to optimize the knowledge base. Note how the Topical Diversity field in the Analytics Panel is ranked as Low (modularity 0.36).
This means that currently the knowledge base is too biased towards the central concepts. It is focused too much on such concepts as "graph" and "infranodus", which will make the responses generated with it too generic.
A great way to optimize the original graph is to delete some of the top concepts, so we give more importance to the ideas that hide underneath. Just select those nodes, delete them from the graph, and then add them to the permanent stopwords list:
Once we delete all the unnecessary concepts that are too general, we will get to a graph that looks like this:
As you can see, the topical diversity measure now is "Focused" (so it is closer to optimal) and therefore we can start using this knowledge graph for generating responses.
Step 3: Create a Dify AI chatbot workflow that integrates InfraNodus question generator
In order to use Dify, you can create an account on their website or install your own open-source version using a service like Elest.io.
Once you set up an account, go to Studio > Chatbot > Create Blank and create your advanced chatbot workflow.
Once inside the chatbot builder, we need to set up the following workflow:
1) A starter node is used to begin the conversation. We use a "conversation opener" in Dify to give users an option to auto-generate a question.
2) If the user clicked "Generate a Question", InfraNodus API will generate a question for the user that will be based on the structural gap detected in content (directed to the HTTP request node in Dify).
3) If the user just typed in a question, it will be used as a prompt and will be forwarded to the InfraNodus API and it will respond to the question (directed to the GraphAndAdvice_Post custom tool in Dify)
4) When the response is generated, the user can continue the conversation by elaborating on the topic further.
Here is the structure of the workflow:
Here is how you can set this workflow up, step by step. This workflow uses InfraNodus' GraphRAG for open-ended queries that may follow automatically generated question content. For simplicity, you can also use this yml file and auto-generate this flow with Studio > Import from YML file: https://github.com/infranodus/dify-infranodus/blob/main/generate-questions-infranodus-only.yml
Note that there is an alternative workflow, which forwards the open-ended question to the knowledge base inside Dify itself and uses its RAG, rather than InfraNodus' GraphRAG for information retrieval: https://github.com/infranodus/dify-infranodus/blob/main/generate-questions-knowledge-base.yml
The chatbot made using the InfraNodus GraphRAG is available at https://aistudio.infranodus.com/chat/MoCUl5Exvdr8mcnC
The chatbot made based on the standard RAG is available here: https://aistudio.infranodus.com/chat/MCMNnbYHFrgKMreu
You can choose any of the workflows above. The original GraphRAG provides more comprehensive responses but works slightly slower than the RAG one, which is, however, slightly harder to set up because you'll need to create an additional RAG knowledge base in your Dify studio.
Below we explain how you can set up both.
Setting up the Dify LLM chatbot workflow:
Sub-step 1: Adding an HTTP request node for question generation
Add an HTTP request node that will query the InfraNodus API using the schema described here: https://github.com/infranodus/dify-infranodus/blob/main/graphAndAdvice-openapi-schema.json
We will use this HTTP request node to generate questions based on the original content.
The POST request URL would look something like this (include all the URL query parameters):
https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&addStats=true&optimize=gap&includeGraphSummary=true&includeGraph=false
The content of the POST request (POST request body) would be:
{
"requestMode": "question",
"modelToUse": "gpt-4o-mini",
"name": "support_nodus_labs", // provide your existing infranodus graph name here
"aiTopics": "true"
}
Sub-step 2: Add a default conversation starter to auto-generate questions
Add a Conversation Starter in the chat's Features panel that says "Generate a Question". When the chat opens to the end user, they will be able to click this button to automatically generate a question with InfraNodus. If they don't generate a question, they can ask a free-form question, which will be forwarded to InfraNodus as a prompt.
Sub-step 3: Use the IF/ELSE node to direct the workflow
Add the IF/ELSE node that will check the value of sys.query from the Starter node. If it's the default value "Generate a Question" then the request is forwarded to the HTTP node, which will then generate a question using the InfraNodus API. If it's anything else, the request itself — `sys.query` — will be forwarded to the custom knowledge retrieval tool described below, which can either be InfraNodus' custom graphRAG AI advice retrieval tool or Dify's own knowledge base:
Sub-step 4: Add a node for treating open-ended user queries
Now is a good moment to decide on how the open-ended questions will be treated.
There are two options to do this.
a) Using Dify's RAG knowledge base.
You can use Dify's own knowledge base. In that case, you will need to create a new knowledge base with the same content in Dify and then direct the user's request (or the InfraNodus auto-generated question) to the Knowledge Base node that links to that knowledge you created. In that case, it will use Dify's native RAG (retrieval-augmented generation). You can also choose to improve the original user's prompt using the InfraNodus Dify workflow we described in another tutorial. In that case, your workflow would look something like this:
You can download the YML file for that workflow here: https://github.com/infranodus/dify-infranodus/blob/main/generate-questions-knowledge-base.yml
b) using InfraNodus' GraphRAG knowledge base
You can use InfraNodus' GraphRAG knowledge base to generate the responses to auto-generated or open-ended queries from users. In that case, you don't need to create an additional knowledge base in Dify, however because the answer generation is more computationally challenging, responses will take longer.
To generate the responses using the InfraNodus GraphRAG, create a Custom Tool in Tools > Custom > Create Custom Tool and paste the OpenAPI schema for graphAndAdvice InfraNodus API endpoint to create a custom tool.
We will use this custom tool for processing open-ended queries made by the user. So after the tool is created, we will link it to the IF/THEN node on the condition where the `sys.query` is anything but the default conversation starter.
Once the question is generated, it's assigned to an environmental variable using Assigner nodes and then the Answer node shows that question.
As you can see on the workflow, we also use variable assigners and JSON aggregators in order to store the results of the text processed the first time in order to reduce the waiting time when the answer is generated:
You can try to connect the HTTP node and the InfraNodus tool node directly to the Answer node, however, if you experience difficulting converting the responses to the appropriate easy-to-read text format, you can use the intermediary CONVERT nodes and CODE nodes in our flow to parse the results.
It is easiest to simply get those from the YML file we created for this workflow here: https://github.com/infranodus/dify-infranodus/blob/main/generate-questions-infranodus-only.yml
Sub-step 5: Test the user interaction flow and publish the chatbot
Once you're done, launch the workflow and click "Genenerate a Question".
Once the question is generated, you can think of an answer to this question or simply copy and paste that question back to the chat to generate a response from the original content we're using.
As the InfraNodus result is already generated, the question now goes to the knowledge base and uses traditional RAG to extract the response if you chose to use Dify's own knowledge base.
If you chose InfraNodus' GraphAndAdvice tool, the question will go to InfraNodus' own system, which will generate a response for you based on the underlying knowledge graph structure.
You can then click "Generate a Question" again to generate another question or continue interacting with the model based on the conversation you're already having.
Possible use cases include:
- An interactive chatbot for developing a scientific discourse
- Brainstorming tool for an organization based on your own knowledge base
- Ideation for new product ideas based on the company's support portal
To try it live:
The chatbot made using the InfraNodus GraphRAG is available at https://aistudio.infranodus.com/chat/MoCUl5Exvdr8mcnC
The chatbot made based on the standard RAG is available here: https://aistudio.infranodus.com/chat/MCMNnbYHFrgKMreu
...
If you like what you see, you can create you own chatbot with InfraNodus and Dify if you create an account on https://infranodus.com and then use Dify to set up the workflow. If you prefer, you can install your own open-source version of Dify using Elest.io.
...
Comments
0 comments
Please sign in to leave a comment.