Skip to content

Commit 2deffae

Browse files
committed
feat: llm model overrides
1 parent f35b337 commit 2deffae

19 files changed

Lines changed: 4061 additions & 2 deletions

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.4.24"
3+
version = "0.4.25"
44
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
## CLI Commands Reference
2+
3+
The UiPath Python SDK provides a comprehensive CLI for managing coded agents and automation projects. All commands should be executed with `uv run uipath <command>`.
4+
5+
### Command Overview
6+
7+
| Command | Purpose | When to Use |
8+
|---------|---------|-------------|
9+
| `init` | Initialize agent project | Creating a new agent or updating schema |
10+
| `run` | Execute agent | Running agent locally or testing |
11+
| `eval` | Evaluate agent | Testing agent performance with evaluation sets |
12+
13+
---
14+
15+
### `uipath init`
16+
17+
**Description:** Initialize the project.
18+
19+
**Options:**
20+
21+
| Option | Type | Default | Description |
22+
|--------|------|---------|-------------|
23+
| `--no-agents-md-override` | flag | false | Won't override existing .agent files and AGENTS.md file. |
24+
25+
**Usage Examples:**
26+
27+
```bash
28+
# Initialize a new agent project
29+
uv run uipath init
30+
31+
# Initialize with specific entrypoint
32+
uv run uipath init main.py
33+
34+
# Initialize and infer bindings from code
35+
uv run uipath init --infer-bindings
36+
```
37+
38+
**When to use:** Run this command when you've modified the Input/Output models and need to regenerate the `uipath.json` schema file.
39+
40+
---
41+
42+
### `uipath run`
43+
44+
**Description:** Execute the project.
45+
46+
**Arguments:**
47+
48+
| Argument | Required | Description |
49+
|----------|----------|-------------|
50+
| `entrypoint` | No | N/A |
51+
| `input` | No | N/A |
52+
53+
**Options:**
54+
55+
| Option | Type | Default | Description |
56+
|--------|------|---------|-------------|
57+
| `--resume` | flag | false | Resume execution from a previous state |
58+
| `-f`, `--file` | value | `Sentinel.UNSET` | File path for the .json input |
59+
| `--input-file` | value | `Sentinel.UNSET` | Alias for '-f/--file' arguments |
60+
| `--output-file` | value | `Sentinel.UNSET` | File path where the output will be written |
61+
| `--trace-file` | value | `Sentinel.UNSET` | File path where the trace spans will be written (JSON Lines format) |
62+
| `--state-file` | value | `Sentinel.UNSET` | File path where the state file is stored for persisting execution state. If not provided, a temporary file will be used. |
63+
| `--debug` | flag | false | Enable debugging with debugpy. The process will wait for a debugger to attach. |
64+
| `--debug-port` | value | `5678` | Port for the debug server (default: 5678) |
65+
| `--keep-state-file` | flag | false | Keep the temporary state file even when not resuming and no job id is provided |
66+
67+
**Usage Examples:**
68+
69+
```bash
70+
# Run agent with inline JSON input
71+
uv run uipath run main.py '{"query": "What is the weather?"}'
72+
73+
# Run agent with input from file
74+
uv run uipath run main.py --file input.json
75+
76+
# Run agent and save output to file
77+
uv run uipath run agent '{"task": "Process data"}' --output-file result.json
78+
79+
# Run agent with debugging enabled
80+
uv run uipath run main.py '{"input": "test"}' --debug --debug-port 5678
81+
82+
# Resume agent execution from previous state
83+
uv run uipath run --resume
84+
```
85+
86+
**When to use:** Run this command to execute your agent locally for development, testing, or debugging. Use `--debug` flag to attach a debugger for step-by-step debugging.
87+
88+
---
89+
90+
### `uipath eval`
91+
92+
**Description:** Run an evaluation set against the agent.
93+
94+
Args:
95+
entrypoint: Path to the agent script to evaluate (optional, will auto-discover if not specified)
96+
eval_set: Path to the evaluation set JSON file (optional, will auto-discover if not specified)
97+
eval_ids: Optional list of evaluation IDs
98+
eval_set_run_id: Custom evaluation set run ID (optional, will generate UUID if not specified)
99+
workers: Number of parallel workers for running evaluations
100+
no_report: Do not report the evaluation results
101+
enable_mocker_cache: Enable caching for LLM mocker responses
102+
report_coverage: Report evaluation coverage
103+
model_settings_id: Model settings ID to override agent settings
104+
trace_file: File path where traces will be written in JSONL format
105+
max_llm_concurrency: Maximum concurrent LLM requests
106+
input_overrides: Input field overrides mapping (direct field override with deep merge)
107+
resume: Resume execution from a previous suspended state
108+
109+
110+
**Arguments:**
111+
112+
| Argument | Required | Description |
113+
|----------|----------|-------------|
114+
| `entrypoint` | No | N/A |
115+
| `eval_set` | No | N/A |
116+
117+
**Options:**
118+
119+
| Option | Type | Default | Description |
120+
|--------|------|---------|-------------|
121+
| `--eval-set-run-id` | value | `Sentinel.UNSET` | Custom evaluation set run ID (if not provided, a UUID will be generated) |
122+
| `--no-report` | flag | false | Do not report the evaluation results |
123+
| `--workers` | value | `1` | Number of parallel workers for running evaluations (default: 1) |
124+
| `--output-file` | value | `Sentinel.UNSET` | File path where the output will be written |
125+
| `--enable-mocker-cache` | flag | false | Enable caching for LLM mocker responses |
126+
| `--report-coverage` | flag | false | Report evaluation coverage |
127+
| `--model-settings-id` | value | `"default"` | Model settings ID from evaluation set to override agent settings (default: 'default') |
128+
| `--trace-file` | value | `Sentinel.UNSET` | File path where traces will be written in JSONL format |
129+
| `--max-llm-concurrency` | value | `20` | Maximum concurrent LLM requests (default: 20) |
130+
| `--resume` | flag | false | Resume execution from a previous suspended state |
131+
132+
**Usage Examples:**
133+
134+
```bash
135+
# Run evaluation with auto-discovered files
136+
uv run uipath eval
137+
138+
# Run evaluation with specific entrypoint and eval set
139+
uv run uipath eval main.py eval_set.json
140+
141+
# Run evaluation without reporting results
142+
uv run uipath eval --no-report
143+
144+
# Run evaluation with custom number of workers
145+
uv run uipath eval --workers 4
146+
147+
# Save evaluation output to file
148+
uv run uipath eval --output-file eval_results.json
149+
```
150+
151+
**When to use:** Run this command to test your agent's performance against a predefined evaluation set. This helps validate agent behavior and measure quality metrics.
152+
153+
---
154+
155+
### Common Workflows
156+
157+
**1. Creating a New Agent:**
158+
```bash
159+
# Step 1: Initialize project
160+
uv run uipath init
161+
162+
# Step 2: Run agent to test
163+
uv run uipath run main.py '{"input": "test"}'
164+
165+
# Step 3: Evaluate agent performance
166+
uv run uipath eval
167+
```
168+
169+
**2. Development & Testing:**
170+
```bash
171+
# Run with debugging
172+
uv run uipath run main.py '{"input": "test"}' --debug
173+
174+
# Test with input file
175+
uv run uipath run main.py --file test_input.json --output-file test_output.json
176+
```
177+
178+
**3. Schema Updates:**
179+
```bash
180+
# After modifying Input/Output models, regenerate schema
181+
uv run uipath init --infer-bindings
182+
```
183+
184+
### Configuration File (uipath.json)
185+
186+
The `uipath.json` file is automatically generated by `uipath init` and defines your agent's schema and bindings.
187+
188+
**Structure:**
189+
190+
```json
191+
{
192+
"entryPoints": [
193+
{
194+
"filePath": "agent",
195+
"uniqueId": "uuid-here",
196+
"type": "agent",
197+
"input": {
198+
"type": "object",
199+
"properties": { ... },
200+
"description": "Input schema",
201+
"required": [ ... ]
202+
},
203+
"output": {
204+
"type": "object",
205+
"properties": { ... },
206+
"description": "Output schema",
207+
"required": [ ... ]
208+
}
209+
}
210+
],
211+
"bindings": {
212+
"version": "2.0",
213+
"resources": []
214+
}
215+
}
216+
```
217+
218+
**When to Update:**
219+
220+
1. **After Modifying Input/Output Models**: Run `uv run uipath init --infer-bindings` to regenerate schemas
221+
2. **Changing Entry Point**: Update `filePath` if you rename or move your main file
222+
3. **Manual Schema Adjustments**: Edit `input.jsonSchema` or `output.jsonSchema` directly if needed
223+
4. **Bindings Updates**: The `bindings` section maps the exported graph variable - update if you rename your graph
224+
225+
**Important Notes:**
226+
227+
- The `uniqueId` should remain constant for the same agent
228+
- Always use `type: "agent"` for LangGraph agents
229+
- The `jsonSchema` must match your Pydantic models exactly
230+
- Re-run `uipath init --infer-bindings` instead of manual edits when possible
231+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
## Required Agent Structure
2+
3+
**IMPORTANT**: All UiPath coded agents MUST follow this standard structure unless explicitly specified otherwise by the user.
4+
5+
### Required Components
6+
7+
Every agent implementation MUST include these three Pydantic models:
8+
9+
```python
10+
from pydantic import BaseModel
11+
12+
class Input(BaseModel):
13+
"""Define input fields that the agent accepts"""
14+
# Add your input fields here
15+
pass
16+
17+
class State(BaseModel):
18+
"""Define the agent's internal state that flows between nodes"""
19+
# Add your state fields here
20+
pass
21+
22+
class Output(BaseModel):
23+
"""Define output fields that the agent returns"""
24+
# Add your output fields here
25+
pass
26+
```
27+
28+
### Required LLM Initialization
29+
30+
Unless the user explicitly requests a different LLM provider, always use `UiPathChat`:
31+
32+
```python
33+
from uipath_langchain.chat import UiPathChat
34+
35+
llm = UiPathChat(model="gpt-4.1-mini-2025-04-14", temperature=0.7)
36+
```
37+
38+
**Alternative LLMs** (only use if explicitly requested):
39+
- `ChatOpenAI` from `langchain_openai`
40+
- `ChatAnthropic` from `langchain_anthropic`
41+
- Other LangChain-compatible LLMs
42+
43+
### Standard Agent Template
44+
45+
Every agent should follow this basic structure:
46+
47+
```python
48+
from langchain_core.messages import SystemMessage, HumanMessage
49+
from langgraph.graph import START, StateGraph, END
50+
from uipath_langchain.chat import UiPathChat
51+
from pydantic import BaseModel
52+
53+
# 1. Define Input, State, and Output models
54+
class Input(BaseModel):
55+
field: str
56+
57+
class State(BaseModel):
58+
field: str
59+
result: str = ""
60+
61+
class Output(BaseModel):
62+
result: str
63+
64+
# 2. Initialize UiPathChat LLM
65+
llm = UiPathChat(model="gpt-4.1-mini-2025-04-14", temperature=0.7)
66+
67+
# 3. Define agent nodes (async functions)
68+
async def process_node(state: State) -> State:
69+
response = await llm.ainvoke([HumanMessage(state.field)])
70+
return State(field=state.field, result=response.content)
71+
72+
async def output_node(state: State) -> Output:
73+
return Output(result=state.result)
74+
75+
# 4. Build the graph
76+
builder = StateGraph(State, input=Input, output=Output)
77+
builder.add_node("process", process_node)
78+
builder.add_node("output", output_node)
79+
builder.add_edge(START, "process")
80+
builder.add_edge("process", "output")
81+
builder.add_edge("output", END)
82+
83+
# 5. Compile the graph
84+
graph = builder.compile()
85+
```
86+
87+
**Key Rules**:
88+
1. Always use async/await for all node functions
89+
2. All nodes (except output) must accept and return `State`
90+
3. The final output node must return `Output`
91+
4. Use `StateGraph(State, input=Input, output=Output)` for initialization
92+
5. Always compile with `graph = builder.compile()`

0 commit comments

Comments
 (0)