mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2398] [MERGED] Batch lorebook entry embedding requests #5579
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#5579
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2398
Author: @Romuromylus
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/batch-lorebook-vectorize📝 Commits (2)
2ba9a76Batch lorebook entry embedding requestsec55e9bReject malformed embedding batch indices instead of mis-mapping by position📊 Changes
1 file changed (+170 additions, -21 deletions)
View changed files
📝
src-tauri/src/commands/storage/prompts.rs(+170 -21)📄 Description
Linked issue
Closes #2285
Why this change
vectorize_lorebookfired one/embeddingsHTTP round-trip per entry, so a large lorebook meant N serial requests (slow and rate-limit-prone). OpenAI-compatible embedding endpoints accept aninputarray, so the same work can be done in batches.What changed
src-tauri/src/commands/storage/prompts.rs: addedembed_texts()which, for OpenAI-compatible providers, POSTsinputas an array and parses everydata[].embeddingordered strictly by each item'sindex(array-position fallback whenindexis absent; fails closed if any slot is unfilled, so a misordered/truncated response can never write the wrong vector). Google/Ollama remain single-input per protocol (per-item fallback).vectorize_lorebooknow collects entries needing embedding and embeds in chunks ofEMBEDDING_BATCH_SIZE = 50(mirrors the web build's BATCH_SIZE). An N-entry lorebook drops from N round-trips to ceil(N/50).embed_text/embed_openai_compatibleare preserved as thin wrappers over the batch path, so single-call sites (chat memory, query embedding), theopenai_chatgptrejection, and the SSRFensure_embedding_url_allowedguard are unchanged.Refactor impact
Primary owner: Rust storage
Impact areas reviewed:
src-tauri/src/commands/storage/prompts.rs(vectorize_lorebook, embedding request/parse path)Boundary notes:
Pressure points touched:
Validation
pnpm checkpasses before PR push/handoffManual verification notes
cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine(embed/vectorize filters) — pass; the 5 existingvectorize_lorebook_*tests still green. Order-by-index and batch-size behavior were verified with local inline tests (kept local per repo convention).cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings— clean.cargo nextestis the CI runner;cargo testused locally as nextest is not installed here.)Feature Discoverability
src/features/shell/discovery/Reason:
Docs and release impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.