Skip to content

Commit b79e5a1

Browse files
authored
Merge pull request #34 from UiPath/feat/vectorstore
feat: add retriever and query engine implementations
2 parents d1a7228 + a6a84ec commit b79e5a1

30 files changed

Lines changed: 1208 additions & 34 deletions

docs/context_grounding.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Context Grounding
2+
3+
Context Grounding Service allows you to:
4+
5+
- Search through indexed documents using natural language queries
6+
- Ground LLM responses in your organization's specific information
7+
- Retrieve context-relevant documents for various applications
8+
9+
10+
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.
11+
12+
13+
## ContextGroundingRetriever
14+
15+
The `ContextGroundingRetriever` is a document retrieval system that uses vector search to efficiently find and retrieve relevant information from your document store.
16+
17+
### Basic Usage
18+
19+
Create a simple retriever by specifying an index name:
20+
21+
```python
22+
from uipath_llamaindex.retrievers import ContextGroundingRetriever
23+
24+
retriever = ContextGroundingRetriever(index_name = "Company Policy Context")
25+
print(retriever.retrieve("What is the company policy on remote work?"))
26+
```
27+
28+
## ContextGroundingQueryEngine
29+
30+
Query engines are interfaces that allows you to ask question over your data. The `ContextGroundingQueryEngine` is a query engine system that leverages the `ContextGroundingRetriever`.
31+
32+
### Basic Usage
33+
34+
Create a simple query engine by specifying an index name and a synthesizer strategy:
35+
36+
```python
37+
from uipath_llamaindex.query_engines import ContextGroundingQueryEngine
38+
from llama_index.core.response_synthesizers.type import ResponseMode
39+
from llama_index.core import get_response_synthesizer
40+
41+
synthesizer = get_response_synthesizer(ResponseMode.SIMPLE_SUMMARIZE)
42+
query_engine = ContextGroundingQueryEngine(index_name = "Company Policy Context", response_synthesizer=synthesizer)
43+
print(query_engine.query("What is the company policy on remote work?"))
44+
```
45+
46+
### Integration with LlamaIndex Tools
47+
48+
You can easily integrate the query engine with LlamaIndex's tool system:
49+
50+
```python
51+
from uipath_llamaindex.query_engines import ContextGroundingQueryEngine
52+
from llama_index.core.response_synthesizers.type import ResponseMode
53+
from llama_index.core import get_response_synthesizer
54+
55+
query_engine = ContextGroundingQueryEngine(
56+
index_name="Company Policy Context",
57+
response_synthesizer=get_response_synthesizer(ResponseMode.REFINE),
58+
)
59+
query_engine_tools = [QueryEngineTool(
60+
query_engine=query_engine,
61+
metadata=ToolMetadata(
62+
name="Company policy",
63+
description="Information about general company policy",
64+
)
65+
)]
66+
# You can use the tool in your agents
67+
react_agent = ReActAgent.from_tools(query_engine_tools)
68+
response = react_agent.chat("Answer user questions as best as you can using the query engine tool.")
69+
```
70+
71+
72+
73+
> **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.
51.9 KB
Loading
47.9 KB
Loading
51 KB
Loading
44.8 KB
Loading

docs/sample_images/RAG/indexes.png

32.1 KB
Loading
140 KB
Loading
52.9 KB
Loading
78.9 KB
Loading
34.6 KB
Loading

0 commit comments

Comments
 (0)