Skip to content

Commit 8afad4f

Browse files
committed
feat: complex open ai sample
1 parent 90c4aad commit 8afad4f

26 files changed

Lines changed: 6309 additions & 0 deletions

packages/uipath-openai-agents/samples/company_agent/.agent/CLI_REFERENCE.md

Lines changed: 618 additions & 0 deletions
Large diffs are not rendered by default.
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.platform 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.platform 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+
```

packages/uipath-openai-agents/samples/company_agent/.agent/SDK_REFERENCE.md

Lines changed: 680 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
---
2+
allowed-tools: Bash, Read, Write, Edit, Glob
3+
description: Create and run agent evaluations
4+
---
5+
6+
I'll help you create and run evaluations for your UiPath agent.
7+
8+
## Step 1: Check project setup
9+
10+
Let me check your project structure:
11+
12+
!ls -la evaluations/ entry-points.json 2>/dev/null || echo "NEEDS_SETUP"
13+
14+
# Check if schemas might be stale (main.py newer than entry-points.json)
15+
!if [ -f main.py ] && [ -f entry-points.json ] && [ main.py -nt entry-points.json ]; then echo "SCHEMAS_MAY_BE_STALE"; fi
16+
17+
### If NEEDS_SETUP
18+
19+
If `entry-points.json` doesn't exist, initialize the project first:
20+
21+
!uv run uipath init
22+
23+
Then re-run this skill.
24+
25+
### If SCHEMAS_MAY_BE_STALE
26+
27+
Your `main.py` is newer than `entry-points.json`. Refresh schemas:
28+
29+
!uv run uipath init --no-agents-md-override
30+
31+
## Step 2: What would you like to do?
32+
33+
1. **Create new eval set** - Set up evaluations from scratch
34+
2. **Add test case** - Add a test to existing eval set
35+
3. **Run evaluations** - Execute tests and see results
36+
4. **Analyze failures** - Debug failing tests
37+
38+
---
39+
40+
## Creating an Eval Set
41+
42+
First, create the directory structure:
43+
44+
!mkdir -p evaluations/eval-sets evaluations/evaluators
45+
46+
Read the agent's Input/Output schema from entry-points.json to understand the data types.
47+
48+
### Evaluator Selection Guide
49+
50+
| If your output is... | Use this evaluator | evaluatorTypeId |
51+
|---------------------|-------------------|-----------------|
52+
| Exact string/number | `ExactMatchEvaluator` | `uipath-exact-match` |
53+
| Contains key phrases | `ContainsEvaluator` | `uipath-contains` |
54+
| Semantically correct | `LLMJudgeOutputEvaluator` | `uipath-llm-judge-output-semantic-similarity` |
55+
| JSON with numbers | `JsonSimilarityEvaluator` | `uipath-json-similarity` |
56+
57+
### Step 1: Create Evaluator Config Files
58+
59+
**Each evaluator needs a JSON config file** in `evaluations/evaluators/`.
60+
61+
**ExactMatchEvaluator** (`evaluations/evaluators/exact-match.json`):
62+
```json
63+
{
64+
"version": "1.0",
65+
"id": "ExactMatchEvaluator",
66+
"name": "ExactMatchEvaluator",
67+
"description": "Checks for exact output match",
68+
"evaluatorTypeId": "uipath-exact-match",
69+
"evaluatorConfig": {
70+
"name": "ExactMatchEvaluator",
71+
"targetOutputKey": "*"
72+
}
73+
}
74+
```
75+
76+
**LLMJudgeOutputEvaluator** (`evaluations/evaluators/llm-judge-output.json`):
77+
```json
78+
{
79+
"version": "1.0",
80+
"id": "LLMJudgeOutputEvaluator",
81+
"name": "LLMJudgeOutputEvaluator",
82+
"description": "Uses LLM to judge semantic similarity",
83+
"evaluatorTypeId": "uipath-llm-judge-output-semantic-similarity",
84+
"evaluatorConfig": {
85+
"name": "LLMJudgeOutputEvaluator",
86+
"model": "gpt-4o-mini-2024-07-18"
87+
}
88+
}
89+
```
90+
91+
**JsonSimilarityEvaluator** (`evaluations/evaluators/json-similarity.json`):
92+
```json
93+
{
94+
"version": "1.0",
95+
"id": "JsonSimilarityEvaluator",
96+
"name": "JsonSimilarityEvaluator",
97+
"description": "Compares JSON structures",
98+
"evaluatorTypeId": "uipath-json-similarity",
99+
"evaluatorConfig": {
100+
"name": "JsonSimilarityEvaluator",
101+
"targetOutputKey": "*"
102+
}
103+
}
104+
```
105+
106+
**ContainsEvaluator** (`evaluations/evaluators/contains.json`):
107+
```json
108+
{
109+
"version": "1.0",
110+
"id": "ContainsEvaluator",
111+
"name": "ContainsEvaluator",
112+
"description": "Checks if output contains text",
113+
"evaluatorTypeId": "uipath-contains",
114+
"evaluatorConfig": {
115+
"name": "ContainsEvaluator"
116+
}
117+
}
118+
```
119+
120+
### Step 2: Create Eval Set
121+
122+
**Eval Set Template** (`evaluations/eval-sets/default.json`):
123+
```json
124+
{
125+
"version": "1.0",
126+
"id": "default-eval-set",
127+
"name": "Default Evaluation Set",
128+
"evaluatorRefs": ["ExactMatchEvaluator"],
129+
"evaluations": [
130+
{
131+
"id": "test-1",
132+
"name": "Test description",
133+
"inputs": {
134+
"field": "value"
135+
},
136+
"evaluationCriterias": {
137+
"ExactMatchEvaluator": {
138+
"expectedOutput": {
139+
"result": "expected value"
140+
}
141+
}
142+
}
143+
}
144+
]
145+
}
146+
```
147+
148+
**Important notes:**
149+
- `evaluatorRefs` must list ALL evaluators used in any test case
150+
- Each evaluator in `evaluatorRefs` needs a matching JSON config in `evaluations/evaluators/`
151+
- `evaluationCriterias` keys must match entries in `evaluatorRefs`
152+
- Use `expectedOutput` for most evaluators
153+
- LLM evaluators need `model` in their config. Available models are defined in the SDK's `ChatModels` class (`uipath.platform.chat.ChatModels`):
154+
- `gpt-4o-mini-2024-07-18` (recommended for cost-efficiency)
155+
- `gpt-4o-2024-08-06` (higher quality, higher cost)
156+
- `o3-mini-2025-01-31` (latest reasoning model)
157+
- Model availability varies by region and tenant configuration
158+
- Check your UiPath Automation Cloud portal under AI Trust Layer for available models in your region
159+
160+
---
161+
162+
## Adding a Test Case
163+
164+
When adding a test to an existing eval set:
165+
166+
1. Read the existing eval set
167+
2. Check which evaluators are in `evaluatorRefs`
168+
3. Add the new test to `evaluations` array
169+
4. If using a new evaluator, add it to `evaluatorRefs`
170+
171+
### Test Case Template
172+
173+
```json
174+
{
175+
"id": "test-{n}",
176+
"name": "Description of what this tests",
177+
"inputs": { },
178+
"evaluationCriterias": {
179+
"EvaluatorName": {
180+
"expectedOutput": { }
181+
}
182+
}
183+
}
184+
```
185+
186+
---
187+
188+
## Running Evaluations
189+
190+
First, read entry-points.json to get the entrypoint name (e.g., `main`):
191+
192+
!uv run uipath eval main evaluations/eval-sets/default.json --output-file eval-results.json
193+
194+
**Note:** Replace `main` with your actual entrypoint from entry-points.json.
195+
196+
### Analyze Results
197+
198+
After running, read `eval-results.json` and show:
199+
- Pass/fail summary table
200+
- For failures: expected vs actual output
201+
- Suggestions for fixing or changing evaluators
202+
203+
### Results Format
204+
205+
```json
206+
{
207+
"evaluationSetResults": [{
208+
"evaluationRunResults": [
209+
{
210+
"evaluationId": "test-1",
211+
"evaluatorId": "ExactMatchEvaluator",
212+
"result": { "score": 1.0 },
213+
"errorMessage": null
214+
}
215+
]
216+
}]
217+
}
218+
```
219+
220+
- Score 1.0 = PASS
221+
- Score < 1.0 = FAIL (show expected vs actual)
222+
- errorMessage present = ERROR (show message)
223+
224+
---
225+
226+
## Evaluator Reference
227+
228+
### Deterministic Evaluators
229+
230+
**ExactMatchEvaluator** - Exact output matching
231+
```json
232+
"ExactMatchEvaluator": {
233+
"expectedOutput": { "result": "exact value" }
234+
}
235+
```
236+
237+
**ContainsEvaluator** - Output contains substring
238+
```json
239+
"ContainsEvaluator": {
240+
"searchText": "must contain this"
241+
}
242+
```
243+
244+
**JsonSimilarityEvaluator** - JSON comparison with tolerance
245+
```json
246+
"JsonSimilarityEvaluator": {
247+
"expectedOutput": { "value": 10.0 }
248+
}
249+
```
250+
251+
### LLM-Based Evaluators
252+
253+
**LLMJudgeOutputEvaluator** - Semantic correctness
254+
```json
255+
"LLMJudgeOutputEvaluator": {
256+
"expectedOutput": { "summary": "Expected semantic meaning" }
257+
}
258+
```
259+
260+
**LLMJudgeTrajectoryEvaluator** - Validate agent reasoning
261+
```json
262+
"LLMJudgeTrajectoryEvaluator": {
263+
"expectedAgentBehavior": "The agent should first fetch data, then process it"
264+
}
265+
```
266+
267+
---
268+
269+
## Common Issues
270+
271+
### "No evaluations found"
272+
- Check `evaluations/eval-sets/` directory exists
273+
- Verify JSON file is valid
274+
275+
### Evaluator not found
276+
- Each evaluator needs a JSON config file in `evaluations/evaluators/`
277+
- Config file must have correct `evaluatorTypeId` (see templates above)
278+
- Config file must have `name` field at root level
279+
- LLM evaluators need `model` in `evaluatorConfig`
280+
281+
### Evaluator skipped
282+
- Ensure evaluator is listed in root `evaluatorRefs` array
283+
- Check evaluator config file exists in `evaluations/evaluators/`
284+
285+
### Schema mismatch
286+
- Run `uv run uipath init --no-agents-md-override` to refresh schemas
287+
- Check `entry-points.json` matches your Input/Output models

0 commit comments

Comments
 (0)