5607 Commits

Author SHA1 Message Date
Timothy Jaeryang Baek
c6a1469fad refac 2026-03-08 19:05:15 -05:00
Timothy Jaeryang Baek
97cc94756e chore: bump 2026-03-08 19:00:50 -05:00
Timothy Jaeryang Baek
61366cbcda refac 2026-03-08 18:57:20 -05:00
Timothy Jaeryang Baek
c3e1d2d894 refac 2026-03-08 18:40:47 -05:00
Timothy Jaeryang Baek
0bfacca0a0 refac 2026-03-08 18:30:16 -05:00
Timothy Jaeryang Baek
1364df0913 refac 2026-03-08 18:26:36 -05:00
Timothy Jaeryang Baek
352391fa76 chore: format 2026-03-08 18:14:09 -05:00
Timothy Jaeryang Baek
2cb28369b7 refac 2026-03-08 18:08:12 -05:00
Timothy Jaeryang Baek
3f350f8659 refac 2026-03-08 17:52:49 -05:00
Timothy Jaeryang Baek
9d8f590fc5 feat: support pipe filters for per-message content truncation in task templates
Add |middletruncate:n, |start:n, and |end:n pipe filters to the
{{MESSAGES}} template variable, enabling per-message character
truncation for task models (title, tags, follow-up, etc.).

Example: {{MESSAGES:END:2|middletruncate:500}}

This optimizes task model prompt size for conversations with very
long messages (e.g. pasted documents), reducing latency for local
models and API costs.

Closes #21499
2026-03-08 17:43:23 -05:00
Timothy Jaeryang Baek
c97767424f refac/fix 2026-03-08 17:26:29 -05:00
Code with love
265d1b2824 Add support for mariadb-vector as backing vector DB (#21931) 2026-03-08 17:13:14 -05:00
Classic298
caf3362be8 fix: add missing group_id filter to analytics token usage query (#22167)
The get_token_usage_by_user query lacked group_id filtering, while the
companion get_message_count_by_user query already supported it. When an
admin filtered analytics by user group, message counts were correctly
scoped to the group but token usage totals included data from all users.

Add the group_id parameter and subquery filter to get_token_usage_by_user,
matching the pattern used by get_message_count_by_user and other analytics
queries, and pass group_id through from the analytics endpoint.
2026-03-08 17:11:12 -05:00
Alvin Tang
7aa7bbc390 fix: correct Azure TTS locale extraction for SSML xml:lang (#22443)
The locale for Azure TTS SSML was being extracted with `split("-")[:1]`,
which only takes the first segment (e.g., "en" from "en-US"). The
xml:lang attribute in SSML requires a full locale like "en-US", not just
a language code. This caused Azure TTS to either fail or use incorrect
pronunciation rules.

Changed `[:1]` to `[:2]` to properly extract the locale (e.g., "en-US").

Co-authored-by: gambletan <ethanchang32@gmail.com>
2026-03-08 16:50:25 -05:00
Ethan T.
a97f5adf95 fix: URL-encode OAuth error message in redirect URL (#22415)
- URL-encodes the OAuth error message when constructing the redirect URL in the OIDC callback handler
- Without encoding, error messages containing spaces, ampersands, or other special characters produce malformed URLs that the frontend cannot parse correctly
- The custom OAuth client callback handler already correctly uses urllib.parse.quote_plus() for the same purpose; this fix brings the OIDC handler in line with that pattern

Co-authored-by: gambletan <tan@gambletan.com>
2026-03-08 16:47:47 -05:00
Fu-Jie
138c4cbfcf fix: filter out internal tool methods starting with underscore (#22408) 2026-03-08 16:46:56 -05:00
Alvin Tang
3e513be963 fix: prevent TypeError in Teams webhook when user data is missing (#22444)
json.loads(event_data.get("user", {})) crashes with TypeError when
the "user" key is absent because the default value {} is a dict, not
a JSON string. json.loads expects str/bytes, not dict.

Also handle the case where "user" is already a dict (not serialized
JSON) to make the webhook more robust.

Co-authored-by: gambletan <ethanchang32@gmail.com>
2026-03-08 16:45:21 -05:00
Alvin Tang
f78b238b40 fix: prevent pipeline filter from corrupting payload on HTTP error (#22445)
In both inlet and outlet filter processing, response.json() was called
BEFORE response.raise_for_status(). When a filter endpoint returns an
HTTP error, the user's chat payload gets silently overwritten with the
error response body. If the error is not caught, the corrupted payload
propagates through subsequent filters and into the chat completion.

Swapped the order so raise_for_status() runs first — payload is only
updated on success.

Co-authored-by: gambletan <ethanchang32@gmail.com>
2026-03-08 16:44:35 -05:00
Classic298
63a0befd3c fix: add missing opentelemetry-instrumentation-system-metrics dependency (#22447) 2026-03-08 16:41:42 -05:00
Timothy Jaeryang Baek
710320601a refac 2026-03-08 16:41:21 -05:00
Timothy Jaeryang Baek
67e26fd3af refac 2026-03-08 16:40:20 -05:00
Alvin Tang
2c35bdbcf5 fix: replace bare string raises with proper exception types (#22446)
`raise "string"` in Python raises TypeError instead of the intended
error, making error messages confusing and debugging difficult.

Co-authored-by: gambletan <ethanchang32@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:39:09 -05:00
Ethan T.
61bbb99d9e fix: replace bare except with Exception in oauth.py (#22420)
* fix: replace bare except with except Exception in main.py

* fix: replace bare except with Exception in oauth.py

In Python 3, bare 'except:' is discouraged as it catches all
SystemExit and KeyboardInterrupt exceptions. Changed to 'except Exception:'
to only catch actual exceptions.
2026-03-08 16:36:53 -05:00
Timothy Jaeryang Baek
710b5270a1 refac 2026-03-07 20:43:45 -06:00
Timothy Jaeryang Baek
2bff50f736 refac 2026-03-07 20:42:21 -06:00
Timothy Jaeryang Baek
f047b6b3ae refac 2026-03-07 20:30:42 -06:00
Timothy Jaeryang Baek
368912ca62 refac 2026-03-07 20:28:17 -06:00
Timothy Jaeryang Baek
b1048fc9bc refac 2026-03-07 20:22:01 -06:00
Classic298
223c14f48b fix: add deterministic tiebreaker to all paginated chat queries (#22387)
Add Chat.id as a secondary sort key to all paginated chat queries
that use offset/limit pagination. When multiple chats share the same
updated_at timestamp, the database does not guarantee a stable order
across page boundaries, causing chats to appear on multiple pages.

This produces duplicate keys in the Svelte sidebar each-block
(each_key_duplicate error). Adding Chat.id as a tiebreaker ensures
fully deterministic ordering.

Extends the fix from #22383 (which addressed get_chat_ids_by_model_id)
to all remaining paginated chat queries.
2026-03-07 20:16:50 -06:00
Timothy Jaeryang Baek
3ceaa107ab chore: format 2026-03-07 20:14:32 -06:00
Timothy Jaeryang Baek
144d8b1bb7 refac 2026-03-07 20:12:35 -06:00
Timothy Jaeryang Baek
989938856f refac 2026-03-07 20:05:18 -06:00
Timothy Jaeryang Baek
8913f37c3d enh: create subfolder
Co-Authored-By: Colin Chen <1207878+silenceroom@users.noreply.github.com>
2026-03-07 19:45:43 -06:00
Timothy Jaeryang Baek
80b5896b70 refac 2026-03-07 19:38:20 -06:00
Timothy Jaeryang Baek
967b1137dc refac 2026-03-07 19:31:51 -06:00
Timothy Jaeryang Baek
ce0ca894fe enh: code interpreter pyodide fs 2026-03-07 19:23:18 -06:00
Classic298
d1975b740b fix: add deterministic ordering to chat_ids pagination query to prevent duplicates (#22383) 2026-03-07 20:19:44 -05:00
Timothy Jaeryang Baek
459a60a242 refac 2026-03-07 19:17:24 -06:00
Classic298
9a269ec8ab fix: use path converter for model ID routes in analytics to support slashes (#22382) 2026-03-07 20:02:59 -05:00
Timothy Jaeryang Baek
d7efdcce2b refac 2026-03-07 19:02:03 -06:00
Timothy Jaeryang Baek
95b65ff751 refac 2026-03-07 18:23:52 -06:00
Timothy Jaeryang Baek
35bc831077 refac 2026-03-07 18:18:02 -06:00
pedro-inf-custodio
5d4505c685 fix: add support for scope in OAuth refresh token request (#22359)
* fix: add support for scope in OAuth refresh token request

* add oauth refresh token include scope

* Fix variable import

* Fix env variables import

* Added debug logs WIP

* Remove debug logs
2026-03-07 19:13:28 -05:00
Classic298
b4f340806a fix: migration streaming/batching (#21542)
* fix: normalize usage tokens + migration streaming/batching

- Migration: replace .fetchall() with yield_per streaming, replace per-message INSERT+SAVEPOINT with batched inserts (5k/batch) with fallback to row-by-row on error, add progress logging

- Write path: call normalize_usage() in upsert_message() before saving to ensure input_tokens/output_tokens always present

- Read path: analytics queries now COALESCE across input_tokens/prompt_tokens and output_tokens/completion_tokens so historical data with OpenAI-format keys is visible

* fix: restore defensive timestamp conversion in migration

Re-add try/except around int(float(timestamp)) that was accidentally dropped. Without this, a non-numeric timestamp string would cause a TypeError on the subsequent comparison, breaking the entire upgrade.

* revert: remove changes to chat_messages.py
2026-03-07 19:08:11 -05:00
Timothy Jaeryang Baek
bc5d519c4f refac 2026-03-07 17:29:24 -06:00
Timothy Jaeryang Baek
7cdff6b1e2 refac 2026-03-07 17:24:17 -06:00
Timothy Jaeryang Baek
b04de83c20 refac 2026-03-07 17:18:46 -06:00
Classic298
dfa2511199 fix: persist token usage data for non-streaming chat responses (#22166)
The non-streaming response handler was saving assistant messages without
their usage/token data. While the streaming handler correctly extracted
and saved usage information, the non-streaming path discarded it entirely.

This caused assistant messages from non-streaming completions to have
NULL usage in the chat_message table, making them invisible to the
analytics token aggregation queries and contributing to the '0 tokens'
display in Admin Panel Analytics.

Extract and normalize the usage data from the API response and include
it in the database upsert, matching the pattern already used by the
streaming handler.
2026-03-07 17:17:36 -06:00
Timothy Jaeryang Baek
d4faa5a5ea refac 2026-03-07 17:13:19 -06:00
Classic298
2108f420ea chore: dep bump (#22305)
* chore: dep bump

* revert: Brotli dependency bump (1.2.0 -> 1.1.0)
2026-03-07 17:12:22 -06:00