|
| 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 | +``` |
0 commit comments