Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions 8 samples/calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Simple UiPath Coded Agents

This is a simple, standalone Coded Agent which does not require external dependencies.

After initialization, execute the agent using this sample command:
```
uipath run main.py '{"a": 0, "b": 1, "operator": "+"}'
```
34 changes: 34 additions & 0 deletions 34 samples/calculator/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pydantic.dataclasses import dataclass
from enum import Enum

from uipath.tracing import traced
import logging

logger = logging.getLogger(__name__)

class Operator(Enum):
ADD = "+"
SUBTRACT = "-"
MULTIPLY = "*"
DIVIDE = "/"

@dataclass
class CalculatorInput:
a: float
b: float
operator: Operator

@dataclass
class CalculatorOutput:
result: float

# use InputTriggerEventArgs when called by UiPath EventTriggers
@traced()
def main(input: CalculatorInput) -> CalculatorOutput:
result = 0
match input.operator:
case Operator.ADD: result = input.a + input.b
case Operator.SUBTRACT: result = input.a - input.b
case Operator.MULTIPLY: result = input.a * input.b
case Operator.DIVIDE: result = input.a / input.b if input.b != 0 else 0
return CalculatorOutput(result=result)
9 changes: 9 additions & 0 deletions 9 samples/calculator/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "event-agent"
version = "0.0.1"
description = "calculator-agent"
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
dependencies = [
"uipath>=2.1.43",
]
requires-python = ">=3.10"
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.