Skip to content

Commit b04f449

Browse files
committed
update README
1 parent 83e25ad commit b04f449

File tree

15 files changed

+243
-12
lines changed

15 files changed

+243
-12
lines changed

.DS_Store

6 KB
Binary file not shown.

egrid_ai_agent/.DS_Store

6 KB
Binary file not shown.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
Metadata-Version: 2.4
2+
Name: egrid_ai_agent
3+
Version: 0.0.0
4+
Summary: Power system analysis with AI agent capabilities
5+
Author-email: Song Zhang <song.zhang@ieee.org>
6+
License: MIT
7+
Project-URL: Repository, https://github.com/IEEE-PES-TF-Cloud4PowerGrid/cloud_adoption_tutorials
8+
Requires-Python: >=3.11
9+
Description-Content-Type: text/markdown
10+
Requires-Dist: requests
11+
Requires-Dist: botocore
12+
Requires-Dist: termcolor
13+
Requires-Dist: InlineAgent
14+
15+
# eGRID AI AGENT
16+
AI agent for electric power grid analysis
17+
<p align="left">
18+
<a href="./README.md/#solution-overview"><img src="https://img.shields.io/badge/AWS-Agentic_AI-orange" /></a>
19+
<a href="./README.md/#setup-for-agent"><img src="https://img.shields.io/badge/Amazon-Bedrock_Inline_Agent-orange" /></a>
20+
</p>
21+
22+
23+
## Introduction
24+
This tutorial introduces a sample agentic AI solution for function-calling various power system analysis applications through a RESTful service. The solution is built with [Amazon Bedrock Inline Agent SDK](https://github.com/awslabs/amazon-bedrock-agent-samples/tree/main/src/InlineAgent). Open source software tools including [OpenDSS (DSS-Python)](https://github.com/dss-extensions/DSS-Python) and [GridCal](https://github.com/SanPen/GridCal) are used in this example to demonstrate the tool use process.
25+
26+
## Solution Overview
27+
![soln_overview](img/soln_overview.png?raw=true "Architectural overview for the eGrid Agentic AI")
28+
29+
## Get Started
30+
### Prerequisites
31+
32+
1. AWS Command Line Interface (CLI), follow instructions [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). Make sure to setup credentials, follow instructions [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html).
33+
2. Requires [Python 3.11](https://www.python.org/downloads/) or later.
34+
3. Enable Amazon Bedrock [model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html).
35+
36+
> [!NOTE]
37+
> If you don't set up your AWS profile as instructed in step 1. An exception `botocore.exceptions.ProfileNotFound` will raise
38+
> when you run `InlineAgent_hello` test below
39+
40+
### Setup for Agent
41+
42+
```bash
43+
# Retrieve the Inline Agent SDK
44+
git clone https://github.com/awslabs/amazon-bedrock-agent-samples.git
45+
cd amazon-bedrock-agent-samples/src/InlineAgent
46+
47+
# Activate the virtual environment (install python virtualenv first if not installed)
48+
python3 -m venv .venv
49+
source .venv/bin/activate
50+
51+
# Install the SDK packages
52+
python3 -m pip install -e .
53+
54+
# Test run; ensure you have access to Claude 3.5 Haiku model via Bedrock
55+
InlineAgent_hello us.anthropic.claude-3-5-haiku-20241022-v1:0
56+
57+
# Retrieve the tutorial
58+
git clone https://github.com/IEEE-PES-TF-Cloud4PowerGrid/cloud_adoption_tutorials.git
59+
cd cloud_adoption_tutorials/egrid_ai_agent/
60+
61+
# Install dependencies for the sample
62+
python3 -m pip install -e .
63+
```
64+
65+
### Setup for eGrid Analysis RESTful Service
66+
> [!NOTE]
67+
> You can host the RESTful service for various power system analysis tools either on your local machine or a remote server.
68+
> If you run the RESTful service on a remote server, just ensure to replace `localhost` in **API_BASE_URL** with the server's public IP address or DNS hostname. Also make sure the server's TCP port 5000 is accessible from the machine where you run the agent, then copy the script `egrid_rest_service.py` to the remote server
69+
70+
71+
```bash
72+
# install dependencies
73+
python3 -m pip install dss-python GridCalEngine flask flask_restful matplotlib
74+
```
75+
76+
77+
### Start the RESTful Service
78+
```bash
79+
python3 egrid_rest_service.py
80+
```
81+
82+
### Run Bedrock Inline Agent to Interact with the REST APIs
83+
```bash
84+
python3 run_egrid_agent.py
85+
```
86+
87+
## Expected Results
88+
### Power Flow Analysis
89+
Uncomment the line in `run_egrid_agent` script where the prompt is *"Run power flow analysis for case IEEE14_from_raw.gridcal"* to run the power flow analysis example. Feel free to change the case name to play with various study systems. Note that you need to download the power flow cases from GridCal project repo ["Grids_and_Profiles/grids/"](https://github.com/SanPen/GridCal/tree/master/Grids_and_profiles) folder
90+
91+
![Agent Response PF](img/agent_resp_pf.png?raw=true "Agent Response for Prompt to Run Power Flow Analysis")
92+
<p align=center>Agent Response for Prompt to Run Power Flow Analysis</p>
93+
94+
### Hosting Capacity Analysis
95+
![Agent Response HCA](img/agent_resp_hca.png?raw=true "Agent Response for Prompt to Run Hosting Capacity Analysis")
96+
<p align=center>Agent Response for Prompt to Run Hosting Capacity Analysis</p>
97+
98+
![HCA Result](img/hca_res.png?raw=true "Visual Representation of Hosting Capacity Analysis Results")
99+
<p align=center>Visual Representation of Hosting Capacity Analysis Results</p>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
README.md
2+
pyproject.toml
3+
egrid_ai_agent.egg-info/PKG-INFO
4+
egrid_ai_agent.egg-info/SOURCES.txt
5+
egrid_ai_agent.egg-info/dependency_links.txt
6+
egrid_ai_agent.egg-info/entry_points.txt
7+
egrid_ai_agent.egg-info/requires.txt
8+
egrid_ai_agent.egg-info/top_level.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[console_scripts]
2+
agent = run_egrid_agent:main
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
requests
2+
botocore
3+
termcolor
4+
InlineAgent
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
img
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Metadata-Version: 2.4
2+
Name: egrid_mcp_agent
3+
Version: 0.0.0
4+
Summary: This is an MCP agent example for power system analysis with open-source tool GridCal and OpenDSS
5+
Author-email: hinfsynz <szhang.asu@gmail.com>
6+
License: MIT
7+
Project-URL: Repository, https://github.com/IEEE-PES-TF-Cloud4PowerGrid/cloud_adoption_tutorials
8+
Requires-Python: >=3.11
9+
Description-Content-Type: text/markdown
10+
Requires-Dist: requests
11+
Requires-Dist: botocore
12+
Requires-Dist: termcolor
13+
Requires-Dist: InlineAgent
14+
15+
# eGRID MCP AGENT
16+
This is an MCP version of the eGrid Agentic AI example
17+
<p align="left">
18+
<a href="./README.md/#solution-overview"><img src="https://img.shields.io/badge/AWS-Agentic_AI-orange" /></a>
19+
<a href="./README.md/#setup-agent-for-mcp-client"><img src="https://img.shields.io/badge/Amazon-Bedrock_Inline_Agent-orange" /></a>
20+
<a href="./README.md/#setup-for-egrid-analysis-mcp-server"><img src="https://img.shields.io/badge/MCP-FastMCP-blue" /></a>
21+
</p>
22+
23+
24+
## Introduction
25+
This tutorial demonstrates an MCP agent implementation that integrates multiple power system analysis tools via an MCP server. The server utilizes [FastMCP](https://github.com/jlowin/fastmcp) for its foundation, while the client leverages the [Amazon Bedrock Inline Agent SDK](https://github.com/awslabs/amazon-bedrock-agent-samples/tree/main/src/InlineAgent). The example showcases tool integration using open source power system software such as [OpenDSS (DSS-Python)](https://github.com/dss-extensions/DSS-Python) and [GridCal](https://github.com/SanPen/GridCal) to illustrate the operational workflow.
26+
27+
## Solution Overview
28+
![soln_overview](img/soln_overview.png?raw=true "Architectural overview for the eGrid Agentic AI harnessing MCP")
29+
30+
## Get Started
31+
### Prerequisites
32+
33+
1. AWS Command Line Interface (CLI), follow instructions [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). Make sure to setup credentials, follow instructions [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html).
34+
2. Install [UV](https://docs.astral.sh/uv/getting-started/installation/)
35+
3. Install [Python](https://docs.astral.sh/uv/guides/install-python/) 3.11 or above in UV
36+
4. Enable Amazon Bedrock [model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html).
37+
38+
> [!NOTE]
39+
> If you don't set up your AWS profile as instructed in step 1. An exception `botocore.exceptions.ProfileNotFound` will raise
40+
> when you run `InlineAgent_hello` test below
41+
42+
### Setup Agent for MCP Client
43+
44+
```bash
45+
# Retrieve the Inline Agent SDK
46+
git clone https://github.com/awslabs/amazon-bedrock-agent-samples.git
47+
cd amazon-bedrock-agent-samples/src/InlineAgent
48+
49+
# Activate the virtual environment (install python virtualenv first if not installed)
50+
python3 -m venv .venv
51+
source .venv/bin/activate
52+
53+
# Install the SDK packages
54+
python3 -m pip install -e .
55+
56+
# Test run; ensure you have access to Claude 3.5 Haiku model via Bedrock
57+
InlineAgent_hello us.anthropic.claude-3-5-haiku-20241022-v1:0
58+
59+
# Retrieve the tutorial
60+
git clone https://github.com/IEEE-PES-TF-Cloud4PowerGrid/cloud_adoption_tutorials.git
61+
cd cloud_adoption_tutorials/egrid_mcp_agent/
62+
63+
# Install dependencies for the sample
64+
python3 -m pip install -e .
65+
```
66+
67+
### Setup for eGrid Analysis MCP Server
68+
> [!NOTE]
69+
> You can host the MCP server for various power system analysis tools either on your local machine or a remote server.
70+
> When deploying the MCP server on a remote machine, update the **API_BASE_URL** by substituting `localhost` with the server's public IP address or domain name.
71+
> Verify that TCP port 8000 is open and reachable from the machine running the agent, then transfer the `egrid_mcp_server.py` script to the remote server.
72+
73+
74+
```bash
75+
# install dependencies
76+
uv add dss-python GridCalEngine numpy matplotlib "fastmcp>=0.1.0"
77+
```
78+
79+
80+
### Start the MCP Server
81+
```bash
82+
uv run egrid_mcp_server.py
83+
```
84+
85+
### Run MCP client built with Bedrock Inline Agent to Interact with MCP Server
86+
```bash
87+
python3 run_egrid_agent_mcp_client.py
88+
```
89+
90+
## Expected Results
91+
### Power Flow Analysis
92+
You need to download the power flow cases from GridCal project repo ["Grids_and_Profiles/grids/"](https://github.com/SanPen/GridCal/tree/master/Grids_and_profiles) folder
93+
94+
![Agent Response PF](img/agent_resp_pf.png?raw=true "Agent Response for Prompt to Run Power Flow Analysis")
95+
<p align=center>Agent Response for Prompt to Run Power Flow Analysis</p>
96+
97+
![MCP Server Response PF](img/mcp_resp_pf.png?raw=true "MCP Server Response for Prompt to Run Power Flow Analysis")
98+
<p align=center>MCP Server Response for Prompt to Run Power Flow Analysis</p>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
README.md
2+
pyproject.toml
3+
egrid_mcp_agent.egg-info/PKG-INFO
4+
egrid_mcp_agent.egg-info/SOURCES.txt
5+
egrid_mcp_agent.egg-info/dependency_links.txt
6+
egrid_mcp_agent.egg-info/entry_points.txt
7+
egrid_mcp_agent.egg-info/requires.txt
8+
egrid_mcp_agent.egg-info/top_level.txt

0 commit comments

Comments
 (0)