Spaces:
Running
Running
Sync from felladrin/MiniSearch@b72789d
Browse filesFiles changed (8)
189 unmodified lines190191192193194195196189 unmodified lines1. Check the wasm build can run it: the architecture must exist in `node_modules/@wllama/wllama/esm/wasm/wllama.wasm` (grep the binary for the arch name), and the quant must stay under the ceilings in `docs/ai-integration.md` (shard every file under 2000 MiB; total weights under ~3.7 GB)2. Shard the GGUF (`llama-gguf-split --split --size`, or an equivalent) and publish to a `Felladrin/gguf-sharded-<QUANT>-<Name>` repo3. Add to `client/modules/wllama.ts`; thinking-by-default templates need `chatTemplateKwargs: { enable_thinking: false }`4. Run `node scripts/wllama-catalog-check.cjs` and `npx vitest run client/modules/wllama.test.ts`5. Update `docs/ai-integration.md`6. Update `docs/configuration.md` defaults189 unmodified lines190191192193194195196189 unmodified lines1. Check the wasm build can run it: the architecture must exist in `node_modules/@wllama/wllama/esm/wasm/wllama.wasm` (grep the binary for the arch name), and the quant must stay under the ceilings in `docs/ai-integration.md` (shard every file under 2000 MiB; total weights under ~3.7 GB)2. Shard the GGUF (`llama-gguf-split --split --size`, or an equivalent) and publish to a `Felladrin/gguf-sharded-<QUANT>-<Name>` repo3. Add to `client/modules/wllama.ts`; thinking-by-default templates need nothing extra, their `reasoning_content` channel is streamed into the thinking UI4. Run `node scripts/wllama-catalog-check.cjs` and `npx vitest run client/modules/wllama.test.ts`5. Update `docs/ai-integration.md`6. Update `docs/configuration.md` defaults
2 unmodified lines3456782 unmodified linesNotable changes, grouped by date, most recent first.## 2026-11-02- Five new browser models joined the Wllama catalog: Spark X2.6 1.7B, Granite 4.2 3B, Qwen 3.5 4B, Gemma 4 E2B and Spark X2.6 4B, each tested end to end against the shipped wasm build with the search-answer prompt. The Gemma 4 and Qwen 3.5 architectures were previously absent from the catalog, and the new entries run on the wasm engine's supported architectures (`gemma4`, `qwen35`, `spark2_5`, `granite`). Models whose chat template thinks by default ship with `chatTemplateKwargs: { enable_thinking: false }`, a new per-model field passed to wllama as `chat_template_kwargs`, because MiniSearch renders only the content channel and a thinking template would otherwise spend the whole token budget on reasoning and answer with nothing. `docs/ai-integration.md` now records the two measured ceilings a candidate must fit (shard files under 2000 MiB, since Chromium's OPFS silently truncates beyond it; total weights under ~3.7 GB, since the wasm linear memory caps at 4 GiB), and `npm run wllama-catalog-check` HEADs every shard of every catalog model on HuggingFace to verify the claimed sizes.2 unmodified lines3456789101112132 unmodified linesNotable changes, grouped by date, most recent first.## 2026-11-03- The five thinking models added on 2026-11-02 (Spark X2.6 1.7B and 4B, Granite 4.2 3B, Qwen 3.5 4B, Gemma 4 E2B) no longer ship with thinking switched off. Their chain of thought arrives on wllama's `reasoning_content` channel and is now wrapped in the configured reasoning markers, so the existing thinking UI shows it while the model reasons and the answer streams in after. The model warmup counts a reasoning token as a working model, so thinking models no longer log a failed warmup.## 2026-11-02- Five new browser models joined the Wllama catalog: Spark X2.6 1.7B, Granite 4.2 3B, Qwen 3.5 4B, Gemma 4 E2B and Spark X2.6 4B, each tested end to end against the shipped wasm build with the search-answer prompt. The Gemma 4 and Qwen 3.5 architectures were previously absent from the catalog, and the new entries run on the wasm engine's supported architectures (`gemma4`, `qwen35`, `spark2_5`, `granite`). Models whose chat template thinks by default ship with `chatTemplateKwargs: { enable_thinking: false }`, a new per-model field passed to wllama as `chat_template_kwargs`, because MiniSearch renders only the content channel and a thinking template would otherwise spend the whole token budget on reasoning and answer with nothing. `docs/ai-integration.md` now records the two measured ceilings a candidate must fit (shard files under 2000 MiB, since Chromium's OPFS silently truncates beyond it; total weights under ~3.7 GB, since the wasm linear memory caps at 4 GiB), and `npm run wllama-catalog-check` HEADs every shard of every catalog model on HuggingFace to verify the claimed sizes.
2 unmodified lines34567894 unmodified lines14151617181986 unmodified lines1061071082 unmodified linesupdateModelLoadingProgress,updateModelSizeInMegabytes,} from "./pubSub";import { generateTextWithWllama } from "./textGenerationWithWllama";import { initializeWllama } from "./wllama";vi.mock("./logEntries", () => ({ addLogEntry: vi.fn() }));4 unmodified linesenableAiResponse: true,wllamaModelId: "test-model",cpuThreads: 1,}),getTextGenerationState: vi.fn().mockReturnValue("generating"),updateModelLoadingProgress: vi.fn(),86 unmodified linesexpect(updateModelSizeInMegabytes).not.toHaveBeenCalledWith(0);});});2 unmodified lines34567891011124 unmodified lines171819202122232486 unmodified lines1111121131141151161171181191201211221231241251261271281291301312 unmodified linesupdateModelLoadingProgress,updateModelSizeInMegabytes,} from "./pubSub";import {composeStreamedText,generateTextWithWllama,} from "./textGenerationWithWllama";import { initializeWllama } from "./wllama";vi.mock("./logEntries", () => ({ addLogEntry: vi.fn() }));4 unmodified linesenableAiResponse: true,wllamaModelId: "test-model",cpuThreads: 1,reasoningStartMarker: "<think>",reasoningEndMarker: "</think>",}),getTextGenerationState: vi.fn().mockReturnValue("generating"),updateModelLoadingProgress: vi.fn(),86 unmodified linesexpect(updateModelSizeInMegabytes).not.toHaveBeenCalledWith(0);});});describe("composeStreamedText", () => {it("returns the answer unchanged when the model does not think", () => {expect(composeStreamedText("", "The answer.")).toBe("The answer.");});it("keeps the reasoning open while the answer has not started", () => {expect(composeStreamedText("hmm, let me see", "")).toBe("<think>hmm, let me see",);});it("closes the reasoning block when the answer starts", () => {expect(composeStreamedText("done thinking", "The answer.")).toBe("<think>done thinking</think>The answer.",);});});
112 unmodified lines11311411511611711816 unmodified lines13513613713813914014114214314414514614714814915048 unmodified lines199200201202203204112 unmodified lines? await messagesOrBuilder(): messagesOrBuilder;let streamedMessage = "";const stream = await wllama.createChatCompletion({16 unmodified lines}const delta = chunk.choices[0]?.delta?.content ?? "";if (!delta) continue;if (shouldCheckCanRespond && getTextGenerationState() !== "generating") {updateTextGenerationState("generating");}streamedMessage += delta;streamedMessage = handleWllamaCompletion(model,streamedMessage,() => abortController.abort(),onUpdate,);48 unmodified linesreturn { wllama, model };}function handleWllamaCompletion(model: WllamaModel,currentText: string,112 unmodified lines11311411511611711811912016 unmodified lines13713813914014114214314414514614714814915015115215315415515615715815948 unmodified lines208209210211212213214215216217218219220221222223224225226227112 unmodified lines? await messagesOrBuilder(): messagesOrBuilder;let reasoningText = "";let answerText = "";let streamedMessage = "";const stream = await wllama.createChatCompletion({16 unmodified lines}const delta = chunk.choices[0]?.delta?.content ?? "";// wllama splits a thinking model's chain of thought into its own// channel; the type does not declare it yet.const reasoningDelta =(chunk.choices[0]?.delta as { reasoning_content?: string } | undefined)?.reasoning_content ?? "";if (!delta && !reasoningDelta) continue;if (shouldCheckCanRespond && getTextGenerationState() !== "generating") {updateTextGenerationState("generating");}if (reasoningDelta) reasoningText += reasoningDelta;if (delta) answerText += delta;streamedMessage = handleWllamaCompletion(model,composeStreamedText(reasoningText, answerText),() => abortController.abort(),onUpdate,);48 unmodified linesreturn { wllama, model };}/*** Joins the reasoning and answer channels into one stream so the existing* reasoning-marker parsing in the UI shows the chain of thought while the* model thinks. The end marker only appears once the answer has started,* which keeps the UI in its "still thinking" state until then.*/export function composeStreamedText(reasoning: string, answer: string): string {if (!reasoning) return answer;const { reasoningStartMarker, reasoningEndMarker } = getSettings();return `${reasoningStartMarker}${reasoning}${answer ? `${reasoningEndMarker}${answer}` : ""}`;}function handleWllamaCompletion(model: WllamaModel,currentText: string,
35 unmodified lines363738394041424344454647484950515235 unmodified lines}});it("switches thinking-by-default chat templates off", () => {// MiniSearch renders only the content channel. A template that thinks// by default spends the whole token budget on reasoning_content and the// user sees an empty answer, so any model passing template kwargs must// be turning thinking off.for (const [id, model] of models) {if (model.chatTemplateKwargs) {expect(model.chatTemplateKwargs, id).toEqual({enable_thinking: false,});}}});35 unmodified lines3637383940414243444546474835 unmodified lines}});it("keeps thinking enabled on every model", () => {// The reasoning channel is streamed into the thinking UI, so a model// must not hand the template a kwarg that switches thinking off: the// answer would arrive with no visible chain of thought, which reads as// a dumber model rather than a feature that was turned off.for (const [id, model] of models) {expect(model.chatTemplateKwargs?.enable_thinking, id).not.toBe(false);}});
69 unmodified lines7071727374757651 unmodified lines128129130131132133134135136200 unmodified lines33733833934034134234329 unmodified lines37337437537637737837922 unmodified lines4024034044054064074081 unmodified line4104114124134144154168 unmodified lines42542642742842943069 unmodified lines: {}),});const hasWarmupSucceeded = !!warmupResponse.choices[0]?.message?.content;addLogEntry(`Wllama warmup ${hasWarmupSucceeded ? "succeeded" : "failed"}.`,51 unmodified linesreadonly flash_attn?: boolean;/*** Extra variables handed to the model's chat template on every completion* (wllama's `chat_template_kwargs`). Used to switch off thinking-by-default* templates: MiniSearch renders only the content channel, so a model that* spends its whole budget on `reasoning_content` would answer with nothing.*/readonly chatTemplateKwargs?: Record<string, unknown>;getSampling: () => Omit<SamplingParams, "logit_bias">;200 unmodified lineshfRepoId: "Felladrin/gguf-sharded-Q4_K_M-Spark-X2.6-1.7B",hfFilePath: "Spark-X2.6-1.7B-Q4_K_M-00001-of-00004.gguf",fileSizeInMegabytes: 1769,chatTemplateKwargs: { enable_thinking: false },},"smollm3-3b": {...createDefaultModelConfig(),29 unmodified lineshfRepoId: "Felladrin/gguf-sharded-Q4_K_S-granite-4.2-3b",hfFilePath: "granite-4.2-3b-Q4_K_S-00001-of-00005.gguf",fileSizeInMegabytes: 2143,chatTemplateKwargs: { enable_thinking: false },},"phi-3.5-mini-3.8b": {...createDefaultModelConfig(),22 unmodified lineshfRepoId: "Felladrin/gguf-sharded-UD-Q3_K_XL-Qwen3.5-4B",hfFilePath: "Qwen3.5-4B-UD-Q3_K_XL-00001-of-00005.gguf",fileSizeInMegabytes: 2436,chatTemplateKwargs: { enable_thinking: false },},"gemma-4-e2b": {...createDefaultModelConfig(),1 unmodified linehfRepoId: "Felladrin/gguf-sharded-Q3_K_S-gemma-4-e2b-it",hfFilePath: "gemma-4-e2b-it-Q3_K_S-00001-of-00005.gguf",fileSizeInMegabytes: 2446,chatTemplateKwargs: { enable_thinking: false },},"phi-4-mini-reasoning": {...createDefaultModelConfig(),8 unmodified lineshfRepoId: "Felladrin/gguf-sharded-Q4_K_M-Spark-X2.6-4B",hfFilePath: "Spark-X2.6-4B-Q4_K_M-00001-of-00007.gguf",fileSizeInMegabytes: 3543,chatTemplateKwargs: { enable_thinking: false },},};69 unmodified lines70717273747576777879808182838451 unmodified lines136137138139140141142143144200 unmodified lines34534634734834935029 unmodified lines38038138238338438522 unmodified lines4084094104114124131 unmodified line4154164174184194208 unmodified lines42943043143243369 unmodified lines: {}),});const warmupMessage = warmupResponse.choices[0]?.message as| { content?: string; reasoning_content?: string }| undefined;// A thinking model spends its single warmup token on the reasoning// channel, so either channel counts as a working model.const hasWarmupSucceeded = !!(warmupMessage?.content || warmupMessage?.reasoning_content);addLogEntry(`Wllama warmup ${hasWarmupSucceeded ? "succeeded" : "failed"}.`,51 unmodified linesreadonly flash_attn?: boolean;/*** Extra variables handed to the model's chat template on every completion* (wllama's `chat_template_kwargs`). Thinking stays on: the reasoning* channel is streamed into the thinking UI, so nothing here should turn* it off.*/readonly chatTemplateKwargs?: Record<string, unknown>;getSampling: () => Omit<SamplingParams, "logit_bias">;200 unmodified lineshfRepoId: "Felladrin/gguf-sharded-Q4_K_M-Spark-X2.6-1.7B",hfFilePath: "Spark-X2.6-1.7B-Q4_K_M-00001-of-00004.gguf",fileSizeInMegabytes: 1769,},"smollm3-3b": {...createDefaultModelConfig(),29 unmodified lineshfRepoId: "Felladrin/gguf-sharded-Q4_K_S-granite-4.2-3b",hfFilePath: "granite-4.2-3b-Q4_K_S-00001-of-00005.gguf",fileSizeInMegabytes: 2143,},"phi-3.5-mini-3.8b": {...createDefaultModelConfig(),22 unmodified lineshfRepoId: "Felladrin/gguf-sharded-UD-Q3_K_XL-Qwen3.5-4B",hfFilePath: "Qwen3.5-4B-UD-Q3_K_XL-00001-of-00005.gguf",fileSizeInMegabytes: 2436,},"gemma-4-e2b": {...createDefaultModelConfig(),1 unmodified linehfRepoId: "Felladrin/gguf-sharded-Q3_K_S-gemma-4-e2b-it",hfFilePath: "gemma-4-e2b-it-Q3_K_S-00001-of-00005.gguf",fileSizeInMegabytes: 2446,},"phi-4-mini-reasoning": {...createDefaultModelConfig(),8 unmodified lineshfRepoId: "Felladrin/gguf-sharded-Q4_K_M-Spark-X2.6-4B",hfFilePath: "Spark-X2.6-4B-Q4_K_M-00001-of-00007.gguf",fileSizeInMegabytes: 3543,},};
37 unmodified lines3839404142434437 unmodified lines- **Every model file must be a shard.** Chromium's OPFS storage silently truncates files past 2000 MiB, so a monolithic GGUF above that size arrives corrupted in the browser. Shards also keep progressive download working.- **The wasm linear memory ceiling is 4 GiB.** Models at ~3.5 GB and above OOM during buffer reserve, so the practical catalog ceiling is around 3.7 GB of weights.Models whose chat template thinks by default (Granite 4.2, Gemma 4, Spark X2.6, Qwen 3.5) would spend the whole token budget on the reasoning channel, which MiniSearch does not render. They are configured with `chatTemplateKwargs: { enable_thinking: false }`, passed to wllama as `chat_template_kwargs`.`node scripts/wllama-catalog-check.cjs` HEADs every shard of every catalog model on HuggingFace and verifies the claimed sizes; run it after adding or re-sharding a model.37 unmodified lines3839404142434437 unmodified lines- **Every model file must be a shard.** Chromium's OPFS storage silently truncates files past 2000 MiB, so a monolithic GGUF above that size arrives corrupted in the browser. Shards also keep progressive download working.- **The wasm linear memory ceiling is 4 GiB.** Models at ~3.5 GB and above OOM during buffer reserve, so the practical catalog ceiling is around 3.7 GB of weights.Models whose chat template thinks by default (Granite 4.2, Gemma 4, Spark X2.6, Qwen 3.5) keep thinking: wllama splits their chain of thought into a `reasoning_content` channel, and MiniSearch wraps it in the configured reasoning markers so the thinking UI shows it while the answer follows. Thinking spends the same token budget as the answer, so these models are slower and, on a long chain of thought, can use up the context before answering.`node scripts/wllama-catalog-check.cjs` HEADs every shard of every catalog model on HuggingFace and verifies the claimed sizes; run it after adding or re-sharding a model.
198 unmodified lines199200201202203204205198 unmodified lines- `{{dateTime}}`: Alias for `{{currentDate}}` - both are replaced with the same current date value- `{{searchResults}}`: Formatted search results from the web search, including the page excerpts when `enablePageContentFetch` is on**Reasoning Markers:** Models that output internal thought processes use `<think>` and `</think>` markers. The UI extracts and separately displays reasoning content from the final response.### Privacy Settings198 unmodified lines199200201202203204205198 unmodified lines- `{{dateTime}}`: Alias for `{{currentDate}}` - both are replaced with the same current date value- `{{searchResults}}`: Formatted search results from the web search, including the page excerpts when `enablePageContentFetch` is on**Reasoning Markers:** Models that output internal thought processes use `<think>` and `</think>` markers. The UI extracts and separately displays reasoning content from the final response. Browser (Wllama) thinking models are wrapped in these markers automatically, so their chain of thought shows up the same way.### Privacy Settings
agents.md+1-1
changelog.md+5
client/modules/textGenerationWithWllama.test.ts+24-1
client/modules/textGenerationWithWllama.ts+26-3
client/modules/wllama.test.ts+6-10
client/modules/wllama.ts+12-9
docs/ai-integration.md+1-1
docs/configuration.md+1-1