Skip to content
Open
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
560 changes: 560 additions & 0 deletions samples/aws-strands-agent/.agent/CLI_REFERENCE.md

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions samples/aws-strands-agent/.agent/REQUIRED_STRUCTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## Required Agent Structure

**IMPORTANT**: All UiPath coded agents MUST follow this standard structure unless explicitly specified otherwise by the user.

### Required Components

Every agent implementation MUST include these two Pydantic models:

```python
from pydantic import BaseModel

class Input(BaseModel):
"""Define input fields that the agent accepts"""
# Add your input fields here
pass

class Output(BaseModel):
"""Define output fields that the agent returns"""
# Add your output fields here
pass
```

### SDK Initialization

```python
from uipath.platform import UiPath

# Initialize with environment variables
uipath = UiPath()

# With explicit credentials
uipath = UiPath(base_url="https://cloud.uipath.com/...", secret="your_token")

# Or with client_id and client_secret
uipath = UiPath(
client_id=UIPATH_CLIENT_ID,
client_secret=UIPATH_CLIENT_SECRET,
scope=UIPATH_SCOPE,
base_url=UIPATH_URL
)
```

### Standard Agent Template

Every agent should follow this basic structure:

```python
from uipath.platform import UiPath
from pydantic import BaseModel

# 1. Define Input, and Output models
class Input(BaseModel):
field: str

class Output(BaseModel):
result: str

# 2. Initialize with environment variables
uipath = UiPath()

# 3. Define the main function (the main function can be named "main", "run" or "execute")
def main(input_data: Input) -> Output:
pass
```
619 changes: 619 additions & 0 deletions samples/aws-strands-agent/.agent/SDK_REFERENCE.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions samples/aws-strands-agent/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OPENAI_API_KEY=<your-api-key-here>
21 changes: 21 additions & 0 deletions samples/aws-strands-agent/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Agent Code Patterns Reference

This document provides practical code patterns for building UiPath coded agents using the UiPath Python SDK.

---

## Documentation Structure

This documentation is split into multiple files for efficient context loading. Load only the files you need:

1. **@.agent/REQUIRED_STRUCTURE.md** - Agent structure patterns and templates
- **When to load:** Creating a new agent or understanding required patterns
- **Contains:** Required Pydantic models (Input, Output), SDK initialization patterns, standard agent template

2. **@.agent/SDK_REFERENCE.md** - Complete SDK API reference
- **When to load:** Calling UiPath SDK methods, working with services (actions, assets, jobs, etc.)
- **Contains:** All SDK services and methods with full signatures and type annotations

3. **@.agent/CLI_REFERENCE.md** - CLI commands documentation
- **When to load:** Working with `uipath init`, `uipath run`, or `uipath eval` commands
- **Contains:** Command syntax, options, usage examples, and workflows
1 change: 1 addition & 0 deletions samples/aws-strands-agent/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
Empty file.
4 changes: 4 additions & 0 deletions samples/aws-strands-agent/bindings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "2.0",
"resources": []
}
31 changes: 31 additions & 0 deletions samples/aws-strands-agent/entry-points.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://cloud.uipath.com/draft/2024-12/entry-point",
"$id": "entry-points.json",
"entryPoints": [
{
"filePath": "agent_function",
"uniqueId": "503902e2-b737-4ee1-85e1-b6536e1d7212",
"type": "agent",
"input": {
"type": "object",
"properties": {
"custom_query": {
"type": "string"
}
},
"required": []
},
"output": {
"type": "object",
"properties": {
"output": {
"type": "string"
}
},
"required": [
"output"
]
}
}
]
}
57 changes: 57 additions & 0 deletions samples/aws-strands-agent/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os

from strands import Agent, tool
from strands_tools import calculator, current_time
from strands.models.openai import OpenAIModel

model = OpenAIModel(
client_args={
"api_key": os.getenv("OPENAI_API_KEY"),
},
model_id="gpt-4o",
params={
"max_tokens": 1000,
"temperature": 0.7,
}
)
from pydantic import BaseModel

class InputModel(BaseModel):
custom_query: str | None = None

class OutputModel(BaseModel):
output: str

@tool
def letter_counter(word: str, letter: str) -> int:
"""
Count occurrences of a specific letter in a word.

Args:
word (str): The input word to search in
letter (str): The specific letter to count

Returns:
int: The number of occurrences of the letter in the word
"""
if not isinstance(word, str) or not isinstance(letter, str):
return 0

if len(letter) != 1:
raise ValueError("The 'letter' parameter must be a single character")

return word.lower().count(letter.lower())

def main(input_model: InputModel) -> OutputModel:
query = """
I have 4 requests:

1. What is the time right now?
2. Calculate 3111696 / 74088
3. Tell me how many letter R's are in the word "strawberry" 🍓
"""
if custom_query := input_model.custom_query:
query = custom_query

agent = Agent(tools=[calculator, current_time, letter_counter], model=model)
return OutputModel(output=str(agent(query).message["content"][0]["text"]))
18 changes: 18 additions & 0 deletions samples/aws-strands-agent/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[project]
name = "uipath-strands-agent"
version = "0.0.8"
description = "UiPath strands coded agent"
readme = "README.md"
requires-python = ">=3.12"
authors = [{ name = "John Doe" }]
dependencies = [
"strands-agents[openai]>=1.19.0",
"strands-agents-builder>=0.1.10",
"strands-agents-tools>=0.2.17",
"uipath>=2.2.28",
]

[dependency-groups]
dev = [
"uipath-dev>=0.0.12",
]
16 changes: 16 additions & 0 deletions samples/aws-strands-agent/uipath.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://cloud.uipath.com/draft/2024-12/uipath",
"runtimeOptions": {
"isConversational": false
},
"packOptions": {
"fileExtensionsIncluded": [],
"filesIncluded": [],
"filesExcluded": [],
"directoriesExcluded": [],
"includeUvLock": true
},
"functions": {
"agent_function": "main.py:main"
}
}
Loading