The RAG Sample project demonstrates the implementation of a Retrieval-Augmented Generation (RAG) system using UiPath Context Grounding. The system comprises two langchain agents:
- Quiz-Generator-RAG-Agent: Attempts to generate a quiz using the given topic, leveraging only the information obtained through RAG. In case it fails to gather sufficient relevant data, the system might opt to invoke the Researcher-RAG-Agent.
- Researcher-RAG-Agent: Retrieves pertinent information from the Internet based on the provided search instructions and uploads it into a UiPath Context Grounding Index.
The system utilizes LangGraph to create a directed graph of agents that can communicate and share state.
---
---
config:
flowchart:
curve: linear
---
graph TD;
__start__([<p>__start__</p>]):::first
invoke_researcher(invoke_researcher)
create_quiz(create_quiz)
return_quiz(return_quiz)
prepare_input(prepare_input)
__end__([<p>__end__</p>]):::last
__start__ --> prepare_input;
invoke_researcher --> create_quiz;
prepare_input --> create_quiz;
return_quiz --> __end__;
create_quiz -.-> invoke_researcher;
create_quiz -.-> return_quiz;
classDef default fill:#f2f0ff,line-height:1.2
classDef first fill-opacity:0
classDef last fill:#bfb6fc
---
---
config:
flowchart:
curve: linear
---
graph TD;
__start__([<p>__start__</p>]):::first
research(research)
add_data_to_context_grounding_index(add_data_to_context_grounding_index)
prepare_input(prepare_input)
create_file_name(create_file_name)
__end__([<p>__end__</p>]):::last
__start__ --> prepare_input;
add_data_to_context_grounding_index --> __end__;
create_file_name --> research;
prepare_input --> create_file_name;
research --> add_data_to_context_grounding_index;
classDef default fill:#f2f0ff,line-height:1.2
classDef first fill-opacity:0
classDef last fill:#bfb6fc
-
Quiz Generator Agent:
- Receives user topics and executes searches using RAG.
- Decides if there is enough relevant information to generate a quiz.
- May ask Researcher Agent for additional information.
- Returns final quiz to the user, complying to the requested output format (question, difficulty, expected answer).
-
Researcher Agent:
- Retrieves information using a Tavily search tool.
- Uploads the data to a storage bucket (that the Context Grounding Index relies on).
- Triggers the index ingestion.
- Create an Orchestrator Storage Bucket
For this demo we'll create it in the Shared folder.
2. Create a Context Grounding Index
Next, we'll create a Context Grounding Index
When configuring Index General Details, we'll select the previously created storage bucket as data source.
That's it! Next, we'll deploy the agents.
-
Clone the Repository
git clone https://github.com/UiPath/uipath-langchain-python.git
-
Navigate to the Sample Directory
-
Windows:
cd .\uipath-langchain-python\samples\RAG-quiz-generator
-
Unix-like Systems (Linux, macOS):
cd ./uipath-langchain-python/samples/RAG-quiz-generator
-
-
Create and Activate a Virtual Python Environment
pip install uv uv venv -p 3.11 .venv .venv\Scripts\activate # Windows source .venv/bin/activate # Unix-like Systems uv sync
-
Authenticate with UiPath Cloud Platform
uipath auth
Note: After successful authentication in the browser, select the tenant for publishing the agent package.
👇 Select tenant:
0: DefaultTenant
1: Tenant2
2: Tenant3
...
Select tenant: 2
- Package and Publish Agents
uipath pack uipath publish --my-workspace
⠋ Publishing most recent package: RAG-agents.1.0.0.nupkg ...
✓ Package published successfully!
⠇ Getting process information ...
🔗 Process configuration link: [LINK]
💡 Use the link above to configure any environment variables
Note: when publishing to my-workspace a process will be auto-provisioned for you. However, our package contains 2 agents (i.e. 2 entrypoints) thus we'll need to create an additional process.
- Configure Agent Processes in Orchestrator
Follow the returned URL from the publish command:
- Researcher Agent
Make sure researcher-RAG-agent entrypoint is selected, set TAVILY and ANTHROPIC api keys and click on Next.
Note: We can leave everything empty in the input section.
On the package requirements page click Next.
Make sure the process name is researcher-RAG-agent.
- Quiz Generator Agent
Lastly, we need to create the quiz generator agent. Create a new process in my-workspace.
- Run the agents on UiPath Cloud Platform
We can run the agent from Processes page
ℹ️ Here is how we can easily copy any folder path.
- Conclusions
We can monitor our agent execution from the job info panel.
Quiz-generator-RAG-agent may choose to invoke researcher agent multiple times before creating the quiz. The output should look like this:
We can also check the storage bucket content.
This is the information fetched by our researcher agent that the quiz generator used to create the quiz using RAG. We can download this file/files to analyze them.
You can locally debug individual agents by invoking them directly:
Run the researcher agent with:
uipath run researcher-RAG-agent '{"search_instructions":"Need data about spanish cuisine", "index_name":"sample-RAG-index", "index_folder_path":"<index_folder_path>"}'
# or use .json file input
uipath run researcher-RAG-agent -f input.example/researcher-debug-input.jsonNOTE: This assumes that an index named sample-RAG-index is created in the folder identified by the index_folder_path parameter.
Run the quiz generator agent with:
uipath run quiz-generator-RAG-agent '{"quiz_topic":"spanish cuisine", "index_name":"sample-RAG-index", "index_folder_path":"<index_folder_path>"}'
# or use .json file input
uipath run quiz-generator-RAG-agent -f input.example/quiz-generator-debug-input.jsonNOTE: This assumes that an agent named researcher-RAG-agent is created in the folder identified by the folder_path parameter passed to InvokeProcess method.
ℹ️ check researcher-RAG-agent.py file.














