From aef75f89f4159ad690d084f09e7a6c67cdb958dd Mon Sep 17 00:00:00 2001 From: James Netherton Date: Mon, 22 Jul 2024 10:34:10 +0100 Subject: [PATCH] Upgarde quarkus-langchain4j to 0.16.4 Fixes #6278 --- .../langchain/chat/it/LangChain4jChatResource.java | 5 +++-- .../src/main/resources/application.properties | 5 +++++ .../test/resources/mappings/multipleMessages.json | 10 +++++----- .../src/test/resources/mappings/promptMessage.json | 12 ++++++------ .../src/test/resources/mappings/simpleMessage.json | 12 ++++++------ pom.xml | 2 +- poms/bom/src/main/generated/flattened-full-pom.xml | 4 ++-- .../bom/src/main/generated/flattened-reduced-pom.xml | 4 ++-- .../main/generated/flattened-reduced-verbose-pom.xml | 4 ++-- 9 files changed, 32 insertions(+), 26 deletions(-) diff --git a/integration-tests/langchain4j-chat/src/main/java/org/apache/camel/quarkus/component/langchain/chat/it/LangChain4jChatResource.java b/integration-tests/langchain4j-chat/src/main/java/org/apache/camel/quarkus/component/langchain/chat/it/LangChain4jChatResource.java index d62a03dd6c7c..f25eb311784b 100644 --- a/integration-tests/langchain4j-chat/src/main/java/org/apache/camel/quarkus/component/langchain/chat/it/LangChain4jChatResource.java +++ b/integration-tests/langchain4j-chat/src/main/java/org/apache/camel/quarkus/component/langchain/chat/it/LangChain4jChatResource.java @@ -34,6 +34,7 @@ import org.apache.camel.ProducerTemplate; import org.apache.camel.component.langchain4j.chat.LangChain4jChat; import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.util.ObjectHelper; @Path("/langchain4j-chat") @ApplicationScoped @@ -94,8 +95,8 @@ public Response sendMultipleMessage() throws Exception { MockEndpoint mockEndpoint = context.getEndpoint("mock:multipleMessageResponse", MockEndpoint.class); mockEndpoint.expectedMessageCount(1); mockEndpoint.expectedMessagesMatches(exchange -> { - String body = exchange.getMessage().getBody(String.class); - return body.trim().contains("I would recommend"); + String chatResponse = exchange.getMessage().getBody(String.class); + return ObjectHelper.isNotEmpty(chatResponse); }); List messages = new ArrayList<>(); diff --git a/integration-tests/langchain4j-chat/src/main/resources/application.properties b/integration-tests/langchain4j-chat/src/main/resources/application.properties index b73f854d928d..c71873874466 100644 --- a/integration-tests/langchain4j-chat/src/main/resources/application.properties +++ b/integration-tests/langchain4j-chat/src/main/resources/application.properties @@ -17,3 +17,8 @@ quarkus.langchain4j.ollama.chat-model.model-id=orca-mini quarkus.langchain4j.ollama.chat-model.temperature=0.3 quarkus.langchain4j.ollama.timeout=30s + +# Uncomment to log HTTP traffic between langchain4j & the LLM API +#quarkus.rest-client.logging.scope=request-response +#quarkus.rest-client.logging.body-limit=10000 +#quarkus.log.category."org.jboss.resteasy.reactive.client.logging".level=DEBUG diff --git a/integration-tests/langchain4j-chat/src/test/resources/mappings/multipleMessages.json b/integration-tests/langchain4j-chat/src/test/resources/mappings/multipleMessages.json index f18bf54a51e1..ae4155d28c88 100644 --- a/integration-tests/langchain4j-chat/src/test/resources/mappings/multipleMessages.json +++ b/integration-tests/langchain4j-chat/src/test/resources/mappings/multipleMessages.json @@ -1,24 +1,24 @@ { - "id" : "5720afb6-10d1-4038-8f8f-f08d89180b14", + "id" : "dd4c47e5-d189-437f-b4fb-cdb3007d6271", "name" : "api_chat", "request" : { "url" : "/api/chat", "method" : "POST", "bodyPatterns" : [ { - "equalToJson" : "{\"model\":\"orca-mini\",\"messages\":[{\"role\":\"SYSTEM\",\"content\":\"You are asked to provide recommendations for a restaurant based on user reviews.\"},{\"role\":\"USER\",\"content\":\"Hello, my name is Karen.\"},{\"role\":\"ASSISTANT\",\"content\":\"Hello Karen, how can I help you?\"},{\"role\":\"USER\",\"content\":\"I\\u0027d like you to recommend a restaurant for me.\"},{\"role\":\"ASSISTANT\",\"content\":\"Sure, what type of cuisine are you interested in?\"},{\"role\":\"USER\",\"content\":\"I\\u0027d like Moroccan food.\"},{\"role\":\"ASSISTANT\",\"content\":\"Sure, do you have a preference for the location?\"},{\"role\":\"USER\",\"content\":\"Paris, Rue Montorgueil.\"}],\"options\":{\"temperature\":0.3},\"stream\":false}", + "equalToJson" : "{\n \"model\" : \"orca-mini\",\n \"messages\" : [ {\n \"role\" : \"system\",\n \"content\" : \"You are asked to provide recommendations for a restaurant based on user reviews.\"\n }, {\n \"role\" : \"user\",\n \"content\" : \"Hello, my name is Karen.\"\n }, {\n \"role\" : \"assistant\",\n \"content\" : \"Hello Karen, how can I help you?\"\n }, {\n \"role\" : \"user\",\n \"content\" : \"I'd like you to recommend a restaurant for me.\"\n }, {\n \"role\" : \"assistant\",\n \"content\" : \"Sure, what type of cuisine are you interested in?\"\n }, {\n \"role\" : \"user\",\n \"content\" : \"I'd like Moroccan food.\"\n }, {\n \"role\" : \"assistant\",\n \"content\" : \"Sure, do you have a preference for the location?\"\n }, {\n \"role\" : \"user\",\n \"content\" : \"Paris, Rue Montorgueil.\"\n } ],\n \"options\" : {\n \"temperature\" : 0.3,\n \"top_k\" : 40,\n \"top_p\" : 0.9\n },\n \"stream\" : false\n}", "ignoreArrayOrder" : true, "ignoreExtraElements" : true } ] }, "response" : { "status" : 200, - "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2024-05-02T08:23:51.41574263Z\",\"message\":{\"role\":\"assistant\",\"content\":\" Based on user reviews, I would recommend La Renaissance de la cuisine marocaine. It has received positive ratings for its delicious Moroccan food and friendly service. The restaurant is located at 35 rue Montorgueil, Paris, France. You can check out their menu and reviews on their website or social media pages.\"},\"done\":true,\"total_duration\":6541034901,\"load_duration\":397036,\"prompt_eval_count\":153,\"prompt_eval_duration\":2982821000,\"eval_count\":68,\"eval_duration\":3556417000}", + "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2024-07-22T09:22:54.577581434Z\",\"message\":{\"role\":\"assistant\",\"content\":\" Based on user reviews, I would recommend La Petite Farine. It has received excellent ratings for Moroccan cuisine and has a great atmosphere. Customers rave about the delicious food and the friendly service. Check it out at https://www.restaurant-la-petite-farine.com/\"},\"done\":true,\"total_duration\":3301943840,\"load_duration\":356730,\"prompt_eval_duration\":51587000,\"eval_count\":64,\"eval_duration\":3248817000}", "headers" : { - "Date" : "Thu, 02 May 2024 08:23:51 GMT", + "Date" : "Mon, 22 Jul 2024 09:22:54 GMT", "Content-Type" : "application/json; charset=utf-8" } }, - "uuid" : "5720afb6-10d1-4038-8f8f-f08d89180b14", + "uuid" : "dd4c47e5-d189-437f-b4fb-cdb3007d6271", "persistent" : true, "insertionIndex" : 3 } \ No newline at end of file diff --git a/integration-tests/langchain4j-chat/src/test/resources/mappings/promptMessage.json b/integration-tests/langchain4j-chat/src/test/resources/mappings/promptMessage.json index 3971db1c2199..94f7328ddbd2 100644 --- a/integration-tests/langchain4j-chat/src/test/resources/mappings/promptMessage.json +++ b/integration-tests/langchain4j-chat/src/test/resources/mappings/promptMessage.json @@ -1,24 +1,24 @@ { - "id" : "6d1d4506-a77f-46c6-81c5-068ab78b372d", + "id" : "7a17ef92-ee87-4291-a924-40289295573d", "name" : "api_chat", "request" : { "url" : "/api/chat", "method" : "POST", "bodyPatterns" : [ { - "equalToJson" : "{\"model\":\"orca-mini\",\"messages\":[{\"role\":\"USER\",\"content\":\"Create a recipe for a oven dish with the following ingredients: potato, tomato, feta, olive oil\"}],\"options\":{\"temperature\":0.3},\"stream\":false}", + "equalToJson" : "{\n \"model\" : \"orca-mini\",\n \"messages\" : [ {\n \"role\" : \"user\",\n \"content\" : \"Create a recipe for a oven dish with the following ingredients: potato, tomato, feta, olive oil\"\n } ],\n \"options\" : {\n \"temperature\" : 0.3,\n \"top_k\" : 40,\n \"top_p\" : 0.9\n },\n \"stream\" : false\n}", "ignoreArrayOrder" : true, "ignoreExtraElements" : true } ] }, "response" : { "status" : 200, - "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2024-05-02T08:22:19.097855836Z\",\"message\":{\"role\":\"assistant\",\"content\":\" Sure, here's a simple recipe for an oven dish with potato, tomato, feta and olive oil:\\n\\nIngredients:\\n- 1 medium-sized potato\\n- 1 medium-sized tomato\\n- 1/2 cup crumbled feta cheese\\n- 2 tablespoons olive oil\\n\\nInstructions:\\n1. Preheat the oven to 375°F (190°C).\\n2. Cut the potato into small cubes and place them in a baking dish.\\n3. Slice the tomato into thin strips and add them to the baking dish.\\n4. Sprinkle the crumbled feta cheese over the top of the potato and tomato mixture.\\n5. Drizzle 2 tablespoons of olive oil over the top of the dish.\\n6. Bake the dish in the preheated oven for about 30-35 minutes, or until the potatoes are tender and the cheese is melted and golden brown.\\n7. Serve hot as a side dish with your favorite main course.\\n\\nEnjoy your delicious oven dish made with potato, tomato, feta, and olive oil!\"},\"done\":true,\"total_duration\":13330355061,\"load_duration\":382950,\"prompt_eval_count\":28,\"prompt_eval_duration\":551261000,\"eval_count\":245,\"eval_duration\":12777780000}", + "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2024-07-22T09:14:41.627539463Z\",\"message\":{\"role\":\"assistant\",\"content\":\" Here's a simple recipe for a delicious oven dish with potatoes, tomato, feta and olive oil:\\n\\nIngredients:\\n- 2 medium-sized potatoes, peeled and chopped into small pieces\\n- 1 medium-sized tomato, chopped\\n- 1/2 cup crumbled feta cheese\\n- 2 tablespoons olive oil\\n\\nInstructions:\\n\\n1. Preheat the oven to 375°F (190°C).\\n\\n2. In a baking dish, mix together the chopped potatoes, tomato, and crumbled feta cheese.\\n\\n3. Drizzle the olive oil over the mixture and toss everything together until evenly coated.\\n\\n4. Bake the potato dish in the preheated oven for 30-35 minutes or until the top is golden brown and crispy.\\n\\n5. Remove from the oven and let it cool for a few minutes before serving.\\n\\nEnjoy your delicious oven dish with potatoes, tomato, feta, and olive oil!\"},\"done\":true,\"total_duration\":11573233199,\"load_duration\":561525,\"prompt_eval_duration\":52398000,\"eval_count\":222,\"eval_duration\":11519384000}", "headers" : { - "Date" : "Thu, 02 May 2024 08:22:19 GMT", + "Date" : "Mon, 22 Jul 2024 09:14:41 GMT", "Content-Type" : "application/json; charset=utf-8" } }, - "uuid" : "6d1d4506-a77f-46c6-81c5-068ab78b372d", + "uuid" : "7a17ef92-ee87-4291-a924-40289295573d", "persistent" : true, - "insertionIndex" : 2 + "insertionIndex" : 3 } \ No newline at end of file diff --git a/integration-tests/langchain4j-chat/src/test/resources/mappings/simpleMessage.json b/integration-tests/langchain4j-chat/src/test/resources/mappings/simpleMessage.json index c258ed1e723c..75231cd4b89a 100644 --- a/integration-tests/langchain4j-chat/src/test/resources/mappings/simpleMessage.json +++ b/integration-tests/langchain4j-chat/src/test/resources/mappings/simpleMessage.json @@ -1,24 +1,24 @@ { - "id" : "27d02f6b-e565-48b5-a64e-2e91590ff224", + "id" : "4b34d025-3895-4bd9-80f9-dce99fad4012", "name" : "api_chat", "request" : { "url" : "/api/chat", "method" : "POST", "bodyPatterns" : [ { - "equalToJson" : "{\"model\":\"orca-mini\",\"messages\":[{\"role\":\"USER\",\"content\":\"Hello my name is Darth Vader!\"}],\"options\":{\"temperature\":0.3},\"stream\":false}", + "equalToJson" : "{\n \"model\" : \"orca-mini\",\n \"messages\" : [ {\n \"role\" : \"user\",\n \"content\" : \"Hello my name is Darth Vader!\"\n } ],\n \"options\" : {\n \"temperature\" : 0.3,\n \"top_k\" : 40,\n \"top_p\" : 0.9\n },\n \"stream\" : false\n}", "ignoreArrayOrder" : true, "ignoreExtraElements" : true } ] }, "response" : { "status" : 200, - "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2024-05-02T08:21:13.635823801Z\",\"message\":{\"role\":\"assistant\",\"content\":\" Hello, I'm your friendly AI assistant. How may I assist you today?\"},\"done\":true,\"total_duration\":2371281081,\"load_duration\":577023282,\"prompt_eval_count\":49,\"prompt_eval_duration\":946565000,\"eval_count\":18,\"eval_duration\":847072000}", + "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2024-07-22T09:15:12.778157441Z\",\"message\":{\"role\":\"assistant\",\"content\":\" Hello, I am your loyal AI assistant. Is there anything I can assist you with today?\"},\"done\":true,\"total_duration\":1277036396,\"load_duration\":576934,\"prompt_eval_count\":16,\"prompt_eval_duration\":324714000,\"eval_count\":20,\"eval_duration\":950928000}", "headers" : { - "Date" : "Thu, 02 May 2024 08:21:13 GMT", + "Date" : "Mon, 22 Jul 2024 09:15:12 GMT", "Content-Type" : "application/json; charset=utf-8" } }, - "uuid" : "27d02f6b-e565-48b5-a64e-2e91590ff224", + "uuid" : "4b34d025-3895-4bd9-80f9-dce99fad4012", "persistent" : true, - "insertionIndex" : 1 + "insertionIndex" : 3 } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 669e7a31dae7..d3ae1756b767 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ 2.0.2 3.1.2 3.0.8 - 0.16.2 + 0.16.4 3.2.4 3.7.5 2.2.3 diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index 4cbb62407e13..2fbb5fd8a920 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -6723,12 +6723,12 @@ io.quarkiverse.langchain4j quarkus-langchain4j-core - 0.16.2 + 0.16.4 io.quarkiverse.langchain4j quarkus-langchain4j-core-deployment - 0.16.2 + 0.16.4 io.quarkiverse.messaginghub diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml index 7c359f7532ab..e541d9270161 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -6693,12 +6693,12 @@ io.quarkiverse.langchain4j quarkus-langchain4j-core - 0.16.2 + 0.16.4 io.quarkiverse.langchain4j quarkus-langchain4j-core-deployment - 0.16.2 + 0.16.4 io.quarkiverse.messaginghub diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml index 5170b3dc1893..ec3c3df0cba3 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -6693,12 +6693,12 @@ io.quarkiverse.langchain4j quarkus-langchain4j-core - 0.16.2 + 0.16.4 io.quarkiverse.langchain4j quarkus-langchain4j-core-deployment - 0.16.2 + 0.16.4 io.quarkiverse.messaginghub