Skip to content

Commit

Permalink
Merge pull request #1038 from WolframResearch/1001-need-better-error-…
Browse files Browse the repository at this point in the history
…handling-for-when-cloud-is-unreachable

Bugfix: Add error handling for unreachable cloud when checking vector DB downloads
  • Loading branch information
rhennigan authored Jan 21, 2025
2 parents b2b4077 + a7dcd9f commit 9f93261
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/Chatbook/PromptGenerators/VectorDatabases.wl
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,22 @@ cleanupLegacyVectorDBFiles // endDefinition;
(* ::Subsubsection::Closed:: *)
(*getDownloadSize*)
getDownloadSize // beginDefinition;

getDownloadSize[ url_String ] := getDownloadSize @ CloudObject @ url;
getDownloadSize[ obj: $$cloudObject ] := FileByteCount @ obj;
getDownloadSize[ obj: $$cloudObject ] := getDownloadSize[ obj, FileByteCount @ obj ];
getDownloadSize[ obj_, size_Integer ] := size;

getDownloadSize[ obj_, $Failed ] := throwFailureToChatOutput @ Failure[
"CloudDownloadError",
<|
"MessageTemplate" :> Chatbook::CloudDownloadError,
"MessageParameters" -> { },
"CloudObject" -> obj,
"Evaluation" -> HoldForm @ FileByteCount @ obj,
"Results" -> $Failed
|>
];

getDownloadSize // endDefinition;

(* ::**************************************************************************************************************:: *)
Expand Down

0 comments on commit 9f93261

Please sign in to comment.