Handle error message for parse errors#37
Handle error message for parse errors#37SasinduDilshara merged 4 commits intoballerina-platform:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is
❌ 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. 🚀 New features to boost your workflow:
|
f9b959b
into
ballerina-platform:main
|
|
||
| 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."; |
There was a problem hiding this comment.
@MaryamZi Can you review this error message?
| return result; | ||
| } | ||
|
|
||
| isolated function handlepParseResponseError(error chatResponseError) returns error { |
| isolated function handlepParseResponseError(error chatResponseError) returns error { | ||
| if chatResponseError.message().includes(JSON_CONVERSION_ERROR) | ||
| || chatResponseError.message().includes(CONVERSION_ERROR) { | ||
| return error(string `${ERROR_MESSAGE}`); |
There was a problem hiding this comment.
Why isn't this just
return error(ERROR_MESSAGE);
| import ballerinax/azure.openai.chat as azureOpenAIChat; | ||
| import ballerinax/openai.chat as openAIChat; | ||
| import ballerina/test; |
| anydata content = message["content"]; | ||
| string contentStr = content.toString(); |
There was a problem hiding this comment.
Use ensureType appropriately instead of just taking toString.
| return "INVALID"; | ||
| } | ||
|
|
||
| isolated function getTheMockLLMResult(string message) returns string { |
| } | ||
|
|
||
| if message.startsWith("What is 1 + 1?") { | ||
| return expectedPromptStringForRateBlog3; |
There was a problem hiding this comment.
Why is this variable name rateBlog?
Fixes ballerina-platform/ballerina-library#7695