(camel) 01/02: CAMEL-20562 - Camel-AWS-Bedrock: Support Mistral AI models - Mistral 8x7B Instruct
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 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 --- .../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("\"[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)); +
(camel) 01/02: CAMEL-20562 - Camel-AWS-Bedrock: Support Mistral AI models - Mistral 8x7B Instruct
This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch CAMEL-20562-8x7b-mistral in repository https://gitbox.apache.org/repos/asf/camel.git commit 479faf9b093ff09f066673ad014597d746e501e5 Author: Andrea Cosentino 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 --- .../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("\"[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().writeValueAsStrin