Skip to content

Commit 99cf393

Browse files
authored
E2e test wfsm v0.2 (#52)
2 parents e7f474e + 596c0d6 commit 99cf393

File tree

12 files changed

+677
-465
lines changed

12 files changed

+677
-465
lines changed

examples/email_reviewer/deploy/email_reviewer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
{
8080
"type": "source_code",
8181
"name": "source_code_local",
82-
"url": "file://./email_reviewer",
82+
"url": "https://github.com/agntcy/acp-sdk.git//examples/email_reviewer",
8383
"framework_config": {
8484
"framework_type": "llamaindex",
8585
"path": "email_reviewer:email_reviewer_workflow"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
values:
2+
AZURE_OPENAI_API_KEY: your-api-key
3+
AZURE_OPENAI_ENDPOINT: 'https://your-project-agents.openai.azure.com'

examples/mailcomposer/deploy/mailcomposer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
{
171171
"type": "source_code",
172172
"name": "source_code_local",
173-
"url": "file://./mailcomposer",
173+
"url": "https://github.com/agntcy/acp-sdk.git//examples/mailcomposer",
174174
"framework_config": {
175175
"framework_type": "langgraph",
176176
"graph": "mailcomposer.mailcomposer:graph"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
values:
2+
AZURE_OPENAI_API_KEY: your-api-key
3+
AZURE_OPENAI_ENDPOINT: 'https://your-project-agents.openai.azure.com'

examples/marketing-campaign/README.md

+262-50
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,280 @@
11
# Marketing Campaign Manager
22

3-
The Marketing Campaign Manager is a demonstration AI agent developed with LangGraph, designed to assist in composing and sending emails for a marketing campaign.
3+
The **Marketing Campaign Manager** is a demonstration AI application developed with LangGraph. It assists in composing and sending emails for marketing campaigns by interacting with multiple AI agents. This guide will walk you through the steps to set up and run the example application locally.
4+
5+
## Features
46

5-
It performs the following actions:
67
* It gathers necessary campaign details from the user through a chat.
78
* Compose an email leveraging the [Email Composer Agent](../mailcomposer/) as a remote ACP agent.
89
* It leverages the [IO Mapper Agent](https://github.com/agntcy/iomapper-agnt) to adapt Email Composer Agent output to Email Reviewer Agent.
910
* Reviews the email leveraging the [Email Reviewer Agent](../email_reviewer/) as a remote ACP agent.
1011
* Send the email to the configured recipient through Twilio sendgrid leveraging the [API Bridge Agent](https://github.com/agntcy/api-bridge-agnt)
1112

13+
---
14+
1215
## Prerequisites
1316

1417
Before running the application, ensure you have the following:
1518

16-
- **Azure OpenAI API Key**
17-
- **Python 3.9 or higher**
18-
- **Poetry**
19+
### Tools and Dependencies
20+
- [Python 3.9 or higher](https://www.python.org/downloads/)
21+
- [Poetry](https://python-poetry.org/docs/#installation)
22+
- [Golang](https://go.dev/doc/install)
23+
- [Make](https://cmake.org/)
24+
- [Git](https://git-scm.com/)
25+
- [Git LFS](https://git-lfs.com/)
26+
- [Docker with Buildx](https://docs.docker.com/get-started/get-docker/)
27+
- [Docker Compose](https://docs.docker.com/compose/)
28+
- [Azure OpenAI API Key](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/quickstart)
29+
30+
---
31+
32+
## Setup Instructions
33+
34+
### 1. Clone the Required Repositories
35+
36+
Clone the following repositories:
37+
38+
- [ACP SDK](https://github.com/agntcy/acp-sdk/tree/main)
39+
- [Workflow Server](https://github.com/agntcy/workflow-srv)
40+
- [Workflow Server Manager](https://github.com/agntcy/workflow-srv-mgr)
41+
- [API Bridge Agent](https://github.com/agntcy/api-bridge-agnt)
42+
43+
It is recommended to work within each of the cloned directories after cloning them.
44+
45+
```sh
46+
# Clone the ACP SDK repository
47+
git clone https://github.com/agntcy/acp-sdk.git
48+
cd acp-sdk
49+
50+
# Clone the Workflow Server repository
51+
git clone https://github.com/agntcy/workflow-srv.git
52+
cd workflow-srv
53+
54+
# Clone the Workflow Server Manager repository
55+
git clone https://github.com/agntcy/workflow-srv-mgr.git
56+
cd workflow-srv-mgr
57+
58+
# Clone the API Bridge Agent repository
59+
git clone https://github.com/agntcy/api-bridge-agnt.git
60+
cd api-bridge-agnt
61+
```
62+
63+
### 2. Build the Workflow Server Manager
64+
65+
Navigate to the `workflow-srv-mgr` directory and build the Workflow Server Manager:
66+
67+
```sh
68+
cd wfsm
69+
make build
70+
```
71+
72+
Add the `wfsm` executable to your system's PATH:
73+
74+
#### For macOS:
75+
```sh
76+
cd build
77+
chmod +x wfsm
78+
echo 'export PATH=$PATH:/path/to/the/repo/workflow-srv-mgr/wfsm/build' >> ~/.zshrc
79+
source ~/.zshrc
80+
```
81+
82+
#### For Linux:
83+
```sh
84+
cd build
85+
chmod +x wfsm
86+
echo 'export PATH=$PATH:/path/to/the/repo/workflow-srv-mgr/wfsm/build' >> ~/.bashrc
87+
source ~/.bashrc
88+
```
89+
90+
### 3. Build the Workflow Server
91+
92+
Navigate to the `workflow-srv` directory and build the Docker image for the Workflow Server:
93+
94+
```sh
95+
make docker-build-dev
96+
```
97+
98+
### 4. Run the API Bridge Agent
99+
100+
Navigate to the `api-bridge-agnt` directory and run the following commands:
101+
102+
```sh
103+
export AZURE_OPENAI_API_KEY=***YOUR_OPENAI_API_KEY***
104+
export AZURE_OPENAI_ENDPOINT=***YOUR_OPENAI_ENDPOINT***
105+
make start_redis
106+
make start_tyk
107+
```
108+
109+
Configure the API Bridge Agent:
110+
111+
```sh
112+
curl http://localhost:8080/tyk/apis/oas \
113+
--header "x-tyk-authorization: foo" \
114+
--header 'Content-Type: text/plain' \
115+
-d@configs/api.sendgrid.com.oas.json
116+
117+
curl http://localhost:8080/tyk/reload/group \
118+
--header "x-tyk-authorization: foo"****
119+
```
120+
121+
---
19122

20123
## Running the Marketing Campaign Manager
21124

22-
### Preliminary step: Deploying API Bridge Agent
23-
24-
Run the API Bridge Agent configured with sendgrid. See [instructions](https://docs.agntcy.org/pages/syntactic_sdk/api_bridge_agent.html#an-example-with-sendgrid-api)
25-
26-
27-
### Running the agent directly
28-
* Deploy agentic dependencies first:
29-
* Run Email Composer Agent through the Agent Workflow Server. See [instructions](../mailcomposer/README.md#running-the-email-agent-using-agent-workflow-server).
30-
* Run Email Reviewer Agent through the Agent Workflow Server. See [instructions](../email_reviewer/README.md#running-the-email-agent-using-agent-workflow-server).
31-
* Install python dependencies
32-
```
33-
poetry install
34-
```
35-
* Run the agent
36-
```
37-
export AZURE_OPENAI_MODEL=gpt-4o-mini
38-
export AZURE_OPENAI_API_KEY=***YOUR_OPENAI_API_KEY***
39-
export AZURE_OPENAI_ENDPOINT=***YOUR_OPENAI_ENDPOINT***
40-
export OPENAI_API_VERSION=2024-07-01-preview
41-
export SENDGRID_API_KEY=***YOUR_SENDGRID_API_KEY***
42-
export MAILCOMPOSER_HOST=***URL TO EMAIL COMPOSER WORKFLOW SERVER e.g. http://0.0.0.0:10100***
43-
export EMAIL_REVIEWER_HOST=***URL TO EMAIL REVIEWER WORKFLOW SERVER e.g. http://0.0.0.0:10100***
44-
export MAILCOMPOSER_AGENT_ID==***EMAIL COMPOSER ID**
45-
export EMAIL_REVIEWER_AGENT_ID=***EMAIL REVIEWER ID**
46-
export SENDGRID_HOST=***URL TO API BRIDGE AGENT***
47-
48-
poetry run python src/marketing_campaign/__main__.py
49-
```
50-
51-
## Running the Email Agent using Agent Workflow Server
52-
53-
* Create an environment variable file with the variables described above
54-
```commandline
55-
echo "
56-
AZURE_OPENAI_MODEL=gpt-4o-mini
57-
...
58-
...
59-
" > deploy/.mcm.env
60-
```
61-
* Make sure that the workflow server manager cli (`wfsm`) is added to your path
62-
* Start the workflow server
63-
```
64-
cd deploy;
65-
wfsm deploy -m ./mailcomposer.json -e ./.mcm.env
66-
```
125+
The Marketing Campaign Manager application can be run in two ways:
126+
1. Using the **ACP client**.
127+
2. Using **LangGraph** directly.
128+
129+
Both methods allow users to interactively create a marketing campaign by providing input through a chat interface. The **MailComposer agent** generates email drafts, while the **EmailReviewer agent** reviews and refines the drafts.
130+
131+
An [IO Mapper Agent](https://github.com/agntcy/iomapper-agnt) is used in the application to automatically transform the output of the MailComposer to match the input of the EmailReviewer.
132+
133+
The **ACP client** or **LangGraph** applications handle communication with the Marketing Campaign application, which orchestrates interactions with the dependent agents.
134+
135+
All commands and scripts should be executed from the `examples/marketing-campaign` directory, where this guide is located.
136+
137+
### Prerequisites for Both Methods
138+
139+
Before running the application, ensure the following prerequisites are met:
140+
141+
1. **Bridge Agent**: The API Bridge Agent must be running as explained in Step 4 of the setup instructions.
142+
2. **`wfsm` CLI**: The Workflow Server Manager CLI (`wfsm`) must be added to your system's PATH.
143+
3. **Dependencies**: Install Python dependencies in the `examples/marketing-campaign` directory:
144+
```sh
145+
cd examples/marketing-campaign
146+
poetry install
147+
```
148+
149+
---
150+
151+
### Method 1: Using the ACP Client
152+
153+
This method demonstrates how to communicate with the Marketing Campaign application using the **ACP (Agent Connect Protocol) client**. The workflow server for the Marketing Campaign application must be started manually. Once running, it will automatically launch the workflow servers for its dependencies, **MailComposer** and **EmailReviewer**, as defined in the deployment configuration of the [marketing-campaign manifest](./deploy/marketing-campaign.json).
154+
155+
#### Steps:
156+
157+
1. **Configure the Agents**:
158+
Before starting the workflow server, provide the necessary configurations for the agents. Open the `./deploy/marketing_campaign_example.yaml` file located in the `deploy` folder and update the following values with your configuration:
159+
160+
```yaml
161+
values:
162+
AZURE_OPENAI_API_KEY: your_secret
163+
AZURE_OPENAI_ENDPOINT: "the_url.com"
164+
API_HOST: 0.0.0.0
165+
SENDGRID_HOST: http://host:port
166+
SENDGRID_API_KEY: SG.your-api-key
167+
dependencies:
168+
- name: mailcomposer
169+
values:
170+
AZURE_OPENAI_API_KEY: your_secret
171+
AZURE_OPENAI_ENDPOINT: "the_url.com"
172+
- name: email_reviewer
173+
values:
174+
AZURE_OPENAI_API_KEY: your_secret
175+
AZURE_OPENAI_ENDPOINT: "the_url.com"
176+
```
177+
178+
2. **Start the Workflow Server**:
179+
Run the following command to deploy the Marketing Campaign workflow server:
180+
```sh
181+
wfsm deploy -m ./deploy/marketing-campaign.json -e ./deploy/marketing_campaign_example.yaml -b workflowserver:latest
182+
```
183+
184+
If everything is set up correctly, the application will start, and the logs will display:
185+
- **Agent ID**
186+
- **API Key**
187+
- **Host**
188+
189+
Example log output:
190+
```plaintext
191+
2025-03-28T12:31:04+01:00 INF ---------------------------------------------------------------------
192+
2025-03-28T12:31:04+01:00 INF ACP agent deployment name: org.agntcy.marketing-campaign
193+
2025-03-28T12:31:04+01:00 INF ACP agent running in container: org.agntcy.marketing-campaign, listening for ACP request on: http://127.0.0.1:62609
194+
2025-03-28T12:31:04+01:00 INF Agent ID: eae32ada-aaf8-408c-bf0c-7654455ce6e3
195+
2025-03-28T12:31:04+01:00 INF API Key: 08817517-7000-48e9-94d8-01d22cf7d20a
196+
2025-03-28T12:31:04+01:00 INF ---------------------------------------------------------------------
197+
```
198+
199+
3. **Export Environment Variables**:
200+
Use the information from the logs to set the following environment variables:
201+
```sh
202+
export MARKETING_CAMPAIGN_HOST="http://localhost:62609"
203+
export MARKETING_CAMPAIGN_ID="eae32ada-aaf8-408c-bf0c-7654455ce6e3"
204+
export MARKETING_CAMPAIGN_API_KEY='{"x-api-key": "08817517-7000-48e9-94d8-01d22cf7d20a"}'
205+
```
206+
207+
4. **Run the Application**:
208+
Start the Marketing Campaign Manager application using the ACP client:
209+
```sh
210+
cd src/marketing_campaign
211+
poetry run python main_acp_client.py
212+
```
213+
214+
Interact with the application via ACP Client to compose and review emails. Once approved, the email will be sent to the recipient via SendGrid.
215+
---
216+
217+
### Method 2: Using LangGraph
218+
219+
This method provides an alternative way to interact with the Marketing Campaign application by directly invoking the **LangGraph graph** of the Marketing Campaign. Unlike the ACP client-based approach, this method bypasses the multi-agent software orchestration and requires manual handling of the agent dependencies.
220+
221+
This script is primarily intended for development and debugging purposes, allowing developers to test and refine the LangGraph logic.
222+
223+
#### Steps:
224+
225+
1. **Start Workflow Servers for Dependencies**:
226+
Manually start the workflow servers for the **MailComposer** and **EmailReviewer** agents in separate terminals:
227+
```sh
228+
wfsm deploy -m ../mailcomposer/deploy/mailcomposer.json -e ../mailcomposer/deploy/mailcomposer_example.yaml -b workflowserver:latest
229+
```
230+
```sh
231+
wfsm deploy -m ../email_reviewer/deploy/email_reviewer.json -e ../email_reviewer/deploy/email_reviewer_example.yaml -b workflowserver:latest
232+
```
233+
234+
The logs will display the **Agent ID**, **API Key**, and **Host** for each agent. Use this information to set the following environment variables:
235+
```sh
236+
export MAILCOMPOSER_HOST="http://localhost:<port>"
237+
export MAILCOMPOSER_ID="<mailcomposer-agent-id>"
238+
export MAILCOMPOSER_API_KEY='{"x-api-key": "<mailcomposer-api-key>"}'
239+
240+
export EMAIL_REVIEWER_HOST="http://localhost:<port>"
241+
export EMAIL_REVIEWER_ID="<email-reviewer-agent-id>"
242+
export EMAIL_REVIEWER_API_KEY='{"x-api-key": "<email-reviewer-api-key>"}'
243+
```
244+
245+
2. **Export Additional Environment Variables**:
246+
Set the following environment variables:
247+
```sh
248+
export API_HOST=0.0.0.0
249+
export SENDGRID_API_KEY=SG.your_secret
250+
export AZURE_OPENAI_API_KEY=your_secret
251+
export AZURE_OPENAI_ENDPOINT="the_url.com"
252+
```
253+
254+
3. **Run the Application**:
255+
Start the Marketing Campaign Manager application using LangGraph:
256+
```sh
257+
cd src/marketing_campaign
258+
poetry run python main_langgraph.py
259+
```
260+
261+
Interact by invoking the langgraph application to compose and review emails. Once approved, the email will be sent to the recipient via SendGrid.
262+
263+
---
264+
265+
### Additional Configuration
266+
267+
In both scripts [main_acp_client.py](./src/marketing_campaign/main_acp_client.py) and [main_langgraph.py](./src/marketing_campaign/main_langgraph.py), you can customize the target audience for the campaign by modifying the `target_audience` parameter `target_audience=TargetAudience.academic`. Available options are:
268+
- `general`
269+
- `technical`
270+
- `business`
271+
- `academic`
272+
273+
Example:
274+
```python
275+
target_audience = TargetAudience.business
276+
```
67277

278+
---
68279

280+
By following these steps, you can successfully run the Marketing Campaign Manager application using either the ACP client or LangGraph. Both methods allow you to compose, review, and send marketing emails interactively.

0 commit comments

Comments
 (0)