[PR #8667] [MERGED] feat(connections): test an embedding model from the model editor #8734

Closed
opened 2026-11-07 17:39:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8667
Author: @SpicyMarinara
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/test-embedding-8663


📝 Commits (4)

  • e9cc952 feat(connections): test an embedding model from the model editor (#8663)
  • 80da41d fix(connections): clear the embedding test result when its settings change
  • 9de46f6 fix(connections): any manual edit hides the embedding test result
  • ee9fcd3 fix(connections): Test embedding names a missing endpoint, not a missing model

📊 Changes

10 files changed (+408 additions, -41 deletions)

View changed files

📝 docs/lorebooks/semantic-search.md (+12 -10)
➕ e2e/connection-test-embedding.e2e.ts (+99 -0)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+76 -0)
📝 packages/client/src/components/connections/ModelPicker.tsx (+3 -2)
📝 packages/client/src/hooks/use-connections.ts (+15 -0)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/routes/connections.routes.ts (+30 -27)
📝 packages/server/src/services/memory-recall-embedding.ts (+20 -2)
📝 packages/server/src/services/memory-recall.ts (+3 -0)
➕ scripts/regressions/connection-test-embedding.regression.ts (+148 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8663

Why this change

  • When you set up an embedding model in Connections, there was no way to check that it works before vectorizing a lorebook. A wrong model name, key or address only showed up later as semantic search quietly matching nothing.
  • The existing POST /api/connections/:id/test-embedding route (used by the Embeddings job picker) sent the call to the connection's chat Base URL with its own model. It ignored the Embedding endpoint URL and the Embedding provider, so it could pass while real semantic search failed, or fail while it worked.

What changed

  • Server
    • memory-recall-embedding.ts: new resolveConnectionTestEmbeddingSource(db, connection), a thin wrapper around the resolver semantic search already uses. It skips the app-wide Embeddings default, so a connection with nothing set reports "No embedding model set." instead of quietly testing the default. A model with no address to send it to reports "No embedding endpoint set." (found by Dottore). It also lets the provider's error through so the test can show it. Normal semantic search still logs and returns nothing, as before. The resolved source now carries model and endpoint.
    • connections.routes.ts: the route resolves that source, embeds one short fixed text and returns { success, message, latencyMs, dimensions?, model?, endpoint? }. success and message keep their old meaning, so the job picker works as before. Failures are logged with Pino and name the connection and model, never the key. If the built-in model is picked as the Embedding provider but can't embed, the test says so.
  • Client
    • New useTestEmbedding mutation in use-connections.ts. ModelPicker.tsx uses it instead of calling the API directly.
    • ConnectionEditor.tsx: a Test embedding button at the end of the "Semantic search (embeddings)" section (Advanced, then More). It saves edits first, like the other test buttons, and shows the result in the same card, e.g. "Success · 1536 dimensions · 210 ms" or the provider's error. It is disabled while running and when no model would be found.
    • Two new English strings in en.json.
  • Docs: docs/lorebooks/semantic-search.md gets a paragraph about Test embedding. Its labels are updated to the current UI: Embedding provider, Same as this provider, Semantic search (embeddings) under Advanced → More, and Built-in model.
  • Tests
    • New regression scripts/regressions/connection-test-embedding.regression.ts. It runs against a local HTTP stub and checks four things: the call goes to the Embedding endpoint URL; the Embedding provider's model, key and URL are used; nothing set gives a plain error; and the key is never echoed. It fails on the old route, where the call went to /chat/v1/embeddings.
    • New e2e e2e/connection-test-embedding.e2e.ts: the button is disabled until a model is typed, then success with the vector size, then a failing endpoint shows the provider's error, with no horizontal scroll. It fails without the client change, and also with the client change but the old server route.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

What the agent ran locally:

  • node ./scripts/pnpm-runner.mjs check passes, and so do check:e2e-types and localization:check.
  • Regressions pass: connection-test-embedding (new), default-embedding-connection, lorebook-vectorization, capability-embedding-input-type, memory-recall-revectorize, connection-test-errors, model-picker-job-pick, semantic-summary-settings and package-agent-lorebook-window.
  • The new e2e passes on desktop-chromium, mobile-chromium and mobile-webkit.
  • Local CodeRabbit found that an old result stayed visible after an edit. On its second pass it added that the API key and Base URL count too, since the test falls back to them. Both are fixed: any manual edit in the editor (markDirty) now hides the result, and in-flight tests were already discarded there. The e2e checks it. The third pass reported 0 findings.
  • An independent review agent re-ran each proof with the server or client half reverse-applied. It confirmed both tests fail without the fix. Its one finding was a stale docs label, now fixed.

For a human to verify:

  • Manually verify in the browser: open a chat model's editor, go to Advanced → More, and type a real embedding model and Embedding endpoint URL (for example OpenAI text-embedding-3-small). Click Test embedding and check that the card shows Success with 1536 dimensions and the latency.
  • Manually verify that with an Embedding provider chosen and this model's embedding field empty, the button is enabled when the chosen connection has its own embedding model, and the test uses that connection's key and address.
  • Manually verify that choosing Built-in model as the Embedding provider without an enabled llama.cpp model shows the built-in model explanation instead of a generic error.
  • Manually verify that the Embeddings job picker under Connections → Defaults still assigns a working embedding model and still refuses one that can't embed.
  • Manually verify the button and result card in light theme at phone width.
  • Manually verify that editing the embedding model, endpoint or Embedding provider after a test hides the old result.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/lorebooks/semantic-search.md changed. The translated packs on docs-i18n will be updated in a follow-up docs-i18n PR after this merges.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8667 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/test-embedding-8663` --- ### 📝 Commits (4) - [`e9cc952`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e9cc9521cf3ff969d4c9bcb471a28f79c88626af) feat(connections): test an embedding model from the model editor (#8663) - [`80da41d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/80da41d47b3c3ea94e6246dbb759810c7d1177be) fix(connections): clear the embedding test result when its settings change - [`9de46f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9de46f676c56f1700bd6e7bb965c19979869531c) fix(connections): any manual edit hides the embedding test result - [`ee9fcd3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ee9fcd3360078daaafb7370ce4c4b245f1b00384) fix(connections): Test embedding names a missing endpoint, not a missing model ### 📊 Changes **10 files changed** (+408 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `docs/lorebooks/semantic-search.md` (+12 -10) ➕ `e2e/connection-test-embedding.e2e.ts` (+99 -0) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+76 -0) 📝 `packages/client/src/components/connections/ModelPicker.tsx` (+3 -2) 📝 `packages/client/src/hooks/use-connections.ts` (+15 -0) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/routes/connections.routes.ts` (+30 -27) 📝 `packages/server/src/services/memory-recall-embedding.ts` (+20 -2) 📝 `packages/server/src/services/memory-recall.ts` (+3 -0) ➕ `scripts/regressions/connection-test-embedding.regression.ts` (+148 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #8663 ## Why this change - When you set up an embedding model in Connections, there was no way to check that it works before vectorizing a lorebook. A wrong model name, key or address only showed up later as semantic search quietly matching nothing. - The existing `POST /api/connections/:id/test-embedding` route (used by the Embeddings job picker) sent the call to the connection's chat Base URL with its own model. It ignored the **Embedding endpoint URL** and the **Embedding provider**, so it could pass while real semantic search failed, or fail while it worked. ## What changed - **Server** - `memory-recall-embedding.ts`: new `resolveConnectionTestEmbeddingSource(db, connection)`, a thin wrapper around the resolver semantic search already uses. It skips the app-wide Embeddings default, so a connection with nothing set reports "No embedding model set." instead of quietly testing the default. A model with no address to send it to reports "No embedding endpoint set." (found by Dottore). It also lets the provider's error through so the test can show it. Normal semantic search still logs and returns nothing, as before. The resolved source now carries `model` and `endpoint`. - `connections.routes.ts`: the route resolves that source, embeds one short fixed text and returns `{ success, message, latencyMs, dimensions?, model?, endpoint? }`. `success` and `message` keep their old meaning, so the job picker works as before. Failures are logged with Pino and name the connection and model, never the key. If the built-in model is picked as the Embedding provider but can't embed, the test says so. - **Client** - New `useTestEmbedding` mutation in `use-connections.ts`. `ModelPicker.tsx` uses it instead of calling the API directly. - `ConnectionEditor.tsx`: a **Test embedding** button at the end of the "Semantic search (embeddings)" section (Advanced, then More). It saves edits first, like the other test buttons, and shows the result in the same card, e.g. "Success · 1536 dimensions · 210 ms" or the provider's error. It is disabled while running and when no model would be found. - Two new English strings in `en.json`. - **Docs**: `docs/lorebooks/semantic-search.md` gets a paragraph about **Test embedding**. Its labels are updated to the current UI: **Embedding provider**, **Same as this provider**, **Semantic search (embeddings)** under Advanced → More, and **Built-in model**. - **Tests** - New regression `scripts/regressions/connection-test-embedding.regression.ts`. It runs against a local HTTP stub and checks four things: the call goes to the Embedding endpoint URL; the Embedding provider's model, key and URL are used; nothing set gives a plain error; and the key is never echoed. It fails on the old route, where the call went to `/chat/v1/embeddings`. - New e2e `e2e/connection-test-embedding.e2e.ts`: the button is disabled until a model is typed, then success with the vector size, then a failing endpoint shows the provider's error, with no horizontal scroll. It fails without the client change, and also with the client change but the old server route. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes What the agent ran locally: - `node ./scripts/pnpm-runner.mjs check` passes, and so do `check:e2e-types` and `localization:check`. - Regressions pass: connection-test-embedding (new), default-embedding-connection, lorebook-vectorization, capability-embedding-input-type, memory-recall-revectorize, connection-test-errors, model-picker-job-pick, semantic-summary-settings and package-agent-lorebook-window. - The new e2e passes on desktop-chromium, mobile-chromium and mobile-webkit. - Local CodeRabbit found that an old result stayed visible after an edit. On its second pass it added that the API key and Base URL count too, since the test falls back to them. Both are fixed: any manual edit in the editor (`markDirty`) now hides the result, and in-flight tests were already discarded there. The e2e checks it. The third pass reported 0 findings. - An independent review agent re-ran each proof with the server or client half reverse-applied. It confirmed both tests fail without the fix. Its one finding was a stale docs label, now fixed. For a human to verify: - Manually verify in the browser: open a chat model's editor, go to Advanced → More, and type a real embedding model and Embedding endpoint URL (for example OpenAI `text-embedding-3-small`). Click **Test embedding** and check that the card shows Success with 1536 dimensions and the latency. - Manually verify that with an **Embedding provider** chosen and this model's embedding field empty, the button is enabled when the chosen connection has its own embedding model, and the test uses that connection's key and address. - Manually verify that choosing **Built-in model** as the Embedding provider without an enabled llama.cpp model shows the built-in model explanation instead of a generic error. - Manually verify that the Embeddings job picker under Connections → Defaults still assigns a working embedding model and still refuses one that can't embed. - Manually verify the button and result card in light theme at phone width. - Manually verify that editing the embedding model, endpoint or Embedding provider after a test hides the old result. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/lorebooks/semantic-search.md` changed. The translated packs on `docs-i18n` will be updated in a follow-up docs-i18n PR after this merges. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:19 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8734
No description provided.