Skip to content

Comments

Handle error message for parse errors#37

Merged
SasinduDilshara merged 4 commits intoballerina-platform:mainfrom
SasinduDilshara:handle-parse-json-error
Mar 17, 2025
Merged

Handle error message for parse errors#37
SasinduDilshara merged 4 commits intoballerina-platform:mainfrom
SasinduDilshara:handle-parse-json-error

Conversation

@SasinduDilshara
Copy link
Contributor

@codecov
Copy link

codecov bot commented Mar 16, 2025

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 72.58%. Comparing base (ad112f5) to head (d2c8f3b).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
ballerina/main.bal 92.85% 1 Missing ⚠️

❌ Your project status has failed because the head coverage (72.58%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #37      +/-   ##
==========================================
+ Coverage   63.79%   72.58%   +8.78%     
==========================================
  Files           6        6              
  Lines         174      186      +12     
  Branches       50       53       +3     
==========================================
+ Hits          111      135      +24     
+ Misses         63       51      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SasinduDilshara SasinduDilshara merged commit f9b959b into ballerina-platform:main Mar 17, 2025
3 of 4 checks passed

const JSON_CONVERSION_ERROR = "FromJsonStringError";
const CONVERSION_ERROR = "ConversionError";
const ERROR_MESSAGE = "Error occurred while converting the LLM response to the given type. Please refined your prompt to get a better result.";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaryamZi Can you review this error message?

return result;
}

isolated function handlepParseResponseError(error chatResponseError) returns error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

isolated function handlepParseResponseError(error chatResponseError) returns error {
if chatResponseError.message().includes(JSON_CONVERSION_ERROR)
|| chatResponseError.message().includes(CONVERSION_ERROR) {
return error(string `${ERROR_MESSAGE}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this just

return error(ERROR_MESSAGE);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add licence headers.

Comment on lines +2 to +4
import ballerinax/azure.openai.chat as azureOpenAIChat;
import ballerinax/openai.chat as openAIChat;
import ballerina/test;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect order.

Comment on lines +16 to +17
anydata content = message["content"];
string contentStr = content.toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ensureType appropriately instead of just taking toString.

return "INVALID";
}

isolated function getTheMockLLMResult(string message) returns string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getMockLLMResult

}

if message.startsWith("What is 1 + 1?") {
return expectedPromptStringForRateBlog3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this variable name rateBlog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unclear error message when the LLM response is not compatible with the expected type

3 participants