Commit Graph

5898 Commits

Author SHA1 Message Date
Timothy Jaeryang Baek 24dd5b461e refac 2026-04-20 00:09:24 +09:00
Timothy Jaeryang Baek 1d501cfa3f refac 2026-04-20 00:07:34 +09:00
Timothy Jaeryang Baek a05a769938 refac 2026-04-19 23:42:09 +09:00
Timothy Jaeryang Baek e5b5a17426 refac 2026-04-19 23:38:58 +09:00
Timothy Jaeryang Baek 37eba1c5a6 chore: format 2026-04-19 22:45:54 +09:00
Timothy Jaeryang Baek 5afc258c5b refac 2026-04-19 22:37:10 +09:00
Timothy Jaeryang Baek 42694c7c0c refac 2026-04-19 22:33:32 +09:00
Timothy Jaeryang Baek f45d0f130e refac 2026-04-19 22:22:15 +09:00
Timothy Jaeryang Baek 98627e42b4 refac 2026-04-19 22:13:47 +09:00
Timothy Jaeryang Baek 4a5401b417 refac 2026-04-19 21:48:27 +09:00
Timothy Jaeryang Baek 8d739e2aba feat: calendar 2026-04-19 19:15:05 +09:00
Timothy Jaeryang Baek a4d62253df refac 2026-04-18 06:23:50 +09:00
Timothy Jaeryang Baek 7cfb260b8a refac 2026-04-17 15:01:42 +09:00
Timothy Jaeryang Baek 49430de42d refac 2026-04-17 15:00:17 +09:00
Classic298 f0e0cfcf02 perf: avoid redundant knowledge re-fetch in update_knowledge_access_by_id (#23799)
After set_access_grants, the handler was reloading the same knowledge
record via get_knowledge_by_id, which triggers an extra SELECT plus a
nested fetch of access grants. set_access_grants already returns the
newly-written grants and the local knowledge object is otherwise
unchanged, so update it in place and reuse it for the response.

https://claude.ai/code/session_01S18Lgqbih7Ry2JZUUv8TxF

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-17 14:44:42 +09:00
Timothy Jaeryang Baek 55bfc7cbc2 refac 2026-04-17 14:35:13 +09:00
Timothy Jaeryang Baek 4113b15a60 chore: format 2026-04-17 14:28:18 +09:00
Timothy Jaeryang Baek 8acce144f9 refac 2026-04-17 14:15:36 +09:00
Timothy Jaeryang Baek e7e752f8e7 refac 2026-04-17 14:09:35 +09:00
Timothy Jaeryang Baek f44b7a01f5 refac 2026-04-17 13:59:46 +09:00
Timothy Jaeryang Baek 2c7acb9285 refac 2026-04-17 13:58:32 +09:00
Timothy Jaeryang Baek 50363ba66b refac 2026-04-17 13:52:11 +09:00
Timothy Jaeryang Baek 860b90fd17 refac 2026-04-17 13:47:21 +09:00
Timothy Jaeryang Baek 914ccf07ef refac 2026-04-17 13:37:52 +09:00
Timothy Jaeryang Baek ba83613ff2 refac 2026-04-17 13:35:35 +09:00
Timothy Jaeryang Baek 499129625b refac
Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com>
2026-04-17 13:33:11 +09:00
Timothy Jaeryang Baek 3271b013a8 refac 2026-04-17 13:29:51 +09:00
Timothy Jaeryang Baek 638c7ab802 refac 2026-04-17 13:27:58 +09:00
Timothy Jaeryang Baek e695d854f2 refac 2026-04-17 13:10:06 +09:00
Timothy Jaeryang Baek 34d569d564 refac 2026-04-17 13:04:07 +09:00
Timothy Jaeryang Baek e709d6812f refac 2026-04-17 12:55:56 +09:00
Timothy Jaeryang Baek 3dd8255816 refac 2026-04-17 12:37:44 +09:00
Classic298 32cfb5788a perf(chats): select only meta column in get_chat_tags_by_id_and_user_id (#23798)
Avoid loading the full Chat row (including the potentially large `chat`
JSON column) just to read tag IDs from `meta.tags`. Issue a narrow
SELECT on `Chat.meta` instead, which is much cheaper for chats with
large message histories.

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-17 12:35:58 +09:00
Classic298 2dca850cee perf: use set for O(1) lookup in insert_chat_files dedupe (#23800)
Convert chat_message_file_ids from list to set so the membership test
in the comprehension is O(1) instead of O(m), turning the dedupe from
O(n*m) into O(n+m). Also replace the redundant set([...]) with a set
comprehension.

https://claude.ai/code/session_01Le3NnqNhcgaJvFrDZGqmwe

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-17 12:28:34 +09:00
Timothy Jaeryang Baek 349ea4ea9e refac 2026-04-17 12:25:43 +09:00
Timothy Jaeryang Baek 7e453de4f7 refac 2026-04-17 11:54:19 +09:00
Timothy Jaeryang Baek f1ef09ddc8 refac 2026-04-17 11:48:17 +09:00
Timothy Jaeryang Baek 3332878321 refac 2026-04-17 11:29:59 +09:00
Classic298 e396af3cc8 perf: reuse request db session in get_model_profile_image (#23796)
Pass the request-scoped AsyncSession into Models.get_model_by_id so the
endpoint no longer opens a fresh DB session on every call, avoiding an
extra connection acquisition per profile image request.

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-17 11:28:19 +09:00
Timothy Jaeryang Baek 7cc7b367dc refac 2026-04-17 11:27:58 +09:00
Classic298 5eae0a5cdd perf(users): drop redundant get_user_by_id refetch in session-user endpoints (#23794)
* perf(users): drop redundant get_user_by_id refetch in session-user endpoints

Five /user/* handlers refetched the user row via Users.get_user_by_id(user.id)
immediately after receiving an identical UserModel from Depends(get_verified_user).
Since get_verified_user already populated the user within the same request
microseconds earlier, the refetch is pure overhead. The dead else branches
(unreachable — get_verified_user raises 401 on missing user) are removed as
a natural consequence.

Affected endpoints:
- GET  /user/settings
- GET  /user/status
- POST /user/status/update
- GET  /user/info
- POST /user/info/update

Eliminates one SELECT per request to each of these endpoints with no behavioral
change.

* fix(users): preserve USER_NOT_FOUND error on status update failure

update_user_status_by_id returns None when the target user is missing or
the update raises. The previous commit removed the pre-update existence
gate (get_user_by_id) and returned the update result directly, which
turned not-found/failure cases into 200 OK with a null body instead of
the expected 400 USER_NOT_FOUND.

Guard the update result explicitly to preserve the original API contract,
matching the equivalent pattern already applied in /user/info/update.

* docs(users): note lost-update tradeoff on /user/info/update

Make the concurrency tradeoff explicit: merging against the auth-time
snapshot slightly widens the lost-update window compared to the previous
pre-merge refetch, but the refetch only narrowed (did not eliminate) that
window. Real safety requires row locking or a version column.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-17 11:23:08 +09:00
Timothy Jaeryang Baek 43e5905c13 refac 2026-04-17 11:18:48 +09:00
Timothy Jaeryang Baek 128cf41fce refac 2026-04-17 11:12:42 +09:00
Timothy Jaeryang Baek 398718d505 refac 2026-04-17 10:44:29 +09:00
Timothy Jaeryang Baek 2e52ad8ff2 refac: shared chat 2026-04-17 10:16:32 +09:00
Timothy Jaeryang Baek 4d2f189810 feat: add RAG_RERANKING_BATCH_SIZE configuration option
Add configurable reranker batch size (env var RAG_RERANKING_BATCH_SIZE,
default 32) following the same pattern as RAG_EMBEDDING_BATCH_SIZE.

- config.py: PersistentConfig for RAG_RERANKING_BATCH_SIZE
- main.py: import, state init, pass to get_reranking_function
- colbert.py: accept batch_size param in predict() (was hardcoded 32)
- utils.py: get_reranking_function passes batch_size at call time
- retrieval.py: expose in config GET/POST endpoints and ConfigForm
- Documents.svelte: add Reranking Batch Size input in admin settings

Closes #23730
2026-04-17 08:35:45 +09:00
Timothy Jaeryang Baek 70a6a24f14 refac 2026-04-15 10:37:59 -07:00
Timothy Jaeryang Baek 2f9e326dba refac 2026-04-15 10:26:47 -07:00
Timothy Jaeryang Baek 5944eda0ff refac 2026-04-15 10:17:40 -07:00
Timothy Jaeryang Baek 5dae600ce7 chore: format 2026-04-14 17:27:31 -05:00