@@ -12,6 +12,7 @@ Needs[ "Wolfram`Chatbook`Common`" ];
1212(*Configuration*)
1313$snippetType = "Text" ;
1414$documentationSnippetVersion := $snippetVersion ;
15+ $snippetFetchBatchSize = 25 ;
1516$baseURL = "https://www.wolframcloud.com/obj/wolframai-content/DocumentationSnippets" ;
1617$documentationSnippetBaseURL := URLBuild @ { $baseURL , $documentationSnippetVersion , $snippetType };
1718$documentationMarkdownBaseURL := URLBuild @ { $baseURL , $documentationSnippetVersion , "Markdown" };
@@ -103,6 +104,7 @@ $RelatedDocumentationSources = Automatic;
103104(*RelatedDocumentation*)
104105RelatedDocumentation // beginDefinition ;
105106RelatedDocumentation // Options = {
107+ "DownloadBatchSize" -> $snippetFetchBatchSize ,
106108 "FilteredCount" -> Automatic ,
107109 "FilterResults" -> Automatic ,
108110 "LLMEvaluator" -> Automatic ,
@@ -173,10 +175,12 @@ RelatedDocumentation[ All, "URIs", Automatic, opts: OptionsPattern[ ] ] := catch
173175RelatedDocumentation [ prompt : $$prompt , "Snippets" , Automatic , opts : OptionsPattern [ ] ] := catchMine @ Enclose [
174176 ConfirmMatch [
175177 (* TODO: filter results *)
176- DeleteMissing @ makeDocSnippets @ vectorDBSearch [
177- getSources [ prompt , OptionValue [ "Sources" ], OptionValue [ "MaxSources" ] ],
178- prompt ,
179- "Results"
178+ Block [ { $snippetFetchBatchSize = OptionValue [ "DownloadBatchSize" ] },
179+ DeleteMissing @ makeDocSnippets @ vectorDBSearch [
180+ getSources [ prompt , OptionValue [ "Sources" ], OptionValue [ "MaxSources" ] ],
181+ prompt ,
182+ "Results"
183+ ]
180184 ],
181185 { ___ String },
182186 "Snippets"
@@ -252,7 +256,8 @@ RelatedDocumentation[ prompt_, "Prompt", n_Integer, opts: OptionsPattern[ ] ] :=
252256 OptionValue [ "PromptHeader" ],
253257 $$unspecified :> $usePromptHeader
254258 ],
255- $RelatedDocumentationSources = getSources [ prompt , OptionValue [ "Sources" ], OptionValue [ "MaxSources" ] ]
259+ $RelatedDocumentationSources = getSources [ prompt , OptionValue [ "Sources" ], OptionValue [ "MaxSources" ] ],
260+ $snippetFetchBatchSize = OptionValue [ "DownloadBatchSize" ]
256261 },
257262 relatedDocumentationPrompt [
258263 ensureChatMessages @ prompt ,
@@ -1177,6 +1182,9 @@ fetchDocumentationSnippets // beginDefinition;
11771182
11781183fetchDocumentationSnippets [ { } ] := { };
11791184
1185+ fetchDocumentationSnippets [ uris : { __ String } ] /; Length @ uris > $snippetFetchBatchSize :=
1186+ Flatten [ fetchDocumentationSnippets /@ TakeDrop [ uris , $snippetFetchBatchSize ] ];
1187+
11801188fetchDocumentationSnippets [ uris : { __ String } ] := Enclose [
11811189 Module [ { count , text , $results , tasks },
11821190 count = Length @ uris ;
0 commit comments