Skip to content
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
91 changes: 91 additions & 0 deletions docs/chat_models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# UiPath chat models

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.

## UiPathAzureChatOpenAI

`UiPathAzureChatOpenAI` can be used as a drop in replacement for `ChatOpenAI` or `AzureChatOpenAI`.

### Example usage

Here is a code that is using `ChatOpenAI`
```python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
model="gpt-4o",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
# api_key="...", # if you prefer to pass api key in directly instaed of using env vars
# base_url="...",
# organization="...",
# other params...
)
```

You can simply change `ChatOpenAi` with `UiPathAzureChatOpenAI`, you don't have to provide an `OPEN_AI_TOKEN`


```python
from uipath_langchain.chat.models import UiPathAzureChatOpenAI

llm = UiPathAzureChatOpenAI(
model="gpt-4o",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
# other params...
)
```

Currently the following models can be used with `UiPathAzureChatOpenAI` (this list can be updated in the future):
- `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`


## UiPathNormalizedChatModel

`UiPathNormalizedChatModel` is a more versatile clas that can suport models from diferent vendors including OpenAI.

### Example usage

Given the following code:

```python
from langchain_anthropic import ChatAnthropic

llm = ChatAnthropic(
model="claude-3-5-sonnet-20240620",
temperature=0,
max_tokens=1024,
timeout=None,
max_retries=2,
# other params...
)
```

You can replace it with `UiPathNormalizedChatModel` like so:

```python
from uipath_langchain.chat.models import UiPathNormalizedChatModel

llm = UiPathNormalizedChatModel(
model="anthropic.claude-3-opus-20240229-v1:0",
temperature=0,
max_tokens=1024,
timeout=None,
max_retries=2,
# other params...
)
```

Currently the following models can be used with `UiPathAzureChatOpenAI` (this list can be updated in the future):
- `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`

### Note

Please note that that you may get errors related to data residency, as some models are not available on all regions.

Example: `[Enforced Region] No model configuration found for product uipath-python-sdk in EU using model anthropic.claude-3-opus-20240229-v1:0`.
38 changes: 38 additions & 0 deletions docs/context_grounding_chain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ContextGroundingVectorStore

`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.

## Initialization

You can initialize the vector store with an index name:

```python
from uipath_langchain.vectorstores.context_grounding_vectorstore import ContextGroundingVectorStore

vectorstore = ContextGroundingVectorStore(index_name=index_name)
```

## Searching Documents

The vector store supports various search methods:

```python
# Perform semantic searches with distance scores
docs_with_scores = await vectorstore.asimilarity_search_with_score(query=query, k=5)

# Perform a similarity search with relevance scores
docs_with_relevance_scores = await vectorstore.asimilarity_search_with_relevance_scores(query=query, k=5)
```

## Creating a Retrieval Chain

You can integrate the vector store into a retrieval chain with a language model:

```python
# Run a retrieval chain
model = UiPathAzureChatOpenAI(model="gpt-4o-2024-08-06", max_retries=3)
retrieval_chain = create_retrieval_chain(vectorstore=vectorstore, model=model)

query = "What is the ECCN for a laptop?"
result = retrieval_chain(query)
```
46 changes: 46 additions & 0 deletions docs/context_grounding_retriever.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Context Grounding Retriever

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

## Overview

`ContextGroundingRetriever` 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


## Basic Usage

Create a simple retriever by specifying an index name:

```python
from uipath_langchain.retrievers import ContextGroundingRetriever

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

## Integration with LangChain Tools

You can easily integrate the retriever with LangChain's tool system:

```python
from langchain.tools.retriever import create_retriever_tool
from uipath_langchain.retrievers import ContextGroundingRetriever

retriever = ContextGroundingRetriever(index_name = "Company Policy Context")
retriever_tool = create_retriever_tool(
retriever,
"ContextforInvoiceDisputeInvestigation",
"""
Use this tool to search the company internal documents for information about policies around dispute resolution.
Use a meaningful query to load relevant information from the documents. Save the citation for later use.
"""
)
```


## Advanced Usage

For complex applications, the retriever can be combined with other LangChain components to create robust document QA systems, agents, or knowledge bases.
Loading