From a7dcd9feec360f8995f99de6f275bbfa7e125778 Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Tue, 21 Jan 2025 14:19:44 -0500 Subject: [PATCH] Bugfix: Add error handling for unreachable cloud when checking vector DB downloads --- .../Chatbook/PromptGenerators/VectorDatabases.wl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/Chatbook/PromptGenerators/VectorDatabases.wl b/Source/Chatbook/PromptGenerators/VectorDatabases.wl index e0cccbe7..5b9ee51e 100644 --- a/Source/Chatbook/PromptGenerators/VectorDatabases.wl +++ b/Source/Chatbook/PromptGenerators/VectorDatabases.wl @@ -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; (* ::**************************************************************************************************************:: *)