From 89be0cdee4e5b8ff2bfdf4c40f3949622440de90 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Wed, 19 Mar 2025 09:42:53 +0530 Subject: [PATCH 1/4] Update error message for client errors --- ballerina/main.bal | 4 ++-- ballerina/tests/tests.bal | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ballerina/main.bal b/ballerina/main.bal index 35439d2..1789b8d 100644 --- a/ballerina/main.bal +++ b/ballerina/main.bal @@ -16,7 +16,7 @@ const JSON_CONVERSION_ERROR = "FromJsonStringError"; const CONVERSION_ERROR = "ConversionError"; -const ERROR_MESSAGE = "Error occurred while converting the LLM response to the given type. Please refine your prompt to get a better result."; +const ERROR_MESSAGE = "Error occurred while converting the LLM response to the given type. This could happen if the response format is unexpected or contains invalid data."; type DefaultModelConfig DefaultAzureOpenAIModelConfig|DefaultOpenAIModelConfig|DefaultBallerinaModelConfig; @@ -119,7 +119,7 @@ isolated function parseResponseAsType(json resp, typedesc targetType) retu isolated function handlepParseResponseError(error chatResponseError) returns error { if chatResponseError.message().includes(JSON_CONVERSION_ERROR) || chatResponseError.message().includes(CONVERSION_ERROR) { - return error(string `${ERROR_MESSAGE}`); + return error(string `${ERROR_MESSAGE}`, detail = chatResponseError); } return chatResponseError; } diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index bed42a8..f334eb0 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -16,7 +16,7 @@ import ballerina/test; -const ERROR_MESSAGE = "Error occurred while converting the LLM response to the given type. Please refine your prompt to get a better result."; +const ERROR_MESSAGE = "Error occurred while converting the LLM response to the given type. This could happen if the response format is unexpected or contains invalid data."; @test:Config function testPromptAsCodeFunctionWithSimpleExpectedTypeWithDefaultAzureOpenAIClient() returns error? { From 1f9ddafe8cea8330d2b90b4818e431a29946a5cb Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Wed, 19 Mar 2025 09:44:02 +0530 Subject: [PATCH 2/4] [Automated] Update the native jar versions --- ballerina/Ballerina.toml | 6 +++--- ballerina/CompilerPlugin.toml | 2 +- ballerina/Dependencies.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 36dad2d..72efae8 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerinax" name = "np" -version = "0.8.0" +version = "0.8.1" authors = ["Ballerina"] keywords = ["natural programming", "ai"] repository = "https://github.com/ballerina-platform/module-ballerinax-np" @@ -17,5 +17,5 @@ observabilityIncluded = true [[platform.java21.dependency]] groupId = "io.ballerina.lib" artifactId = "np-native" -version = "0.8.0" -path = "../native/build/libs/np-native-0.8.0.jar" +version = "0.8.1" +path = "../native/build/libs/np-native-0.8.1-SNAPSHOT.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index ee1b152..2d92368 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "np-compiler-plugin" class = "io.ballerina.lib.np.compilerplugin.CompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/np-compiler-plugin-0.8.0.jar" +path = "../compiler-plugin/build/libs/np-compiler-plugin-0.8.1-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index cd1074d..461aa35 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -335,7 +335,7 @@ modules = [ [[package]] org = "ballerinax" name = "np" -version = "0.8.0" +version = "0.8.1" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "jballerina.java"}, From b64b0c5bcdbb26113d4fc775a309330f43ea4bc0 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Wed, 19 Mar 2025 21:17:45 +0530 Subject: [PATCH 3/4] Update the client error message --- ballerina/main.bal | 2 +- ballerina/tests/tests.bal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ballerina/main.bal b/ballerina/main.bal index 1789b8d..4b0a1bd 100644 --- a/ballerina/main.bal +++ b/ballerina/main.bal @@ -16,7 +16,7 @@ const JSON_CONVERSION_ERROR = "FromJsonStringError"; const CONVERSION_ERROR = "ConversionError"; -const ERROR_MESSAGE = "Error occurred while converting the LLM response to the given type. This could happen if the response format is unexpected or contains invalid data."; +const ERROR_MESSAGE = "Error occurred while attempting to parse the response from the LLM as the expected type. Retrying and/or validating the prompt could fix the response."; type DefaultModelConfig DefaultAzureOpenAIModelConfig|DefaultOpenAIModelConfig|DefaultBallerinaModelConfig; diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index f334eb0..7f08d2c 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -16,7 +16,7 @@ import ballerina/test; -const ERROR_MESSAGE = "Error occurred while converting the LLM response to the given type. This could happen if the response format is unexpected or contains invalid data."; +const ERROR_MESSAGE = "Error occurred while attempting to parse the response from the LLM as the expected type. Retrying and/or validating the prompt could fix the response." @test:Config function testPromptAsCodeFunctionWithSimpleExpectedTypeWithDefaultAzureOpenAIClient() returns error? { From 5b3e58b20147c833c719a3b3d62265c3b015f5fe Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Wed, 19 Mar 2025 21:23:06 +0530 Subject: [PATCH 4/4] Refactor test program --- ballerina/tests/tests.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 7f08d2c..9ad8a25 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -16,7 +16,7 @@ import ballerina/test; -const ERROR_MESSAGE = "Error occurred while attempting to parse the response from the LLM as the expected type. Retrying and/or validating the prompt could fix the response." +const ERROR_MESSAGE = "Error occurred while attempting to parse the response from the LLM as the expected type. Retrying and/or validating the prompt could fix the response."; @test:Config function testPromptAsCodeFunctionWithSimpleExpectedTypeWithDefaultAzureOpenAIClient() returns error? {