Skip to content

Commit 6eaa07b

Browse files
authored
Merge pull request #172 from UiPath/fix/main-py-template
fix: updated uipath new example to use our model endpoints
2 parents 6066248 + a0f5ec6 commit 6eaa07b

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

docs/quick_start.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ Generate your first UiPath LangChain agent:
121121
✓ Created 'main.py' file.
122122
✓ Created 'langgraph.json' file.
123123
✓ Created 'pyproject.toml' file.
124-
🔧 Please ensure to define either ANTHROPIC_API_KEY or OPENAI_API_KEY in your .env file.
125124
💡 Initialize project: uipath init
126125
💡 Run agent: uipath run agent '{"topic": "UiPath"}'
127126
```

src/uipath_langchain/_cli/_templates/main.py.template

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
from langchain_anthropic import ChatAnthropic
21
from langchain_core.messages import HumanMessage, SystemMessage
3-
from langchain_openai import ChatOpenAI
42
from langgraph.graph import START, StateGraph, END
3+
from uipath_langchain.chat import UiPathChat
54
from pydantic import BaseModel
6-
import os
5+
6+
llm = UiPathChat(model="gpt-4o-mini-2024-07-18")
7+
78

89
class GraphState(BaseModel):
910
topic: str
1011

12+
1113
class GraphOutput(BaseModel):
1214
report: str
1315

14-
async def generate_report(state: GraphState) -> GraphOutput:
15-
if os.getenv("ANTHROPIC_API_KEY"):
16-
llm_model = ChatAnthropic(model="claude-3-5-sonnet-latest")
17-
elif os.getenv("OPENAI_API_KEY"):
18-
llm_model = ChatOpenAI(model="gpt-4o-mini", temperature=0)
19-
else:
20-
raise Exception("Missing API Key. Please define either ANTHROPIC_API_KEY or OPENAI_API_KEY.")
2116

17+
async def generate_report(state: GraphState) -> GraphOutput:
2218
system_prompt = "You are a report generator. Please provide a brief report based on the given topic."
23-
output = await llm_model.ainvoke([SystemMessage(system_prompt), HumanMessage(state.topic)])
19+
output = await llm.ainvoke(
20+
[SystemMessage(system_prompt), HumanMessage(state.topic)]
21+
)
2422
return GraphOutput(report=output.content)
2523

24+
2625
builder = StateGraph(GraphState, output=GraphOutput)
2726

2827
builder.add_node("generate_report", generate_report)

src/uipath_langchain/_cli/cli_new.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ def langgraph_new_middleware(name: str) -> MiddlewareResult:
5454
console.success("Created 'langgraph.json' file.")
5555
generate_pyproject(directory, name)
5656
console.success("Created 'pyproject.toml' file.")
57-
console.config(
58-
f""" Please ensure to define either {click.style("ANTHROPIC_API_KEY", fg="bright_yellow")} or {click.style("OPENAI_API_KEY", fg="bright_yellow")} in your .env file. """
59-
)
6057
init_command = """uipath init"""
6158
run_command = """uipath run agent '{"topic": "UiPath"}'"""
6259
console.hint(

0 commit comments

Comments
 (0)