Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Fix Books & Documents recipe loading under CSP (#15045)
Lee Jackson85d63e07496d
diff --git a/studio/frontend/src/features/data-recipes/learning-recipes/index.ts b/studio/frontend/src/features/data-recipes/learning-recipes/index.tsindex 6b68a75b9c2..8a2d962f225 100644--- a/studio/frontend/src/features/data-recipes/learning-recipes/index.ts+++ b/studio/frontend/src/features/data-recipes/learning-recipes/index.ts@@ -3,28 +3,35 @@import type { RecipePayload } from "@/features/recipe-studio";+// Templates are fetched under a same-origin CSP; small JSON files must not become data: URLs.const structuredOutputsJinjaUrl = new URL(- "./structured-outputs-jinja.json",+ "./structured-outputs-jinja.json?no-inline",+ import.meta.url,+).href;+const pdfGroundedQaUrl = new URL(+ "./pdf-grounded-qa.json?no-inline",import.meta.url,).href;-const pdfGroundedQaUrl = new URL("./pdf-grounded-qa.json", import.meta.url)- .href;const instructionFromAnswerUrl = new URL(- "./instruction-from-answer.json",+ "./instruction-from-answer.json?no-inline",import.meta.url,).href;-const textToPythonUrl = new URL("./text-to-python.json", import.meta.url).href;-const textToSqlUrl = new URL("./text-to-sql.json", import.meta.url).href;+const textToPythonUrl = new URL(+ "./text-to-python.json?no-inline",+ import.meta.url,+).href;+const textToSqlUrl = new URL("./text-to-sql.json?no-inline", import.meta.url)+ .href;const ocrDocumentExtractionUrl = new URL(- "./ocr-document-extraction.json",+ "./ocr-document-extraction.json?no-inline",import.meta.url,).href;const githubSupportBotUrl = new URL(- "./github-support-bot.json",+ "./github-support-bot.json?no-inline",import.meta.url,).href;const booksAndDocumentsUrl = new URL(- "./books-and-documents.json",+ "./books-and-documents.json?no-inline",import.meta.url,).href;diff --git a/studio/frontend/tests/learning-recipe-assets.test.ts b/studio/frontend/tests/learning-recipe-assets.test.tsnew file mode 100644index 00000000000..0f2cd9577eb--- /dev/null+++ b/studio/frontend/tests/learning-recipe-assets.test.ts@@ -0,0 +1,52 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import test from "node:test";+import { fileURLToPath } from "node:url";+import { build } from "vite";++test("production learning recipes emit JSON assets fetchable under the same-origin CSP", async () => {+ const result = await build({+ configFile: false,+ root: fileURLToPath(new URL("../", import.meta.url)),+ logLevel: "silent",+ build: {+ write: false,+ minify: false,+ rolldownOptions: {+ input: fileURLToPath(+ new URL(+ "../src/features/data-recipes/learning-recipes/index.ts",+ import.meta.url,+ ),+ ),+ preserveEntrySignatures: "strict",+ },+ },+ });+ assert(!Array.isArray(result) && "output" in result);+ const books = result.output.find(+ (file) =>+ file.type === "asset" &&+ /books-and-documents-.*\.json$/.test(file.fileName),+ );+ assert(+ books?.type === "asset",+ "the small books template must be emitted as a JSON file",+ );+ const source =+ typeof books.source === "string"+ ? books.source+ : new TextDecoder().decode(books.source);+ assert(Array.isArray(JSON.parse(source).recipe.columns));+ for (const file of result.output) {+ if (file.type === "chunk") {+ assert.doesNotMatch(+ file.code,+ /data:application\/json/,+ "fetching an inline template is blocked by Unsloth's connect-src policy",+ );+ }+ }+});