Skip to content

Commit 32f4d62

Browse files
committed
docs: add llm docs
1 parent 5bb6007 commit 32f4d62

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed

docs/chat_models.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# UiPath chat models
2+
3+
UiPath provides two chat models `UiPathAzureChatOpenAI` and `UiPathNormalizedChatModel`. These are compatible with langgraph as drop in replacements. You do not need to add tokens from OpenAI or Anthropic, usage of these chat models will consume `AI Units` on your account.
4+
5+
## UiPathAzureChatOpenAI
6+
7+
`UiPathAzureChatOpenAI` can be used as a drop in replacement for `ChatOpenAI` or `AzureChatOpenAI`.
8+
9+
### Example usage
10+
11+
Here is a code that is using `ChatOpenAI`
12+
```python
13+
from langchain_openai import ChatOpenAI
14+
15+
llm = ChatOpenAI(
16+
model="gpt-4o",
17+
temperature=0,
18+
max_tokens=None,
19+
timeout=None,
20+
max_retries=2,
21+
# api_key="...", # if you prefer to pass api key in directly instaed of using env vars
22+
# base_url="...",
23+
# organization="...",
24+
# other params...
25+
)
26+
```
27+
28+
You can simply change `ChatOpenAi` with `UiPathAzureChatOpenAI`, you don't have to provide an `OPEN_AI_TOKEN`
29+
30+
31+
```python
32+
from uipath_langchain.chat.models import UiPathAzureChatOpenAI
33+
34+
llm = UiPathAzureChatOpenAI(
35+
model="gpt-4o",
36+
temperature=0,
37+
max_tokens=None,
38+
timeout=None,
39+
max_retries=2,
40+
# other params...
41+
)
42+
```
43+
44+
Currently the following models can be used with `UiPathAzureChatOpenAI` (this list can be updated in the future):
45+
- `gpt-4`, `gpt-4-1106-Preview`, `gpt-4-32k`, `gpt-4-turbo-2024-04-09`, `gpt-4-vision-preview`, `gpt-4o-2024-05-13`, `gpt-4o-2024-08-06`, `gpt-4o-mini-2024-07-18`, `o3-mini-2025-01-31`
46+
47+
48+
## UiPathNormalizedChatModel
49+
50+
`UiPathNormalizedChatModel` is a more versatile clas that can suport models from diferent vendors including OpenAI.
51+
52+
### Example usage
53+
54+
Given the following code:
55+
56+
```python
57+
from langchain_anthropic import ChatAnthropic
58+
59+
llm = ChatAnthropic(
60+
model="claude-3-5-sonnet-20240620",
61+
temperature=0,
62+
max_tokens=1024,
63+
timeout=None,
64+
max_retries=2,
65+
# other params...
66+
)
67+
```
68+
69+
You can replace it with `UiPathNormalizedChatModel` like so:
70+
71+
```python
72+
from uipath_langchain.chat.models import UiPathNormalizedChatModel
73+
74+
llm = UiPathNormalizedChatModel(
75+
model="anthropic.claude-3-opus-20240229-v1:0",
76+
temperature=0,
77+
max_tokens=1024,
78+
timeout=None,
79+
max_retries=2,
80+
# other params...
81+
)
82+
```
83+
84+
Currently the following models can be used with `UiPathAzureChatOpenAI` (this list can be updated in the future):
85+
- `anthropic.claude-3-5-sonnet-20240620-v1:0`, `anthropic.claude-3-5-sonnet-20241022-v2:0`, `anthropic.claude-3-7-sonnet-20250219-v1:0`, `anthropic.claude-3-haiku-20240307-v1:0`, `gemini-1.5-pro-001`, `gemini-2.0-flash-001`, `gpt-4o-2024-05-13`, `gpt-4o-2024-08-06`, `gpt-4o-2024-11-20`, `gpt-4o-mini-2024-07-18`, `o3-mini-2025-01-31`
86+
87+
### Note
88+
89+
Please note that that you may get errors related to data residency, as some models are not available on all regions.
90+
91+
Example: `[Enforced Region] No model configuration found for product uipath-python-sdk in EU using model anthropic.claude-3-opus-20240229-v1:0`.

docs/context_grounding_chain.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ContextGroundingVectorStore
2+
3+
`ContextGroundingVectorStore` is a vector store implementation designed for context-aware document retrieval. It allows you to perform semantic searches and create retrieval chains with language models.
4+
5+
## Initialization
6+
7+
You can initialize the vector store with an index name:
8+
9+
```python
10+
from uipath_langchain.vectorstores.context_grounding_vectorstore import ContextGroundingVectorStore
11+
12+
vectorstore = ContextGroundingVectorStore(index_name=index_name)
13+
```
14+
15+
## Searching Documents
16+
17+
The vector store supports various search methods:
18+
19+
```python
20+
# Perform semantic searches with distance scores
21+
docs_with_scores = await vectorstore.asimilarity_search_with_score(query=query, k=5)
22+
23+
# Perform a similarity search with relevance scores
24+
docs_with_relevance_scores = await vectorstore.asimilarity_search_with_relevance_scores(query=query, k=5)
25+
```
26+
27+
## Creating a Retrieval Chain
28+
29+
You can integrate the vector store into a retrieval chain with a language model:
30+
31+
```python
32+
# Run a retrieval chain
33+
model = UiPathAzureChatOpenAI(model="gpt-4o-2024-08-06", max_retries=3)
34+
retrieval_chain = create_retrieval_chain(vectorstore=vectorstore, model=model)
35+
36+
query = "What is the ECCN for a laptop?"
37+
result = retrieval_chain(query)
38+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Context Grounding Retriever
2+
3+
The `ContextGroundingRetriever` is a document retrieval system that uses vector search to efficiently find and retrieve relevant information from your document store.
4+
5+
## Overview
6+
7+
`ContextGroundingRetriever` allows you to:
8+
- Search through indexed documents using natural language queries
9+
- Ground LLM responses in your organization's specific information
10+
- Retrieve context-relevant documents for various applications
11+
12+
13+
## Basic Usage
14+
15+
Create a simple retriever by specifying an index name:
16+
17+
```python
18+
from uipath_langchain.retrievers import ContextGroundingRetriever
19+
20+
retriever = ContextGroundingRetriever(index_name = "Company Policy Context")
21+
pprint(retriever.invoke("What is the company policy on remote work?"))
22+
```
23+
24+
## Integration with LangChain Tools
25+
26+
You can easily integrate the retriever with LangChain's tool system:
27+
28+
```python
29+
from langchain.tools.retriever import create_retriever_tool
30+
from uipath_langchain.retrievers import ContextGroundingRetriever
31+
32+
retriever = ContextGroundingRetriever(index_name = "Company Policy Context")
33+
retriever_tool = create_retriever_tool(
34+
retriever,
35+
"ContextforInvoiceDisputeInvestigation",
36+
"""
37+
Use this tool to search the company internal documents for information about policies around dispute resolution.
38+
Use a meaningful query to load relevant information from the documents. Save the citation for later use.
39+
"""
40+
)
41+
```
42+
43+
44+
## Advanced Usage
45+
46+
For complex applications, the retriever can be combined with other LangChain components to create robust document QA systems, agents, or knowledge bases.

0 commit comments

Comments
 (0)