Upload bundle.js
Browse files
bundle.js
CHANGED
|
@@ -9128,7 +9128,8 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9128 |
throw new Error("Llm not done loading");
|
| 9129 |
}
|
| 9130 |
const { pre, post } = this.promptTemplate[message.role];
|
| 9131 |
-
const
|
|
|
|
| 9132 |
const tokenCount = this.llmInference.sizeInTokens(text) ?? 0;
|
| 9133 |
return produce(message, (newMessage) => {
|
| 9134 |
newMessage.templateApplied = {
|
|
@@ -9137,6 +9138,9 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9137 |
};
|
| 9138 |
});
|
| 9139 |
}
|
|
|
|
|
|
|
|
|
|
| 9140 |
applyTemplateToMessages(messages) {
|
| 9141 |
return messages.map((message) => this.applyTemplate(message));
|
| 9142 |
}
|
|
@@ -9296,6 +9300,7 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9296 |
constructor() {
|
| 9297 |
super(...arguments);
|
| 9298 |
this.cachedModels = /* @__PURE__ */ new Map();
|
|
|
|
| 9299 |
this.options = structuredClone(DEFAULT_OPTIONS);
|
| 9300 |
}
|
| 9301 |
async connectedCallback() {
|
|
@@ -9337,6 +9342,14 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9337 |
});
|
| 9338 |
this.dispatchOptionsChanged();
|
| 9339 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9340 |
async handleRemoveCached(e8, path) {
|
| 9341 |
e8.stopPropagation();
|
| 9342 |
if (confirm("Remove model from cache?")) {
|
|
@@ -9425,6 +9438,18 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9425 |
</div>
|
| 9426 |
`}
|
| 9427 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9428 |
<div>
|
| 9429 |
<label for="temperature"
|
| 9430 |
>Temperature: ${this.options.temperature.toFixed(2)}</label
|
|
@@ -9463,13 +9488,16 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9463 |
/>
|
| 9464 |
</div>
|
| 9465 |
<div>
|
| 9466 |
-
<label for="force-f32">
|
| 9467 |
-
|
| 9468 |
-
|
| 9469 |
-
|
| 9470 |
-
|
| 9471 |
-
|
| 9472 |
-
|
|
|
|
|
|
|
|
|
|
| 9473 |
</div>
|
| 9474 |
</div>
|
| 9475 |
`;
|
|
@@ -9577,6 +9605,9 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9577 |
__decorateClass([
|
| 9578 |
n4({ type: Array })
|
| 9579 |
], LlmOptions.prototype, "cachedModels", 2);
|
|
|
|
|
|
|
|
|
|
| 9580 |
__decorateClass([
|
| 9581 |
r5()
|
| 9582 |
], LlmOptions.prototype, "options", 2);
|
|
@@ -9586,6 +9617,20 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9586 |
|
| 9587 |
// src/llm_chat.ts
|
| 9588 |
var import_deep_equal = __toESM(require_deep_equal());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9589 |
function isChromium() {
|
| 9590 |
if (navigator.userAgent.includes("Chrome")) {
|
| 9591 |
return true;
|
|
@@ -9618,7 +9663,7 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9618 |
this.currentAppliedOptions = structuredClone(DEFAULT_OPTIONS);
|
| 9619 |
this.pendingOptions = structuredClone(DEFAULT_OPTIONS);
|
| 9620 |
this.hasPendingOptionsChanges = false;
|
| 9621 |
-
this.
|
| 9622 |
this.cachedModels = /* @__PURE__ */ new Map();
|
| 9623 |
this.llmService = new LlmService();
|
| 9624 |
this.llmService.history.subscribe((history) => {
|
|
@@ -9634,6 +9679,14 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9634 |
this.cachedModels = models;
|
| 9635 |
});
|
| 9636 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9637 |
getModelName() {
|
| 9638 |
const modelPath = this.currentAppliedOptions.baseOptions?.modelAssetPath;
|
| 9639 |
if (!modelPath) {
|
|
@@ -9796,7 +9849,9 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9796 |
<llm-options
|
| 9797 |
.options=${this.pendingOptions}
|
| 9798 |
.cachedModels=${this.cachedModels}
|
|
|
|
| 9799 |
@options-changed=${this.handleOptionsChange}
|
|
|
|
| 9800 |
@cached-models-changed=${this.handleCachedModelsChanged}
|
| 9801 |
?disabled=${this.isLoadingModel || this.isGenerating}
|
| 9802 |
>
|
|
@@ -9998,6 +10053,9 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9998 |
__decorateClass([
|
| 9999 |
r5()
|
| 10000 |
], LlmChat.prototype, "hasPendingOptionsChanges", 2);
|
|
|
|
|
|
|
|
|
|
| 10001 |
__decorateClass([
|
| 10002 |
r5()
|
| 10003 |
], LlmChat.prototype, "cachedModels", 2);
|
|
|
|
| 9128 |
throw new Error("Llm not done loading");
|
| 9129 |
}
|
| 9130 |
const { pre, post } = this.promptTemplate[message.role];
|
| 9131 |
+
const strippedText = this.stripThoughts(message.text);
|
| 9132 |
+
const text = `${pre}${strippedText}${post}`;
|
| 9133 |
const tokenCount = this.llmInference.sizeInTokens(text) ?? 0;
|
| 9134 |
return produce(message, (newMessage) => {
|
| 9135 |
newMessage.templateApplied = {
|
|
|
|
| 9138 |
};
|
| 9139 |
});
|
| 9140 |
}
|
| 9141 |
+
stripThoughts(text) {
|
| 9142 |
+
return text.replace(/<\|channel>thought.*?<channel\|>/gs, "");
|
| 9143 |
+
}
|
| 9144 |
applyTemplateToMessages(messages) {
|
| 9145 |
return messages.map((message) => this.applyTemplate(message));
|
| 9146 |
}
|
|
|
|
| 9300 |
constructor() {
|
| 9301 |
super(...arguments);
|
| 9302 |
this.cachedModels = /* @__PURE__ */ new Map();
|
| 9303 |
+
this.thinking = false;
|
| 9304 |
this.options = structuredClone(DEFAULT_OPTIONS);
|
| 9305 |
}
|
| 9306 |
async connectedCallback() {
|
|
|
|
| 9342 |
});
|
| 9343 |
this.dispatchOptionsChanged();
|
| 9344 |
}
|
| 9345 |
+
handleThinkingChange(e8) {
|
| 9346 |
+
const event = new CustomEvent("thinking-changed", {
|
| 9347 |
+
detail: e8.target.checked,
|
| 9348 |
+
bubbles: true,
|
| 9349 |
+
composed: true
|
| 9350 |
+
});
|
| 9351 |
+
this.dispatchEvent(event);
|
| 9352 |
+
}
|
| 9353 |
async handleRemoveCached(e8, path) {
|
| 9354 |
e8.stopPropagation();
|
| 9355 |
if (confirm("Remove model from cache?")) {
|
|
|
|
| 9438 |
</div>
|
| 9439 |
`}
|
| 9440 |
</div>
|
| 9441 |
+
<div>
|
| 9442 |
+
<label for="thinking">
|
| 9443 |
+
<input
|
| 9444 |
+
type="checkbox"
|
| 9445 |
+
id="thinking"
|
| 9446 |
+
.checked=${this.thinking}
|
| 9447 |
+
@change=${this.handleThinkingChange}
|
| 9448 |
+
style="width: auto; margin-right: 8px;"
|
| 9449 |
+
/>
|
| 9450 |
+
Thinking
|
| 9451 |
+
</label>
|
| 9452 |
+
</div>
|
| 9453 |
<div>
|
| 9454 |
<label for="temperature"
|
| 9455 |
>Temperature: ${this.options.temperature.toFixed(2)}</label
|
|
|
|
| 9488 |
/>
|
| 9489 |
</div>
|
| 9490 |
<div>
|
| 9491 |
+
<label for="force-f32">
|
| 9492 |
+
<input
|
| 9493 |
+
type="checkbox"
|
| 9494 |
+
id="force-f32"
|
| 9495 |
+
.checked=${this.options.forceF32}
|
| 9496 |
+
@change=${this.handleForceF32Change}
|
| 9497 |
+
style="width: auto; margin-right: 8px;"
|
| 9498 |
+
/>
|
| 9499 |
+
Force F32 Fallback
|
| 9500 |
+
</label>
|
| 9501 |
</div>
|
| 9502 |
</div>
|
| 9503 |
`;
|
|
|
|
| 9605 |
__decorateClass([
|
| 9606 |
n4({ type: Array })
|
| 9607 |
], LlmOptions.prototype, "cachedModels", 2);
|
| 9608 |
+
__decorateClass([
|
| 9609 |
+
n4({ type: Boolean })
|
| 9610 |
+
], LlmOptions.prototype, "thinking", 2);
|
| 9611 |
__decorateClass([
|
| 9612 |
r5()
|
| 9613 |
], LlmOptions.prototype, "options", 2);
|
|
|
|
| 9617 |
|
| 9618 |
// src/llm_chat.ts
|
| 9619 |
var import_deep_equal = __toESM(require_deep_equal());
|
| 9620 |
+
|
| 9621 |
+
// src/personas/base_gemma4_thinking.ts
|
| 9622 |
+
var BASE_GEMMA4_THINKING_PERSONA = {
|
| 9623 |
+
...BASE_GEMMA4_PERSONA,
|
| 9624 |
+
name: "Base Gemma4 Thinking",
|
| 9625 |
+
instructions: [
|
| 9626 |
+
{
|
| 9627 |
+
role: "system",
|
| 9628 |
+
text: "<|think|>"
|
| 9629 |
+
}
|
| 9630 |
+
]
|
| 9631 |
+
};
|
| 9632 |
+
|
| 9633 |
+
// src/llm_chat.ts
|
| 9634 |
function isChromium() {
|
| 9635 |
if (navigator.userAgent.includes("Chrome")) {
|
| 9636 |
return true;
|
|
|
|
| 9663 |
this.currentAppliedOptions = structuredClone(DEFAULT_OPTIONS);
|
| 9664 |
this.pendingOptions = structuredClone(DEFAULT_OPTIONS);
|
| 9665 |
this.hasPendingOptionsChanges = false;
|
| 9666 |
+
this.isThinkingEnabled = false;
|
| 9667 |
this.cachedModels = /* @__PURE__ */ new Map();
|
| 9668 |
this.llmService = new LlmService();
|
| 9669 |
this.llmService.history.subscribe((history) => {
|
|
|
|
| 9679 |
this.cachedModels = models;
|
| 9680 |
});
|
| 9681 |
}
|
| 9682 |
+
get selectedPersona() {
|
| 9683 |
+
return this.isThinkingEnabled ? BASE_GEMMA4_THINKING_PERSONA : BASE_GEMMA4_PERSONA;
|
| 9684 |
+
}
|
| 9685 |
+
handleThinkingToggle(event) {
|
| 9686 |
+
this.isThinkingEnabled = event.detail;
|
| 9687 |
+
this.llmService.setPersona(this.selectedPersona);
|
| 9688 |
+
this.requestUpdate();
|
| 9689 |
+
}
|
| 9690 |
getModelName() {
|
| 9691 |
const modelPath = this.currentAppliedOptions.baseOptions?.modelAssetPath;
|
| 9692 |
if (!modelPath) {
|
|
|
|
| 9849 |
<llm-options
|
| 9850 |
.options=${this.pendingOptions}
|
| 9851 |
.cachedModels=${this.cachedModels}
|
| 9852 |
+
.thinking=${this.isThinkingEnabled}
|
| 9853 |
@options-changed=${this.handleOptionsChange}
|
| 9854 |
+
@thinking-changed=${this.handleThinkingToggle}
|
| 9855 |
@cached-models-changed=${this.handleCachedModelsChanged}
|
| 9856 |
?disabled=${this.isLoadingModel || this.isGenerating}
|
| 9857 |
>
|
|
|
|
| 10053 |
__decorateClass([
|
| 10054 |
r5()
|
| 10055 |
], LlmChat.prototype, "hasPendingOptionsChanges", 2);
|
| 10056 |
+
__decorateClass([
|
| 10057 |
+
r5()
|
| 10058 |
+
], LlmChat.prototype, "isThinkingEnabled", 2);
|
| 10059 |
__decorateClass([
|
| 10060 |
r5()
|
| 10061 |
], LlmChat.prototype, "cachedModels", 2);
|