Skip to content

Commit 902d41d

Browse files
feat(documents): add samples
1 parent e59bd33 commit 902d41d

File tree

16 files changed

+2902
-0
lines changed

16 files changed

+2902
-0
lines changed

samples/document-understanding-agent/.agent/CLI_REFERENCE.md

Lines changed: 560 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+
```

samples/document-understanding-agent/.agent/SDK_REFERENCE.md

Lines changed: 565 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Agent Code Patterns Reference
2+
3+
This document provides practical code patterns for building UiPath coded agents using the UiPath Python SDK.
4+
5+
---
6+
7+
## Documentation Structure
8+
9+
This documentation is split into multiple files for efficient context loading. Load only the files you need:
10+
11+
1. **@.agent/REQUIRED_STRUCTURE.md** - Agent structure patterns and templates
12+
- **When to load:** Creating a new agent or understanding required patterns
13+
- **Contains:** Required Pydantic models (Input, Output), SDK initialization patterns, standard agent template
14+
15+
2. **@.agent/SDK_REFERENCE.md** - Complete SDK API reference
16+
- **When to load:** Calling UiPath SDK methods, working with services (actions, assets, jobs, etc.)
17+
- **Contains:** All SDK services and methods with full signatures and type annotations
18+
19+
3. **@.agent/CLI_REFERENCE.md** - CLI commands documentation
20+
- **When to load:** Working with `uipath init`, `uipath run`, or `uipath eval` commands
21+
- **Contains:** Command syntax, options, usage examples, and workflows
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Document Understanding Sample
2+
3+
This sample demonstrates how to use UiPath Document Understanding capabilities with the UiPath Python SDK to classify, extract and validate data from documents.
4+
5+
## Overview
6+
7+
Document Understanding enables automated processing of documents through:
8+
9+
- **Classification**: Identify document types
10+
- **Extraction**: Extract data from classified documents
11+
- **Validation**: Create human-in-the-loop validation actions for review
12+
13+
This sample includes three Document Understanding approaches:
14+
15+
- **IXP (Intelligent Xtraction and Processing)** (`samples/ixp.py`) - [IXP documentation](https://docs.uipath.com/ixp/automation-cloud/latest/overview/introduction)
16+
- **Modern Projects** (`samples/du_modern.py`) - [Modern DU documentation](https://docs.uipath.com/document-understanding/automation-cloud/latest/user-guide/about-document-understanding)
17+
- **Pretrained Models** (`samples/pretrained.py`) - [Pretrained models documentation](https://docs.uipath.com/document-understanding/automation-cloud/latest/user-guide/out-of-the-box-pre-trained-ml-packages)
18+
19+
## Prerequisites
20+
21+
- UiPath Automation Suite or Automation Cloud tenant
22+
- Document Understanding projects deployed with appropriate tags ( [DU Modern publish documentation](https://docs.uipath.com/document-understanding/automation-cloud/latest/user-guide/publish) / [IXP model deployment documentation](https://docs.uipath.com/document-understanding/automation-cloud/latest/user-guide/publish) )
23+
- Action catalog configured for validation actions ( [Actions documentation](https://docs.uipath.com/action-center/automation-cloud/latest/user-guide/about-actions) )
24+
- Storage bucket for validation data ( [Storage buckets documentation](https://docs.uipath.com/orchestrator/automation-cloud/latest/user-guide/about-storage-buckets) )
25+
26+
## Setup
27+
28+
1. **Install dependencies**:
29+
30+
```bash
31+
uv sync
32+
```
33+
34+
2. **Configure UiPath credentials and initialize project**:
35+
36+
```bash
37+
uv run uipath auth
38+
uv run uipath init
39+
```
40+
41+
3. **Update sample parameters**:
42+
43+
Edit the sample files to match your environment:
44+
- Project names and tags
45+
- Document type names
46+
- Action catalog and folder names
47+
- Storage bucket configuration
48+
49+
## Usage
50+
51+
Run the complete sample workflow:
52+
53+
```bash
54+
uv run uipath run main
55+
```
56+
57+
Or run individual samples:
58+
59+
```python
60+
from samples import ixp, du_modern, pretrained
61+
62+
# IXP extraction and validation
63+
ixp.extract_validate()
64+
65+
# Modern project
66+
du_modern.extract_validate()
67+
du_modern.classify_extract_validate()
68+
69+
# Pretrained model
70+
pretrained.extract_validate()
71+
pretrained.classify_extract_validate()
72+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "2.0",
3+
"resources": []
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://cloud.uipath.com/draft/2024-12/entry-point",
3+
"$id": "entry-points.json",
4+
"entryPoints": []
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from src import ixp, du_modern, pretrained
2+
3+
def main():
4+
ixp.extract_validate()
5+
6+
du_modern.extract_validate()
7+
du_modern.classify_extract_validate()
8+
9+
pretrained.extract_validate()
10+
pretrained.classify_extract_validate()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[project]
2+
name = "document-understanding-agent"
3+
version = "0.1.0"
4+
authors = [{ name = "John Doe" }]
5+
description = "Add your description here"
6+
readme = "README.md"
7+
requires-python = ">=3.11"
8+
dependencies = [
9+
"uipath>=2.2.14, <2.3.0",
10+
]

0 commit comments

Comments
 (0)