Skip to content

[WIP] chore: samples use UiPathChat #88

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion samples/RAG-quiz-generator/env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
TAVILY_API_KEY=xxx
ANTHROPIC_API_KEY=xxx

# You can set either ANTHROPIC_API_KEY or USE_UIPATH_AI_UNITS:
# ANTHROPIC_API_KEY=xxx
# or
# USE_UIPATH_AI_UNITS=true
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,33 @@
from uipath_langchain.retrievers import ContextGroundingRetriever
from langchain_anthropic import ChatAnthropic
from langchain_core.documents import Document
from uipath_langchain.chat.models import UiPathChat
import os

class IndexNotFound(Exception):
pass


logger = logging.getLogger(__name__)

llm = ChatAnthropic(model="claude-3-5-sonnet-latest")
if os.getenv("USE_UIPATH_AI_UNITS") and os.getenv("USE_UIPATH_AI_UNITS") == "true":
# other available UiPath chat models
# "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",
llm = UiPathChat(
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
)
else:
llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

class QuizItem(BaseModel):
question: str = Field(
Expand Down
22 changes: 20 additions & 2 deletions samples/RAG-quiz-generator/src/agents/researcher-RAG-agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,32 @@
from uipath import UiPath
from langchain_core.messages import AIMessage, SystemMessage, HumanMessage
from uipath.models import ContextGroundingIndex
from uipath_langchain.chat.models import UiPathChat
import os

uipath = UiPath()
tavily_tool = TavilySearchResults(max_results=5)
anthropic_model = "claude-3-5-sonnet-latest"


llm = ChatAnthropic(model=anthropic_model)

if os.getenv("USE_UIPATH_AI_UNITS") and os.getenv("USE_UIPATH_AI_UNITS") == "true":
# other available UiPath chat models
# "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",
llm = UiPathChat(
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
)
else:
llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

class GraphInput(BaseModel):
search_instructions: str
Expand Down
8 changes: 5 additions & 3 deletions samples/company-research-agent/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
UIPATH_URL=https://alpha.uipath.com/<organization>/<tenant>
UIPATH_ACCESS_TOKEN=YOUR TOKEN HERE
ANTHROPIC_API_KEY=your_anthropic_api_key
TAVILY_API_KEY=your_tavily_api_key

# You can set either ANTHROPIC_API_KEY or USE_UIPATH_AI_UNITS:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these don't need to be commented out since you're in .env.example

# ANTHROPIC_API_KEY=your_anthropic_api_key
# or
# USE_UIPATH_AI_UNITS=true
22 changes: 21 additions & 1 deletion samples/company-research-agent/graph.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os

from langchain_anthropic import ChatAnthropic
from langchain_community.tools.tavily_search import TavilySearchResults
from langgraph.graph import END, START, MessagesState, StateGraph
from langgraph.prebuilt import create_react_agent
from pydantic import BaseModel
from uipath_langchain.chat.models import UiPathChat

# Set up the Tavily search tool
tavily_tool = TavilySearchResults(max_results=5)
Expand Down Expand Up @@ -30,7 +33,24 @@
DO NOT do any math as specified in your instructions.
"""

llm = ChatAnthropic(model="claude-3-5-sonnet-latest")
if os.getenv("USE_UIPATH_AI_UNITS") and os.getenv("USE_UIPATH_AI_UNITS") == "true":
# other available UiPath chat models
# "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",
llm = UiPathChat(
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
)
else:
llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

research_agent = create_react_agent(llm, tools=[tavily_tool], prompt=system_prompt)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
UIPATH_URL=https://alpha.uipath.com/<organization>/<tenant>
UIPATH_ACCESS_TOKEN=YOUR TOKEN HERE
ANTHROPIC_API_KEY=your_anthropic_api_key
TAVILY_API_KEY=your_tavily_api_key

# You can set either ANTHROPIC_API_KEY or USE_UIPATH_AI_UNITS:
# ANTHROPIC_API_KEY=your_anthropic_api_key
# or
# USE_UIPATH_AI_UNITS=true
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
import os
from typing import Annotated

from langchain_anthropic import ChatAnthropic
from langchain_core.tools import tool
from langchain_experimental.utilities import PythonREPL
from langgraph.graph import END, START, MessagesState, StateGraph
from langgraph.prebuilt import create_react_agent
from uipath_langchain.chat.models import UiPathChat
from pydantic import BaseModel

llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

if os.getenv("USE_UIPATH_AI_UNITS") and os.getenv("USE_UIPATH_AI_UNITS") == "true":
# other available UiPath chat models
# "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",
llm = UiPathChat(
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
)
else:
llm = ChatAnthropic(model="claude-3-5-sonnet-latest")
repl = PythonREPL()


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import List, Literal

from langchain_anthropic import ChatAnthropic
Expand All @@ -9,6 +10,7 @@
from pydantic import BaseModel, Field
from typing_extensions import TypedDict
from uipath.models import InvokeProcess
from uipath_langchain.chat.models import UiPathChat

worker_agents = {"researcher": "researcher-agent", "coder": "coder-agent"}
agent_names = list(worker_agents.values())
Expand Down Expand Up @@ -67,8 +69,24 @@ def input(state: GraphInput):
}


llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

if os.getenv("USE_UIPATH_AI_UNITS") and os.getenv("USE_UIPATH_AI_UNITS") == "true":
# other available UiPath chat models
# "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",
llm = UiPathChat(
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
)
else:
llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

async def create_plan(state: State) -> Command:
"""Create an execution plan based on the user's question."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,30 @@
from langchain_community.tools.tavily_search import TavilySearchResults
from langgraph.graph import END, START, MessagesState, StateGraph
from langgraph.prebuilt import create_react_agent
from uipath_langchain.chat.models import UiPathChat
import os
from pydantic import BaseModel

tavily_tool = TavilySearchResults(max_results=5)

llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

if os.getenv("USE_UIPATH_AI_UNITS") and os.getenv("USE_UIPATH_AI_UNITS") == "true":
# other available UiPath chat models
# "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",
llm = UiPathChat(
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
)
else:
llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

research_agent = create_react_agent(
llm, tools=[tavily_tool], prompt="You are a researcher. DO NOT do any math."
Expand Down
6 changes: 5 additions & 1 deletion samples/multi-agent-supervisor-researcher-coder/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
ANTHROPIC_API_KEY=your_anthropic_api_key
TAVILY_API_KEY=your_tavily_api_key

# You can set either ANTHROPIC_API_KEY or USE_UIPATH_AI_UNITS:
# ANTHROPIC_API_KEY=your_anthropic_api_key
# or
# USE_UIPATH_AI_UNITS=true
23 changes: 21 additions & 2 deletions samples/multi-agent-supervisor-researcher-coder/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
from langchain_core.messages import HumanMessage, SystemMessage
from langchain_core.tools import tool
from langchain_experimental.utilities import PythonREPL
from langgraph.graph import END, START, MessagesState, StateGraph
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.prebuilt import create_react_agent
from langgraph.types import Command
from pydantic import BaseModel
from typing_extensions import TypedDict
from uipath_langchain.chat.models import UiPathChat
import os

tavily_tool = TavilySearchResults(max_results=5)

Expand Down Expand Up @@ -51,7 +53,24 @@ class Router(TypedDict):
next: Literal[*options]


llm = ChatAnthropic(model="claude-3-5-sonnet-latest")
if os.getenv("USE_UIPATH_AI_UNITS") and os.getenv("USE_UIPATH_AI_UNITS") == "true":
# other available UiPath chat models
# "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",
llm = UiPathChat(
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
)
else:
llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

class GraphInput(BaseModel):
question: str
Expand Down
Loading