Skip to content

feat: add retriever and query engine implementations #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions docs/context_grounding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Context Grounding

Context Grounding Service allows you to:

- Search through indexed documents using natural language queries
- Ground LLM responses in your organization's specific information
- Retrieve context-relevant documents for various applications


You will need to create an index in `Context Grounding` to use this feature. To create an index go to organization `Orchestrator` -> the folder where you'd like to create an index -> `Indexes`. There you can create a new index from a storage bucket which you've added documents to. See the full documentation [here](https://docs.uipath.com/automation-cloud/automation-cloud/latest/admin-guide/about-context-grounding) for more details.


## ContextGroundingRetriever

The `ContextGroundingRetriever` is a document retrieval system that uses vector search to efficiently find and retrieve relevant information from your document store.

### Basic Usage

Create a simple retriever by specifying an index name:

```python
from uipath_llamaindex.retrievers import ContextGroundingRetriever

retriever = ContextGroundingRetriever(index_name = "Company Policy Context")
print(retriever.retrieve("What is the company policy on remote work?"))
```

## ContextGroundingQueryEngine

Query engines are interfaces that allows you to ask question over your data. The `ContextGroundingQueryEngine` is a query engine system that leverages the `ContextGroundingRetriever`.

### Basic Usage

Create a simple query engine by specifying an index name and a synthesizer strategy:

```python
from uipath_llamaindex.query_engines import ContextGroundingQueryEngine
from llama_index.core.response_synthesizers.type import ResponseMode
from llama_index.core import get_response_synthesizer

synthesizer = get_response_synthesizer(ResponseMode.SIMPLE_SUMMARIZE)
query_engine = ContextGroundingQueryEngine(index_name = "Company Policy Context", response_synthesizer=synthesizer)
print(query_engine.query("What is the company policy on remote work?"))
```

### Integration with LlamaIndex Tools

You can easily integrate the query engine with LlamaIndex's tool system:

```python
from uipath_llamaindex.query_engines import ContextGroundingQueryEngine
from llama_index.core.response_synthesizers.type import ResponseMode
from llama_index.core import get_response_synthesizer

query_engine = ContextGroundingQueryEngine(
index_name="Company Policy Context",
response_synthesizer=get_response_synthesizer(ResponseMode.REFINE),
)
query_engine_tools = [QueryEngineTool(
query_engine=query_engine,
metadata=ToolMetadata(
name="Company policy",
description="Information about general company policy",
)
)]
# You can use the tool in your agents
react_agent = ReActAgent.from_tools(query_engine_tools)
response = react_agent.chat("Answer user questions as best as you can using the query engine tool.")
```



> **HINT:** Check our [travel-helper-RAG-agent sample](https://github.com/UiPath/uipath-llamaindex-python/tree/main/samples/travel-helper-RAG-agent) to see context grounding query engines in action.
Binary file added docs/sample_images/RAG/create-index-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sample_images/RAG/create-index-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sample_images/RAG/indexes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sample_images/RAG/job-info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sample_images/RAG/run-process-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sample_images/RAG/run-process-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sample_images/RAG/storage_buckets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sample_images/RAG/traces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-llamaindex"
version = "0.0.25"
version = "0.0.26"
description = "UiPath LlamaIndex SDK"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
Expand Down Expand Up @@ -90,3 +90,4 @@ name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

91 changes: 61 additions & 30 deletions samples/simple-hitl-agent/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading