unsloth/studio/backend
Roland Tannous 266342a64e Studio: skip re-indexing an already-indexed document (content-hash dedup)
Re-uploading the same file into the same scope (KB or thread) used to
parse, chunk, caption and embed it all over again, creating a duplicate
set of chunks. Dedup by content hash instead:

  - schema: add rag_documents.content_hash (sha256 of the bytes) via the
    standard PRAGMA/ALTER migration, plus (scope, content_hash) indexes.
  - upload: _save_upload now streams the bytes through sha256 and returns
    the digest alongside path/name/size.
  - _start_ingestion: before inserting, look for a COMPLETED row in the
    same scope with the same hash. If found, delete the redundant upload
    from disk and return the existing document_id with already_indexed=
    true and an empty job_id — no ingestion job is started. Only
    'completed' rows dedup, so a failed/in-flight prior attempt can still
    retry. Scope-local: the same file in two KBs is indexed in each.
  - frontend: UploadResponse.already_indexed flows through the rag-store
    (skips job subscription) into both upload paths, which mark the chip
    ready immediately and toast '<file> is already indexed'.

Pre-existing rows have NULL content_hash and won't dedup until
re-uploaded once under the new path. Not build/UI-verified here (no bun
in this env); needs typecheck + browser check.
2026-05-28 15:19:06 +04:00
..
assets Add Qwen3.6 inference defaults for Studio (#5065) 2026-04-16 11:42:42 -07:00
auth [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-05-25 06:39:01 +00:00
core Merge branch 'main' into feature/rag 2026-05-28 13:46:11 +04:00
loggers Studio: stop truncating long log lines as suspected base64 (#5335) 2026-05-08 13:07:18 +04:00
models Merge remote-tracking branch 'origin/main' into feature/rag 2026-05-28 00:38:58 +03:00
plugins fix(gh_client): fail fast on 401/403 auth errors instead of retrying forever (#5325) (#5329) 2026-05-08 21:57:41 +04:00
requirements Merge remote-tracking branch 'origin/main' into feature/rag 2026-05-28 00:38:58 +03:00
routes Studio: skip re-indexing an already-indexed document (content-hash dedup) 2026-05-28 15:19:06 +04:00
state unsloth run: add --enable-tools/--disable-tools server-side tool policy (#5277) 2026-05-05 12:45:15 +04:00
storage Studio: skip re-indexing an already-indexed document (content-hash dedup) 2026-05-28 15:19:06 +04:00
tests Merge branch 'main' into feature/rag 2026-05-28 13:46:11 +04:00
utils Merge remote-tracking branch 'origin/main' into feature/rag 2026-05-28 00:38:58 +03:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
_platform_compat.py Fix Studio crash on Anaconda/conda-forge Python (#4484) 2026-03-22 05:36:55 -07:00
colab.py Fix/studio colab button message: Add fallback message for Colab Studio button when proxy URL fails (#4866) 2026-04-05 21:57:45 -07:00
main.py Merge remote-tracking branch 'origin/main' into feature/rag 2026-05-28 00:38:58 +03:00
run.py Studio: add configurable CPU thread pool limit (#5760) 2026-05-27 05:09:34 -07:00
startup_banner.py Studio: stop hint, Uvicorn log rename, reachability check + Mac UI CI retry hardening (#5503) 2026-05-17 07:44:06 -07:00