-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 2.x] Add sample templates (#510)
Add sample templates (#498) * Add sample templates * Change Query Assist template to use OpenAI * Add README to the folder * Address PR review comments on templates * Add chat agent template --------- (cherry picked from commit 13b1f93) Signed-off-by: Daniel Widdis <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
37cae9a
commit ddeeee0
Showing
11 changed files
with
1,509 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
## Flow Framework Sample Templates | ||
|
||
This folder contains sample workflow templates that can be used with Flow Framework. | ||
|
||
Each template is provided in both YAML and JSON format with identical functionality. | ||
The YAML templates include comments which give more insight into the template's usage. | ||
Use the corresponding `Content-Type` (`application/yaml` or `application/json`) when providing them as the body of a REST request. | ||
|
||
You will need to update the `credentials` field with appropriate API keys. | ||
|
||
To create a workflow and provision the resources: | ||
|
||
``` | ||
POST /_plugins/_flow_framework/workflow?provision=true | ||
{ template as body } | ||
``` | ||
|
||
This will return a `workflow_id`. To get the IDs of created resources, call the workflow status API. | ||
|
||
``` | ||
GET /_plugins/_flow_framework/workflow/<workflow_id>/_status | ||
``` | ||
|
||
For the Query Assist Agent API, the `agent_id` of the `root_agent` can be used to query it. | ||
|
||
``` | ||
POST /_plugins/_ml/agents/_<agent_id>/_execute | ||
{ | ||
"parameters": { | ||
"question": "How many 5xx logs do I have?" | ||
} | ||
} | ||
``` |
This file contains 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,72 @@ | ||
{ | ||
"name": "Deploy Claude Model", | ||
"description": "Deploy a model using a connector to Claude", | ||
"use_case": "PROVISION", | ||
"version": { | ||
"template": "1.0.0", | ||
"compatibility": [ | ||
"2.12.0", | ||
"3.0.0" | ||
] | ||
}, | ||
"workflows": { | ||
"provision": { | ||
"nodes": [ | ||
{ | ||
"id": "create_claude_connector", | ||
"type": "create_connector", | ||
"user_inputs": { | ||
"name": "Claude Instant Runtime Connector", | ||
"version": "1", | ||
"protocol": "aws_sigv4", | ||
"description": "The connector to BedRock service for Claude model", | ||
"actions": [ | ||
{ | ||
"headers": { | ||
"x-amz-content-sha256": "required", | ||
"content-type": "application/json" | ||
}, | ||
"method": "POST", | ||
"request_body": "{ \"prompt\":\"${parameters.prompt}\", \"max_tokens_to_sample\":${parameters.max_tokens_to_sample}, \"temperature\":${parameters.temperature}, \"anthropic_version\":\"${parameters.anthropic_version}\" }", | ||
"action_type": "predict", | ||
"url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/anthropic.claude-instant-v1/invoke" | ||
} | ||
], | ||
"credential": { | ||
"access_key": "PUT_YOUR_ACCESS_KEY_HERE", | ||
"secret_key": "PUT_YOUR_SECRET_KEY_HERE" | ||
}, | ||
"parameters": { | ||
"endpoint": "bedrock-runtime.us-west-2.amazonaws.com", | ||
"content_type": "application/json", | ||
"auth": "Sig_V4", | ||
"max_tokens_to_sample": "8000", | ||
"service_name": "bedrock", | ||
"temperature": "0.0001", | ||
"response_filter": "$.completion", | ||
"region": "us-west-2", | ||
"anthropic_version": "bedrock-2023-05-31" | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "register_claude_model", | ||
"type": "register_remote_model", | ||
"previous_node_inputs": { | ||
"create_claude_connector": "connector_id" | ||
}, | ||
"user_inputs": { | ||
"name": "claude-instant" | ||
} | ||
}, | ||
{ | ||
"id": "deploy_claude_model", | ||
"type": "deploy_model", | ||
"previous_node_inputs": { | ||
"register_claude_model": "model_id" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains 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,76 @@ | ||
# This template creates a connector to the BedRock service for Claude model | ||
# It then registers a model using that connector and deploys it. | ||
# | ||
# To use: | ||
# - update the "credential" fields under the create_claude_connector node. | ||
# - if needed, update region | ||
# | ||
# After provisioning: | ||
# - returns a workflow ID | ||
# - use the status API to get the deployed model ID | ||
--- | ||
name: Deploy Claude Model | ||
description: Deploy a model using a connector to Claude | ||
use_case: PROVISION | ||
version: | ||
template: 1.0.0 | ||
compatibility: | ||
- 2.12.0 | ||
- 3.0.0 | ||
# This section defines the provision workflow. Nodes are connected in a graph. | ||
# Either previous_node_inputs or explicit edges can be used to enforce ordering. | ||
workflows: | ||
provision: | ||
# Each id field in a workflow must be unique. | ||
nodes: | ||
- id: create_claude_connector | ||
type: create_connector | ||
user_inputs: | ||
name: Claude Instant Runtime Connector | ||
version: '1' | ||
protocol: aws_sigv4 | ||
description: The connector to BedRock service for Claude model | ||
actions: | ||
- headers: | ||
x-amz-content-sha256: required | ||
content-type: application/json | ||
method: POST | ||
request_body: '{ | ||
"prompt":"${parameters.prompt}", | ||
"max_tokens_to_sample":${parameters.max_tokens_to_sample}, | ||
"temperature":${parameters.temperature}, "anthropic_version":"${parameters.anthropic_version}" | ||
}' | ||
action_type: predict | ||
url: https://bedrock-runtime.us-west-2.amazonaws.com/model/anthropic.claude-instant-v1/invoke | ||
credential: | ||
access_key: 'PUT_YOUR_ACCESS_KEY_HERE' | ||
secret_key: 'PUT_YOUR_SECRET_KEY_HERE' | ||
parameters: | ||
endpoint: bedrock-runtime.us-west-2.amazonaws.com | ||
content_type: application/json | ||
auth: Sig_V4 | ||
max_tokens_to_sample: '8000' | ||
service_name: bedrock | ||
temperature: '0.0001' | ||
response_filter: "$.completion" | ||
region: us-west-2 | ||
anthropic_version: bedrock-2023-05-31 | ||
- id: register_claude_model | ||
type: register_remote_model | ||
previous_node_inputs: | ||
create_claude_connector: connector_id | ||
user_inputs: | ||
name: claude-instant | ||
# Using deploy: true here would both registers and deploy the model | ||
# and the deploy model step below could be deleted | ||
# deploy: true | ||
- id: deploy_claude_model | ||
type: deploy_model | ||
previous_node_inputs: | ||
register_claude_model: model_id | ||
# Because the above nodes use previous_node_inputs, these edges are automatically generated. | ||
# edges: | ||
# - source: create_claude_connector | ||
# dest: register_claude_model | ||
# - source: register_claude_model | ||
# dest: deploy_claude_model |
This file contains 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,60 @@ | ||
{ | ||
"name": "Deploy OpenAI Model", | ||
"description": "Deploy a model using a connector to OpenAI", | ||
"use_case": "PROVISION", | ||
"version": { | ||
"template": "1.0.0", | ||
"compatibility": [ | ||
"2.12.0", | ||
"3.0.0" | ||
] | ||
}, | ||
"workflows": { | ||
"provision": { | ||
"nodes": [ | ||
{ | ||
"id": "create_openai_connector", | ||
"type": "create_connector", | ||
"user_inputs": { | ||
"name": "OpenAI Chat Connector", | ||
"description": "The connector to public OpenAI model service for GPT 3.5", | ||
"version": "1", | ||
"protocol": "http", | ||
"parameters": { | ||
"endpoint": "api.openai.com", | ||
"model": "gpt-3.5-turbo", | ||
"response_filter": "$.choices[0].message.content" | ||
}, | ||
"credential": { | ||
"openAI_key": "PUT_YOUR_API_KEY_HERE" | ||
}, | ||
"actions": [ | ||
{ | ||
"action_type": "predict", | ||
"method": "POST", | ||
"url": "https://${parameters.endpoint}/v1/chat/completions" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"id": "register_openai_model", | ||
"type": "register_remote_model", | ||
"previous_node_inputs": { | ||
"create_openai_connector": "connector_id" | ||
}, | ||
"user_inputs": { | ||
"name": "openAI-gpt-3.5-turbo" | ||
} | ||
}, | ||
{ | ||
"id": "deploy_openai_model", | ||
"type": "deploy_model", | ||
"previous_node_inputs": { | ||
"register_openai_model": "model_id" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains 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,60 @@ | ||
# This template creates a connector to the public OpenAI model service for GPT 3.5 | ||
# It then registers a model using that connector and deploys it. | ||
# | ||
# To use: | ||
# - update the "credential" field under the create_openai_connector node. | ||
# | ||
# After provisioning: | ||
# - returns a workflow ID | ||
# - use the status API to get the deployed model ID | ||
--- | ||
name: Deploy OpenAI Model | ||
description: Deploy a model using a connector to OpenAI | ||
use_case: PROVISION | ||
version: | ||
template: 1.0.0 | ||
compatibility: | ||
- 2.12.0 | ||
- 3.0.0 | ||
# This section defines the provision workflow. Nodes are connected in a graph. | ||
# Either previous_node_inputs or explicit edges can be used to enforce ordering. | ||
workflows: | ||
provision: | ||
# Each id field in a workflow must be unique. | ||
nodes: | ||
- id: create_openai_connector | ||
type: create_connector | ||
user_inputs: | ||
name: OpenAI Chat Connector | ||
description: The connector to public OpenAI model service for GPT 3.5 | ||
version: '1' | ||
protocol: http | ||
parameters: | ||
endpoint: api.openai.com | ||
model: gpt-3.5-turbo | ||
response_filter: '$.choices[0].message.content' | ||
credential: | ||
openAI_key: 'PUT_YOUR_API_KEY_HERE' | ||
actions: | ||
- action_type: predict | ||
method: POST | ||
url: https://${parameters.endpoint}/v1/chat/completions | ||
- id: register_openai_model | ||
type: register_remote_model | ||
previous_node_inputs: | ||
create_openai_connector: connector_id | ||
user_inputs: | ||
name: openAI-gpt-3.5-turbo | ||
# Using deploy: true here would both registers and deploy the model | ||
# and the deploy model step below could be deleted | ||
# deploy: true | ||
- id: deploy_openai_model | ||
type: deploy_model | ||
previous_node_inputs: | ||
register_openai_model: model_id | ||
# Because the above nodes use previous_node_inputs, these edges are automatically generated. | ||
# edges: | ||
# - source: create_openai_connector | ||
# dest: register_openai_model | ||
# - source: register_openai_model | ||
# dest: deploy_openai_model |
This file contains 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,64 @@ | ||
{ | ||
"name": "Deploy Mistral Model", | ||
"description": "Deploy a model using a connector to SageMaker Mistral model", | ||
"use_case": "PROVISION", | ||
"version": { | ||
"template": "1.0.0", | ||
"compatibility": [ | ||
"2.12.0", | ||
"3.0.0" | ||
] | ||
}, | ||
"workflows": { | ||
"provision": { | ||
"nodes": [ | ||
{ | ||
"id": "create_mistral_connector", | ||
"type": "create_connector", | ||
"user_inputs": { | ||
"name": "sagemaker: mistral", | ||
"description": "Test connector for Sagemaker mistral model", | ||
"version": "1", | ||
"protocol": "aws_sigv4", | ||
"credential": { | ||
"access_key": "PUT_YOUR_ACCESS_KEY_HERE", | ||
"secret_key": "PUT_YOUR_SECRET_KEY_HERE" | ||
}, | ||
"parameters": { | ||
"region": "us-east-1", | ||
"service_name": "sagemaker" | ||
}, | ||
"actions": [ | ||
{ | ||
"action_type": "predict", | ||
"method": "POST", | ||
"headers": { | ||
"content-type": "application/json" | ||
}, | ||
"url": "https://PUT_YOUR_CUSTOM_SAGEMAKER_ENDPOINT_HERE", | ||
"request_body": "{\"prompt\":\"${parameters.prompt}\"}" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"id": "register_mistral_model", | ||
"type": "register_remote_model", | ||
"previous_node_inputs": { | ||
"create_mistral_connector": "connector_id" | ||
}, | ||
"user_inputs": { | ||
"name": "mistral fine-tuned model" | ||
} | ||
}, | ||
{ | ||
"id": "deploy_mistral_model", | ||
"type": "deploy_model", | ||
"previous_node_inputs": { | ||
"register_mistral_model": "model_id" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.