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
Studio: let imported chats with image links answer follow-up questions (#13099)
Nilayc2c197d8b2b4
diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.tsindex 981b7631f4f..ce1ba496a39 100644--- a/studio/frontend/src/features/chat/api/chat-adapter.ts+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts@@ -849,7 +849,9 @@ function collectImageParts(parts.push({type: "image_url",image_url: {- url: src.startsWith("data:") ? src : `data:image/png;base64,${src}`,+ url: /^(?:data:|https?:\/\/)/i.test(src)+ ? src+ : `data:image/png;base64,${src}`,},});};diff --git a/studio/frontend/tests/image-url-replay.test.ts b/studio/frontend/tests/image-url-replay.test.tsnew file mode 100644index 00000000000..6cc4933e98f--- /dev/null+++ b/studio/frontend/tests/image-url-replay.test.ts@@ -0,0 +1,72 @@+// 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 ts from "typescript";++import { readSrc } from "./helpers/kit.ts";++const adapterSource = readSrc("features/chat/api/chat-adapter.ts");++function liftAdapterFunction(opener: string): string {+ const start = adapterSource.indexOf(opener);+ assert.ok(start >= 0, `${opener} is no longer defined in chat-adapter.ts`);+ const end = adapterSource.indexOf("\n}", start);+ assert.ok(end > start, `could not find the end of ${opener}`);+ return adapterSource.slice(start, end + 2);+}++const serializeJs = ts.transpileModule(+ [+ "function modelVisibleMessage(message) { return message; }",+ "function serializeAssistantReplayMessages() { throw new Error('not under test'); }",+ liftAdapterFunction("function collectTextParts("),+ liftAdapterFunction("function collectImageParts("),+ liftAdapterFunction("function buildReplayContent("),+ liftAdapterFunction("function toOpenAIMessages("),+ "return { toOpenAIMessages };",+ ].join("\n\n"),+ { compilerOptions: { target: ts.ScriptTarget.ES2022 } },+).outputText;++const { toOpenAIMessages } = new Function(serializeJs)() as {+ toOpenAIMessages: (+ message: unknown,+ ) => Array<{ role: string; content: unknown }>;+};++function replayedImageUrl(image: string): string {+ const [serialized] = toOpenAIMessages({+ role: "user",+ content: [+ { type: "text", text: "what is this?" },+ { type: "image", image },+ ],+ });+ const parts = serialized.content as Array<{+ type: string;+ image_url?: { url: string };+ }>;+ return parts[1].image_url!.url;+}++test("an imported https image is replayed as the same url", () => {+ const url = "https://example.com/photos/cat.jpg";+ assert.equal(replayedImageUrl(url), url);+});++test("an http image url is replayed unchanged too", () => {+ const url = "HTTP://example.com/cat.png";+ assert.equal(replayedImageUrl(url), url);+});++test("a data url image is replayed unchanged", () => {+ const url = "data:image/jpeg;base64,aGVsbG8=";+ assert.equal(replayedImageUrl(url), url);+});++test("bare base64 is still wrapped as a png data url", () => {+ assert.equal(replayedImageUrl("aGVsbG8="), "data:image/png;base64,aGVsbG8=");+});