You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2024/03/14 10:52:59 UTC
(camel) 07/08: Camel-AWS-Bedrock: Add documentation for Anthropic Claude Sonnet 3
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e752fa6956a83c3cdd7668c9aacb9d281108e480
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Mar 14 11:12:15 2024 +0100
Camel-AWS-Bedrock: Add documentation for Anthropic Claude Sonnet 3
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../src/main/docs/aws-bedrock-component.adoc | 63 ++++++++++++++++++++++
.../runtime/integration/BedrockProducerIT.java | 25 +++++----
2 files changed, 75 insertions(+), 13 deletions(-)
diff --git a/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-component.adoc b/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-component.adoc
index 2ccd3eb465a..b8d37dcc976 100644
--- a/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-component.adoc
+++ b/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-component.adoc
@@ -555,6 +555,69 @@ Json schema for request
}
--------------------------------------------------------------------------------
+- Claude 3 Sonnet with id `anthropic.claude-3-sonnet-20240229-v1:0"`
+Claude 3 Sonnet by Anthropic strikes the ideal balance between intelligence and speed—particularly for enterprise workloads.
+
+Json schema for request
+
+[source,json]
+--------------------------------------------------------------------------------
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "messages": {
+ "type": "array",
+ "items": [
+ {
+ "type": "object",
+ "properties": {
+ "role": {
+ "type": "string"
+ },
+ "content": {
+ "type": "array",
+ "items": [
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string"
+ },
+ "text": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "text"
+ ]
+ }
+ ]
+ }
+ },
+ "required": [
+ "role",
+ "content"
+ ]
+ }
+ ]
+ },
+ "max_tokens": {
+ "type": "integer"
+ },
+ "anthropic_version": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "messages",
+ "max_tokens",
+ "anthropic_version"
+ ]
+}
+--------------------------------------------------------------------------------
+
=== Bedrock Producer operations
Camel-AWS Bedrock component provides the following operation on the producer side:
diff --git a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/integration/BedrockProducerIT.java b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/integration/BedrockProducerIT.java
index 8a2eab71fab..b0a9bb36346 100644
--- a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/integration/BedrockProducerIT.java
+++ b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/integration/BedrockProducerIT.java
@@ -32,10 +32,10 @@ import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
// Must be manually tested. Provide your own accessKey and secretKey using -Daws.manual.access.key and -Daws.manual.secret.key
-/*@EnabledIfSystemProperties({
+@EnabledIfSystemProperties({
@EnabledIfSystemProperty(named = "aws.manual.access.key", matches = ".*", disabledReason = "Access key not provided"),
@EnabledIfSystemProperty(named = "aws.manual.secret.key", matches = ".*", disabledReason = "Secret key not provided")
-})*/
+})
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class BedrockProducerIT extends CamelTestSupport {
@@ -263,7 +263,6 @@ class BedrockProducerIT extends CamelTestSupport {
rootNode.putIfAbsent("top_k", new IntNode(250));
rootNode.putIfAbsent("anthropic_version", new TextNode("bedrock-2023-05-31"));
- System.err.println(mapper.writer().writeValueAsString(rootNode));
exchange.getMessage().setBody(mapper.writer().writeValueAsString(rootNode));
exchange.getMessage().setHeader(BedrockConstants.MODEL_CONTENT_TYPE, "application/json");
exchange.getMessage().setHeader(BedrockConstants.MODEL_ACCEPT_CONTENT_TYPE, "application/json");
@@ -343,17 +342,17 @@ class BedrockProducerIT extends CamelTestSupport {
@Override
public void configure() {
from("direct:send_titan_express")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=eu-central-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=eu-central-1&operation=invokeTextModel&modelId="
+ BedrockModels.TITAN_TEXT_EXPRESS_V1.model)
.to(result);
from("direct:send_titan_lite")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.TITAN_TEXT_LITE_V1.model)
.to(result);
from("direct:send_titan_image")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeImageModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeImageModel&modelId="
+ BedrockModels.TITAN_IMAGE_GENERATOR_V1.model)
.split(body())
.unmarshal().base64()
@@ -361,12 +360,12 @@ class BedrockProducerIT extends CamelTestSupport {
.to(result);
from("direct:send_titan_embeddings")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeEmbeddingsModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeEmbeddingsModel&modelId="
+ BedrockModels.TITAN_EMBEDDINGS_G1.model)
.to(result);
from("direct:send_jurassic2_model")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.JURASSIC2_ULTRA.model)
.split(body())
.transform().jq(".data.text")
@@ -374,7 +373,7 @@ class BedrockProducerIT extends CamelTestSupport {
.to(result);
from("direct:send_jurassic2_mid_model")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.JURASSIC2_MID.model)
.split(body())
.transform().jq(".data.text")
@@ -382,25 +381,25 @@ class BedrockProducerIT extends CamelTestSupport {
.to(result);
from("direct:send_anthropic_v1_model")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.ANTROPHIC_CLAUDE_INSTANT_V1.model)
.log("${body}")
.to(result);
from("direct:send_anthropic_v2_model")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.ANTROPHIC_CLAUDE_V2.model)
.log("${body}")
.to(result);
from("direct:send_anthropic_v21_model")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.ANTROPHIC_CLAUDE_V2_1.model)
.log("${body}")
.to(result);
from("direct:send_anthropic_v3_model")
- .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.ANTROPHIC_CLAUDE_V3.model)
.log("Completions: ${body}")
.to(result);