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/04/05 05:04:41 UTC
(camel) branch main updated (31699bd91c8 -> 650e1aa9166)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from 31699bd91c8 camel-smb: polish
new ed12b8a0d1c CAMEL-20562 - Camel-AWS-Bedrock: Support Mistral AI models - Mistral 8x7B Instruct
new 650e1aa9166 CAMEL-20562 - Camel-AWS-Bedrock: Support Mistral AI models - Mistral 8x7B Instruct
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../component/aws2/bedrock/BedrockModels.java | 3 ++-
.../aws2/bedrock/runtime/BedrockProducer.java | 2 +-
.../runtime/integration/BedrockProducerIT.java | 29 ++++++++++++++++++++++
3 files changed, 32 insertions(+), 2 deletions(-)
(camel) 01/02: CAMEL-20562 - Camel-AWS-Bedrock: Support Mistral AI models - Mistral 8x7B Instruct
Posted by ac...@apache.org.
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 ed12b8a0d1c36a8f24376e85eccab8ecfeb14e0d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Apr 5 06:41:52 2024 +0200
CAMEL-20562 - Camel-AWS-Bedrock: Support Mistral AI models - Mistral 8x7B Instruct
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../component/aws2/bedrock/BedrockModels.java | 3 +-
.../aws2/bedrock/runtime/BedrockProducer.java | 2 +-
.../runtime/integration/BedrockProducerIT.java | 57 ++++++++++++++++------
3 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/BedrockModels.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/BedrockModels.java
index c7688b50286..af463f63bb7 100644
--- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/BedrockModels.java
+++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/BedrockModels.java
@@ -29,7 +29,8 @@ public enum BedrockModels {
ANTROPHIC_CLAUDE_V2_1("anthropic.claude-v2:1"),
ANTROPHIC_CLAUDE_V3("anthropic.claude-3-sonnet-20240229-v1:0"),
ANTROPHIC_CLAUDE_HAIKU_V3("anthropic.claude-3-haiku-20240307-v1:0"),
- MISTRAL_7B_INSTRUCT("mistral.mistral-7b-instruct-v0:2");
+ MISTRAL_7B_INSTRUCT("mistral.mistral-7b-instruct-v0:2"),
+ MISTRAL_8x7B_INSTRUCT("mistral.mixtral-8x7b-instruct-v0:1");
public final String model;
diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java
index 8a2a3fffdd0..f7d18e5e46f 100644
--- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java
+++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockProducer.java
@@ -256,7 +256,7 @@ public class BedrockProducer extends DefaultProducer {
throw new RuntimeException(e);
}
}
- case "mistral.mistral-7b-instruct-v0:2" -> {
+ case "mistral.mistral-7b-instruct-v0:2", "mistral.mixtral-8x7b-instruct-v0:1" -> {
try {
setMistralText(result, message);
} catch (JsonProcessingException e) {
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 52111a22f97..7645771da1c 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 {
@@ -397,23 +397,46 @@ class BedrockProducerIT extends CamelTestSupport {
MockEndpoint.assertIsSatisfied(context);
}
+ @Test
+ public void testInvokeMistral8x7BInstructModel() throws InterruptedException {
+
+ result.expectedMessageCount(1);
+ final Exchange result = template.send("direct:send_mistral_8x7b_instruct_model", exchange -> {
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectNode rootNode = mapper.createObjectNode();
+ rootNode.putIfAbsent("prompt",
+ new TextNode("\"<s>[INST] Can you tell the history of Mayflower? [/INST]\\\""));
+
+ rootNode.putIfAbsent("max_tokens", new IntNode(300));
+ rootNode.putIfAbsent("temperature", new DoubleNode(0.5));
+ rootNode.putIfAbsent("top_p", new DoubleNode(0.9));
+ rootNode.putIfAbsent("top_k", new IntNode(50));
+
+ 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");
+ });
+
+ MockEndpoint.assertIsSatisfied(context);
+ }
+
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@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()
@@ -421,12 +444,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")
@@ -434,7 +457,7 @@ class BedrockProducerIT extends CamelTestSupport {
.to(result);
from("direct:send_jurassic2_mid_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_MID.model)
.split(body())
.transform().jq(".data.text")
@@ -442,40 +465,46 @@ 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);
from("direct:send_anthropic_v3_haiku_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_HAIKU_V3.model)
.log("Completions: ${body}")
.to(result);
from("direct:send_mistral_7b_instruct_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.MISTRAL_7B_INSTRUCT.model)
.log("Completions: ${body}")
.to(result);
+
+ from("direct:send_mistral_8x7b_instruct_model")
+ .to("aws-bedrock:label?useDefaultCredentialsProvider=true®ion=us-east-1&operation=invokeTextModel&modelId="
+ + BedrockModels.MISTRAL_8x7B_INSTRUCT.model)
+ .log("Completions: ${body}")
+ .to(result);
}
};
}
(camel) 02/02: CAMEL-20562 - Camel-AWS-Bedrock: Support Mistral AI models - Mistral 8x7B Instruct
Posted by ac...@apache.org.
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 650e1aa91665b758d80270af275b384dd08c223d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Apr 5 06:54:16 2024 +0200
CAMEL-20562 - Camel-AWS-Bedrock: Support Mistral AI models - Mistral 8x7B Instruct
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../runtime/integration/BedrockProducerIT.java | 30 +++++++++++-----------
1 file changed, 15 insertions(+), 15 deletions(-)
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 7645771da1c..56908f2ed4c 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 {
@@ -426,17 +426,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()
@@ -444,12 +444,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")
@@ -457,7 +457,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")
@@ -465,43 +465,43 @@ 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);
from("direct:send_anthropic_v3_haiku_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_HAIKU_V3.model)
.log("Completions: ${body}")
.to(result);
from("direct:send_mistral_7b_instruct_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.MISTRAL_7B_INSTRUCT.model)
.log("Completions: ${body}")
.to(result);
from("direct:send_mistral_8x7b_instruct_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.MISTRAL_8x7B_INSTRUCT.model)
.log("Completions: ${body}")
.to(result);