-
Notifications
You must be signed in to change notification settings - Fork 86
HITL Tutorial: Demonstrate HITL with a Strands Agent #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BharathiSrini
wants to merge
6
commits into
strands-agents:main
Choose a base branch
from
BharathiSrini:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
19a6844
HR Assistant Agent with user confirmation
0ebdba9
HR Assistant using HITL principles
d442748
adding architecture diagram
945fc67
Merge branch 'strands-agents:main' into main
BharathiSrini be81ea3
update region to be picked up from config and set profile to default
47fc366
updating README.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
01-tutorials/01-fundamentals/09-human-in-the-loop/BedrockAgentStack/config.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"agentName": "HRAssistant", | ||
"agentAliasName": "HRAssistantAlias", | ||
"agentModelId": "us.anthropic.claude-3-7-sonnet-20250219-v1:0", | ||
"agentDescription": "An HR assistant that helps employees manage their time off requests", | ||
"agentInstruction": "You are an HR assistant that helps employees check their available time off and submit time off requests. You should be friendly, helpful, and professional. When a user asks about their time off balance, use the getTimeOff function. When a user wants to request time off, use the requestTimeOff function with the start date and number of days they want to take off.", | ||
|
||
"getTimeOffActionGroupName": "GetTimeOffActionGroup", | ||
"getTimeOffActionGroup": "Action group for retrieving employee time off information", | ||
|
||
"requestTimeOffActionGroupName": "RequestTimeOffActionGroup", | ||
"requestTimeOffActionGroup": "Action group for submitting time off requests", | ||
|
||
"func_gettime_name": "getTimeOff", | ||
"func_gettime_description": "Get the current time off balance for the employee", | ||
|
||
"func_createtimeoff_name": "requestTimeOff", | ||
"func_createtimeoff_description": "Submit a time off request for the employee", | ||
"func_createtimeoff_start_date": "startDate", | ||
"func_createtimeoff_number_of_days": "numberOfDays" | ||
} |
91 changes: 91 additions & 0 deletions
91
01-tutorials/01-fundamentals/09-human-in-the-loop/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Strands HR Assistant | ||
|
||
A virtual HR assistant built with the Strands SDK that helps employees manage their time off requests. | ||
|
||
## Features | ||
|
||
- Check time off balance | ||
- Submit time off requests | ||
- Natural language interaction | ||
|
||
## Prerequisites | ||
|
||
- Python 3.10 or higher | ||
- AWS account with access to Amazon Bedrock | ||
- AWS CLI configured with appropriate credentials | ||
|
||
## Installation | ||
|
||
1. Clone the repository: | ||
``` | ||
git clone https://github.com/strands-agents/samples.git | ||
cd strands-samples/01-tutorials/01-fundamentals/09-human-in-the-loop | ||
``` | ||
|
||
2. Create and activate a virtual environment: | ||
``` | ||
python -m venv venv | ||
source venv/bin/activate # On Windows: venv\Scripts\activate | ||
``` | ||
|
||
3. Install the required packages: | ||
``` | ||
pip install -r requirements.txt | ||
``` | ||
|
||
4. Configure AWS credentials: | ||
- Make sure you have the AWS CLI installed and configured with your credentials | ||
- Update the `aws_config.py` file with your AWS region and profile name | ||
|
||
## Configuration | ||
|
||
The HR assistant is configured using the `BedrockAgentStack/config.json` file. You can modify the following settings: | ||
|
||
- `agentName`: The name of the HR assistant | ||
- `agentDescription`: A description of the HR assistant | ||
- `agentInstruction`: Instructions for the HR assistant | ||
- Function names and descriptions | ||
|
||
## Usage | ||
|
||
1. Run the HR assistant: | ||
``` | ||
python hr_assistant.py | ||
``` | ||
|
||
2. Interact with the assistant using natural language: | ||
- "What is my time off balance?" | ||
- "I want to request time off from 2025-07-01 for 5 days" | ||
- "Show me my pending time off requests" | ||
|
||
3. Type 'exit' to quit the assistant. | ||
|
||
## How It Works | ||
|
||
The HR assistant uses the Strands SDK to create an agent with two main functions: | ||
|
||
1. `get_time_off()`: Retrieves the employee's time off balance | ||
2. `request_time_off(start_date, number_of_days)`: Submits a time off request | ||
|
||
The agent uses Amazon Bedrock's Claude model to understand natural language requests and determine when to call these functions. | ||
|
||
## Customization | ||
|
||
You can extend the HR assistant by adding more functions to handle additional HR-related tasks, such as: | ||
|
||
- Checking pay information | ||
- Updating personal details | ||
- Submitting expense reports | ||
- Accessing company policies | ||
|
||
To add a new function, define it using the `@tool` decorator and add it to the agent's tools list in the `create_hr_assistant()` function. | ||
|
||
## Troubleshooting | ||
|
||
- **AWS Credentials Error**: Make sure your AWS credentials are properly configured and you have access to Amazon Bedrock. | ||
- **Model Not Found**: Verify that the model ID in the code matches an available model in your AWS region. | ||
- **Function Not Called**: Ensure that your natural language request clearly indicates which function should be called. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the LICENSE file for details. |
23 changes: 23 additions & 0 deletions
23
01-tutorials/01-fundamentals/09-human-in-the-loop/aws_config.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
AWS configuration for the HR assistant agent. | ||
This file contains the AWS configuration for the Bedrock model. | ||
""" | ||
|
||
import os | ||
import boto3 | ||
from botocore.config import Config | ||
|
||
# AWS configuration | ||
AWS_REGION = os.environ.get('AWS_REGION') # Replace with your AWS region if using a region different from the one set in ~/.aws/config | ||
AWS_PROFILE = "default" # Replace with your AWS profile name | ||
|
||
def get_bedrock_session(): | ||
"""Get a Bedrock client with the configured AWS credentials. | ||
|
||
Returns: | ||
A Bedrock client. | ||
""" | ||
# Configure AWS session | ||
session = boto3.Session(profile_name=AWS_PROFILE, region_name=AWS_REGION) | ||
|
||
return session |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pick up the region dynamically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
picking it from the environment, and allowing user to change to a different region if required.