File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ public type DefaultBallerinaModelConfig record {|
2626 string accessToken;
2727| };
2828
29+ type ChatCompletionResponse record {
30+ string [] content?;
31+ };
32+
2933# Default Ballerina model chat completion client.
3034public isolated distinct client class DefaultBallerinaModel {
3135 * Model ;
@@ -55,10 +59,11 @@ public isolated distinct client class DefaultBallerinaModel {
5559 return error (string ` LLM call failed: ${check chatResponse .getTextPayload ()}` );
5660 }
5761
58- string | error resp = check chatResponse .getTextPayload ();
59- if resp is error {
60- return error (" Failed to retrieve completion message" , resp );
62+ ChatCompletionResponse chatCompleteResponse = check (check chatResponse .getJsonPayload ()).cloneWithType ();
63+ string []? content = chatCompleteResponse ?.content ;
64+ if content is () {
65+ return error (" No completion message" );
6166 }
62- return parseResponseAsJson (resp );
67+ return parseResponseAsJson (content [ 0 ] );
6368 }
6469}
You can’t perform that action at this time.
0 commit comments