Skip to content

Commit

Permalink
Sample template: add for knowledge base alert analysis agent (opensea…
Browse files Browse the repository at this point in the history
…rch-project#874)

* add sample template for create alert agent

Signed-off-by: yuye-aws <[email protected]>

* add description

Signed-off-by: yuye-aws <[email protected]>

* spotless apply

Signed-off-by: yuye-aws <[email protected]>

* update changelog

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws authored and dbwiddis committed Sep 18, 2024
1 parent 76d82a4 commit 410b462
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
### Enhancements
### Bug Fixes
### Infrastructure
- Set Java target compatibility to JDK 21 ([#730](https://github.com/opensearch-project/flow-framework/pull/730))

### Documentation
### Maintenance
### Refactoring
Expand All @@ -18,5 +20,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
### Bug Fixes
### Infrastructure
### Documentation
- Add knowledge base alert agent into sample templates ([#874](https://github.com/opensearch-project/flow-framework/pull/874))

### Maintenance
### Refactoring
93 changes: 93 additions & 0 deletions sample-templates/create-knowledge-base-alert-agent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"name": "Olly II Agents",
"description": "This template is to create all Agents required for olly II features ",
"use_case": "REGISTER_AGENTS",
"version": {
"template": "1.0.0",
"compatibility": [
"2.15.0",
"3.0.0"
]
},
"workflows": {
"provision": {
"user_params": {},
"nodes": [
{
"id": "create_knowledge_base_connector",
"type": "create_connector",
"previous_node_inputs": {},
"user_inputs": {
"name": "Amazon Bedrock Connector: knowledge base",
"description": "The connector to the Bedrock knowledge base",
"version": "1",
"protocol": "aws_sigv4",
"parameters": {
"region": "us-west-2",
"service_name": "bedrock",
"knowledgeBaseId": "PUT_YOUR_KNOWLEDGE_BASE_ID_HERE",
"model_arn": "arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0"
},
"credential": {
"access_key": "PUT_YOUR_ACCESS_KEY_HERE",
"secret_key": "PUT_YOUR_SECRET_KEY_HERE"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"url": "https://bedrock-agent-runtime.us-west-2.amazonaws.com/retrieveAndGenerate",
"headers": {
"content-type": "application/json"
},
"request_body": "{\"input\": {\"text\": \"${parameters.text}\"}, \"retrieveAndGenerateConfiguration\": {\"type\": \"KNOWLEDGE_BASE\", \"knowledgeBaseConfiguration\": {\"knowledgeBaseId\": \"${parameters.knowledgeBaseId}\", \"modelArn\": \"${parameters.model_arn}\"}}}",
"post_process_function": "return params.output.text;"
}
]
}
},
{
"id": "register_knowledge_base_model",
"type": "register_remote_model",
"previous_node_inputs": {
"create_knowledge_base_connector": "connector_id"
},
"user_inputs": {
"name": "Claude model on bedrock",
"function_name": "remote",
"version": "1.0.0",
"description": "Claude model on bedrock",
"deploy": "true"
}
},
{
"id": "create_kb_ml_model_tool",
"type": "create_tool",
"previous_node_inputs": {
"register_knowledge_base_model": "model_id"
},
"user_inputs": {
"parameters": {
"text": "You are an OpenSearch Alert Assistant to provide your insight on this alert to help users understand the alert, find potential causes and give feasible solutions to address it.\n Here is the detail of alert: ${parameters.context};\n The alert summary is: ${parameters.summary};\n The question is: ${parameters.question}."
},
"name": "MLModelTool",
"type": "MLModelTool"
}
},
{
"id": "create_knowledge_base_agent",
"type": "register_agent",
"previous_node_inputs": {
"create_kb_ml_model_tool": "tools"
},
"user_inputs": {
"parameters": {},
"type": "flow",
"name": "Bedrock knowledge base agent",
"description": "this is an agent to call retrieveAndGenerate API in bedrock knowledge base suggestion agent"
}
}
]
}
}
}
83 changes: 83 additions & 0 deletions sample-templates/create-knowledge-base-alert-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This template creates a connector to the BedRock service for Knowledge base
# It then registers a model using the connector and deploys it.
# Finally, it creates a flow agent base agent with ML Model tool to access the knowledge base.
#
# To use:
# - update the "credential" and "knowledgeBaseId" fields under the create_knowledge_base_connector node.
# - if needed, update region
#
# After provisioning:
# - returns a workflow ID
# - use the status API to get the deployed agent ID
---
name: Olly II Agents
description: 'This template is to create all Agents required for olly II features '
use_case: REGISTER_AGENTS
version:
template: 1.0.0
compatibility:
- 2.15.0
- 3.0.0
workflows:
provision:
user_params: {}
nodes:
- id: create_knowledge_base_connector
type: create_connector
previous_node_inputs: {}
user_inputs:
name: 'Amazon Bedrock Connector: knowledge base'
description: The connector to the Bedrock knowledge base
version: '1'
protocol: aws_sigv4
parameters:
region: us-west-2
service_name: bedrock
knowledgeBaseId: PUT_YOUR_KNOWLEDGE_BASE_ID_HERE
model_arn: arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0
credential:
access_key: PUT_YOUR_ACCESS_KEY_HERE
secret_key: PUT_YOUR_SECRET_KEY_HERE
actions:
- action_type: predict
method: POST
url: https://bedrock-agent-runtime.us-west-2.amazonaws.com/retrieveAndGenerate
headers:
content-type: application/json
request_body: '{"input": {"text": "${parameters.text}"}, "retrieveAndGenerateConfiguration":
{"type": "KNOWLEDGE_BASE", "knowledgeBaseConfiguration": {"knowledgeBaseId":
"${parameters.knowledgeBaseId}", "modelArn": "${parameters.model_arn}"}}}'
post_process_function: return params.output.text;
- id: register_knowledge_base_model
type: register_remote_model
previous_node_inputs:
create_knowledge_base_connector: connector_id
user_inputs:
name: Claude model on bedrock
function_name: remote
version: 1.0.0
description: Claude model on bedrock
deploy: 'true'
- id: create_kb_ml_model_tool
type: create_tool
previous_node_inputs:
register_knowledge_base_model: model_id
user_inputs:
parameters:
text: |-
You are an OpenSearch Alert Assistant to provide your insight on this alert to help users understand the alert, find potential causes and give feasible solutions to address it.
Here is the detail of alert: ${parameters.context};
The alert summary is: ${parameters.summary};
The question is: ${parameters.question}.
name: MLModelTool
type: MLModelTool
- id: create_knowledge_base_agent
type: register_agent
previous_node_inputs:
create_kb_ml_model_tool: tools
user_inputs:
parameters: {}
type: flow
name: Bedrock knowledge base agent
description: this is an agent to call retrieveAndGenerate API in bedrock knowledge
base suggestion agent

0 comments on commit 410b462

Please sign in to comment.