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:53 UTC
(camel) 01/08: Camel-AWS-Bedrock: Add documentation for Embeddings Titan G1
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 6fd7a44720b11946da694329edc7b1f3bad4bc5b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Mar 14 10:34:13 2024 +0100
Camel-AWS-Bedrock: Add documentation for Embeddings Titan G1
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../src/main/docs/aws-bedrock-component.adoc | 50 ++++++++++++++++++++++
.../runtime/integration/BedrockProducerIT.java | 22 +++++-----
.../servicebus/client/ServiceBusClientFactory.java | 1 +
3 files changed, 62 insertions(+), 11 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 a436bdb88ef..9f0e4223ac2 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
@@ -252,12 +252,34 @@ Json schema for request
}
--------------------------------------------------------------------------------
+- Titan Embeddings G1 with id `amazon.titan-embed-text-v1`
+The Amazon Titan Embeddings G1 - Text – Text v1.2 can intake up to 8k tokens and outputs a vector of 1,536 dimensions. The model also works in 25+ different language
+
+Json schema for request
+
+[source,json]
+--------------------------------------------------------------------------------
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "inputText": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "inputText"
+ ]
+}
+--------------------------------------------------------------------------------
+
=== Bedrock Producer operations
Camel-AWS Bedrock component provides the following operation on the producer side:
- invokeTextModel
- invokeImageModel
+- invokeEmbeddingsModel
== Producer Examples
@@ -338,6 +360,34 @@ and you can the send to the direct endpoint something like
where template is a ProducerTemplate.
+- invokeEmbeddingsModel: this operation will invoke an Embeddings model from Bedrock. This is an example for Titan Embeddings G1.
+
+[source,java]
+--------------------------------------------------------------------------------
+from("direct:send_titan_embeddings")
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeEmbeddingsModel&modelId="
+ + BedrockModels.TITAN_EMBEDDINGS_G1.model)
+ .to(result);
+--------------------------------------------------------------------------------
+
+and you can the send to the direct endpoint something like
+
+[source,java]
+--------------------------------------------------------------------------------
+ final Exchange result = template.send("direct:send_titan_embeddings", exchange -> {
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectNode rootNode = mapper.createObjectNode();
+ rootNode.putIfAbsent("inputText",
+ new TextNode("A Sci-fi camel running in the desert"));
+
+ exchange.getMessage().setBody(mapper.writer().writeValueAsString(rootNode));
+ exchange.getMessage().setHeader(BedrockConstants.MODEL_CONTENT_TYPE, "application/json");
+ exchange.getMessage().setHeader(BedrockConstants.MODEL_ACCEPT_CONTENT_TYPE, "*/*");
+ });
+--------------------------------------------------------------------------------
+
+where template is a ProducerTemplate.
+
== Dependencies
Maven users will need to add the following dependency to their pom.xml.
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 bfe93173df8..adb4a1a2538 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 {
@@ -342,17 +342,17 @@ class BedrockProducerIT extends CamelTestSupport {
@Override
public void configure() {
from("direct:send_titan_express")
- .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=eu-central-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=eu-central-1&operation=invokeTextModel&modelId="
+ BedrockModels.TITAN_TEXT_EXPRESS_V1.model)
.to(result);
from("direct:send_titan_lite")
- .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.TITAN_TEXT_LITE_V1.model)
.to(result);
from("direct:send_titan_image")
- .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeImageModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeImageModel&modelId="
+ BedrockModels.TITAN_IMAGE_GENERATOR_V1.model)
.split(body())
.unmarshal().base64()
@@ -360,12 +360,12 @@ class BedrockProducerIT extends CamelTestSupport {
.to(result);
from("direct:send_titan_embeddings")
- .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeEmbeddingsModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeEmbeddingsModel&modelId="
+ BedrockModels.TITAN_EMBEDDINGS_G1.model)
.to(result);
from("direct:send_jurassic2_model")
- .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.JURASSIC2_ULTRA.model)
.split(body())
.transform().jq(".data.text")
@@ -381,25 +381,25 @@ class BedrockProducerIT extends CamelTestSupport {
.to(result);
from("direct:send_anthropic_v1_model")
- .to("aws-bedrock:label?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®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?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®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?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®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?accessKey=RAW({{aws.manual.access.key}})&secretKey=RAW({{aws.manual.secret.key}}®ion=us-east-1&operation=invokeTextModel&modelId="
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ BedrockModels.ANTROPHIC_CLAUDE_V3.model)
.log("Completions: ${body}")
.to(result);
diff --git a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
index 225f61da1c0..90173230eb8 100644
--- a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
+++ b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
@@ -21,6 +21,7 @@ import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.messaging.servicebus.ServiceBusClientBuilder;
import com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient;
import com.azure.messaging.servicebus.ServiceBusSenderAsyncClient;
+import com.azure.messaging.servicebus.models.SubQueue;
import org.apache.camel.component.azure.servicebus.CredentialType;
import org.apache.camel.component.azure.servicebus.ServiceBusConfiguration;
import org.apache.camel.component.azure.servicebus.ServiceBusType;