Skip to content

Commit 5c2f63c

Browse files
committed
chore: add generic agent
1 parent 4218989 commit 5c2f63c

File tree

17 files changed

+5774
-0
lines changed

17 files changed

+5774
-0
lines changed
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
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:** Create uipath.json with input/output schemas and bindings.
18+
19+
**Arguments:**
20+
21+
| Argument | Required | Description |
22+
|----------|----------|-------------|
23+
| `entrypoint` | No | N/A |
24+
25+
**Options:**
26+
27+
| Option | Type | Default | Description |
28+
|--------|------|---------|-------------|
29+
| `--infer-bindings` | flag | false | Infer bindings from the script. |
30+
| `--no-agents-md-override` | flag | false | Won't override existing .agent files and AGENTS.md file. |
31+
32+
**Usage Examples:**
33+
34+
```bash
35+
# Initialize a new agent project
36+
uv run uipath init
37+
38+
# Initialize with specific entrypoint
39+
uv run uipath init main.py
40+
41+
# Initialize and infer bindings from code
42+
uv run uipath init --infer-bindings
43+
```
44+
45+
**When to use:** Run this command when you've modified the Input/Output models and need to regenerate the `uipath.json` schema file.
46+
47+
---
48+
49+
### `uipath run`
50+
51+
**Description:** Execute the project.
52+
53+
**Arguments:**
54+
55+
| Argument | Required | Description |
56+
|----------|----------|-------------|
57+
| `entrypoint` | No | N/A |
58+
| `input` | No | N/A |
59+
60+
**Options:**
61+
62+
| Option | Type | Default | Description |
63+
|--------|------|---------|-------------|
64+
| `--resume` | flag | false | Resume execution from a previous state |
65+
| `-f`, `--file` | value | `Sentinel.UNSET` | File path for the .json input |
66+
| `--input-file` | value | `Sentinel.UNSET` | Alias for '-f/--file' arguments |
67+
| `--output-file` | value | `Sentinel.UNSET` | File path where the output will be written |
68+
| `--trace-file` | value | `Sentinel.UNSET` | File path where the trace spans will be written (JSON Lines format) |
69+
| `--debug` | flag | false | Enable debugging with debugpy. The process will wait for a debugger to attach. |
70+
| `--debug-port` | value | `5678` | Port for the debug server (default: 5678) |
71+
72+
**Usage Examples:**
73+
74+
```bash
75+
# Run agent with inline JSON input
76+
uv run uipath run main.py '{"query": "What is the weather?"}'
77+
78+
# Run agent with input from file
79+
uv run uipath run main.py --file input.json
80+
81+
# Run agent and save output to file
82+
uv run uipath run agent '{"task": "Process data"}' --output-file result.json
83+
84+
# Run agent with debugging enabled
85+
uv run uipath run main.py '{"input": "test"}' --debug --debug-port 5678
86+
87+
# Resume agent execution from previous state
88+
uv run uipath run --resume
89+
```
90+
91+
**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.
92+
93+
---
94+
95+
### `uipath eval`
96+
97+
**Description:** Run an evaluation set against the agent.
98+
99+
Args:
100+
entrypoint: Path to the agent script to evaluate (optional, will auto-discover if not specified)
101+
eval_set: Path to the evaluation set JSON file (optional, will auto-discover if not specified)
102+
eval_ids: Optional list of evaluation IDs
103+
eval_set_run_id: Custom evaluation set run ID (optional, will generate UUID if not specified)
104+
workers: Number of parallel workers for running evaluations
105+
no_report: Do not report the evaluation results
106+
107+
108+
**Arguments:**
109+
110+
| Argument | Required | Description |
111+
|----------|----------|-------------|
112+
| `entrypoint` | No | N/A |
113+
| `eval_set` | No | N/A |
114+
115+
**Options:**
116+
117+
| Option | Type | Default | Description |
118+
|--------|------|---------|-------------|
119+
| `--eval-set-run-id` | value | `Sentinel.UNSET` | Custom evaluation set run ID (if not provided, a UUID will be generated) |
120+
| `--no-report` | flag | false | Do not report the evaluation results |
121+
| `--workers` | value | `1` | Number of parallel workers for running evaluations (default: 1) |
122+
| `--output-file` | value | `Sentinel.UNSET` | File path where the output will be written |
123+
124+
**Usage Examples:**
125+
126+
```bash
127+
# Run evaluation with auto-discovered files
128+
uv run uipath eval
129+
130+
# Run evaluation with specific entrypoint and eval set
131+
uv run uipath eval main.py eval_set.json
132+
133+
# Run evaluation without reporting results
134+
uv run uipath eval --no-report
135+
136+
# Run evaluation with custom number of workers
137+
uv run uipath eval --workers 4
138+
139+
# Save evaluation output to file
140+
uv run uipath eval --output-file eval_results.json
141+
```
142+
143+
**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.
144+
145+
---
146+
147+
### Common Workflows
148+
149+
**1. Creating a New Agent:**
150+
```bash
151+
# Step 1: Initialize project
152+
uv run uipath init
153+
154+
# Step 2: Run agent to test
155+
uv run uipath run main.py '{"input": "test"}'
156+
157+
# Step 3: Evaluate agent performance
158+
uv run uipath eval
159+
```
160+
161+
**2. Development & Testing:**
162+
```bash
163+
# Run with debugging
164+
uv run uipath run main.py '{"input": "test"}' --debug
165+
166+
# Test with input file
167+
uv run uipath run main.py --file test_input.json --output-file test_output.json
168+
```
169+
170+
**3. Schema Updates:**
171+
```bash
172+
# After modifying Input/Output models, regenerate schema
173+
uv run uipath init --infer-bindings
174+
```
175+
176+
### Configuration File (uipath.json)
177+
178+
The `uipath.json` file is automatically generated by `uipath init` and defines your agent's schema and bindings.
179+
180+
**Structure:**
181+
182+
```json
183+
{
184+
"entryPoints": [
185+
{
186+
"filePath": "agent",
187+
"uniqueId": "uuid-here",
188+
"type": "agent",
189+
"input": {
190+
"type": "object",
191+
"properties": { ... },
192+
"description": "Input schema",
193+
"required": [ ... ]
194+
},
195+
"output": {
196+
"type": "object",
197+
"properties": { ... },
198+
"description": "Output schema",
199+
"required": [ ... ]
200+
}
201+
}
202+
],
203+
"bindings": {
204+
"version": "2.0",
205+
"resources": []
206+
}
207+
}
208+
```
209+
210+
**When to Update:**
211+
212+
1. **After Modifying Input/Output Models**: Run `uv run uipath init --infer-bindings` to regenerate schemas
213+
2. **Changing Entry Point**: Update `filePath` if you rename or move your main file
214+
3. **Manual Schema Adjustments**: Edit `input.jsonSchema` or `output.jsonSchema` directly if needed
215+
4. **Bindings Updates**: The `bindings` section maps the exported graph variable - update if you rename your graph
216+
217+
**Important Notes:**
218+
219+
- The `uniqueId` should remain constant for the same agent
220+
- Always use `type: "agent"` for LangGraph agents
221+
- The `jsonSchema` must match your Pydantic models exactly
222+
- Re-run `uipath init --infer-bindings` instead of manual edits when possible
223+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 two 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 Output(BaseModel):
18+
"""Define output fields that the agent returns"""
19+
# Add your output fields here
20+
pass
21+
```
22+
23+
### SDK Initialization
24+
25+
```python
26+
from uipath import UiPath
27+
28+
# Initialize with environment variables
29+
uipath = UiPath()
30+
31+
# With explicit credentials
32+
uipath = UiPath(base_url="https://cloud.uipath.com/...", secret="your_token")
33+
34+
# Or with client_id and client_secret
35+
uipath = UiPath(
36+
client_id=UIPATH_CLIENT_ID,
37+
client_secret=UIPATH_CLIENT_SECRET,
38+
scope=UIPATH_SCOPE,
39+
base_url=UIPATH_URL
40+
)
41+
```
42+
43+
### Standard Agent Template
44+
45+
Every agent should follow this basic structure:
46+
47+
```python
48+
from uipath import UiPath
49+
from pydantic import BaseModel
50+
51+
# 1. Define Input, and Output models
52+
class Input(BaseModel):
53+
field: str
54+
55+
class Output(BaseModel):
56+
result: str
57+
58+
# 2. Initialize with environment variables
59+
uipath = UiPath()
60+
61+
# 3. Define the main function (the main function can be named "main", "run" or "execute")
62+
def main(input_data: Input) -> Output:
63+
pass
64+
```

0 commit comments

Comments
 (0)