Skip to content

Commit

Permalink
Merge pull request #953 from WolframResearch/bugfix/handle-http-100-s…
Browse files Browse the repository at this point in the history
…tatus-code

Bugfix: Handle HTTP status code 100 in responses
  • Loading branch information
rhennigan authored Nov 25, 2024
2 parents 7761527 + 70b066b commit c0e3dc2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion PacletInfo.wl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PacletObject[ <|
"Name" -> "Wolfram/Chatbook",
"PublisherID" -> "Wolfram",
"Version" -> "1.5.2.4",
"Version" -> "1.5.2.5",
"WolframVersion" -> "14.1+",
"Description" -> "Wolfram Notebooks + LLMs",
"License" -> "MIT",
Expand Down
2 changes: 1 addition & 1 deletion Source/Chatbook/LLMUtilities.wl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ extractBodyChunks0 // endDefinition;
(* ::Subsubsection::Closed:: *)
(*apiFailureQ*)
apiFailureQ // beginDefinition;
apiFailureQ[ Failure[ "APIError", KeyValuePattern[ "StatusCode" -> Except[ 200, _Integer ] ] ] ] := True;
apiFailureQ[ Failure[ "APIError", KeyValuePattern[ "StatusCode" -> Except[ 100|200, _Integer ] ] ] ] := True;
apiFailureQ[ _ ] := False;
apiFailureQ // endDefinition;

Expand Down
4 changes: 2 additions & 2 deletions Source/Chatbook/SendChat.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ writeResult[ settings_, container_, cell_, as_Association ] := Enclose[

$lastFullResponseData = <| "Body" -> body, "Processed" -> processed, "Data" -> data |>;

Which[ MatchQ[ as[ "StatusCode" ], Except[ 200, _Integer ] ] || (processed === "" && AssociationQ @ data),
Which[ MatchQ[ as[ "StatusCode" ], Except[ 100|200, _Integer ] ] || (processed === "" && AssociationQ @ data),
writeErrorCell[ cell, $badResponse = Association[ as, "Body" -> body, "BodyJSON" -> data ] ]
,
processed === body === "",
Expand Down Expand Up @@ -2793,7 +2793,7 @@ errorBoxes[ as: KeyValuePattern[ "Error" -> "ServerResponseEmpty" ] ] :=
errorBoxes[ as: KeyValuePattern[ "StatusCode" -> 429 ] ] :=
ToBoxes @ messageFailure[ "RateLimitReached", as ];

errorBoxes[ as: KeyValuePattern[ "StatusCode" -> code: Except[ 200 ] ] ] :=
errorBoxes[ as: KeyValuePattern[ "StatusCode" -> code: Except[ 100|200 ] ] ] :=
ToBoxes @ messageFailure[ "UnknownStatusCode", as ];

errorBoxes[ failure_Failure ] :=
Expand Down

0 comments on commit c0e3dc2

Please sign in to comment.