unsloth/studio/backend
Daniel Han 4577c9c565 Memoise load_inference_config to skip per-request disk scans
Every passthrough request through `/v1/chat/completions` and the
streaming `/v1/responses` path calls `load_inference_config(model)`
to fold family-default `chat_template_kwargs` (e.g. gpt-oss
`reasoning_effort=medium`) into the outbound body. The function
walks the model_defaults directory recursively via `rglob` inside
`_has_specific_yaml` plus reads two YAML files on every call, so the
hot path was paying the full lookup cost for every token-budget
poll, every tool turn, every reasoning sub-step.

The defaults directory is shipped with the package and does not
mutate at runtime, so wrap both `_has_specific_yaml` and the
expensive inner work of `load_inference_config` in `lru_cache`. The
public entry point still returns a fresh deepcopy of the cached
snapshot so the existing `test_load_returns_a_fresh_dict_per_call`
contract (callers may safely mutate the dict) is preserved.

Adds a regression test pinning the cache-hit count over repeated
calls for the same identifier.
2026-05-22 15:52:48 +00:00
..
assets Studio: family-default chat_template_kwargs for gpt-oss + Nemotron 2026-05-22 14:35:37 +00:00
auth studio: security and hardening pass (auth rate-limit, sandbox, path containment, schema validation, headers) (#5375) 2026-05-13 06:12:18 -07:00
core Studio: PDF / document attachments for Anthropic + OpenAI (#5689) 2026-05-22 06:22:57 -07:00
loggers Studio: stop truncating long log lines as suspected base64 (#5335) 2026-05-08 13:07:18 +04:00
models Studio: PDF / document attachments for Anthropic + OpenAI (#5689) 2026-05-22 06:22:57 -07: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 studio: API external provider support for chat (OpenAI, Mistral, Gemini, Cohere, Anthropic, OpenRouter, DeepSeek, custom providers) (#4706) 2026-05-14 16:13:59 +04:00
routes [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-05-22 14:36:28 +00:00
state unsloth run: add --enable-tools/--disable-tools server-side tool policy (#5277) 2026-05-05 12:45:15 +04:00
storage Studio: persist chat history in backend storage (#5272) 2026-05-22 06:18:05 -07:00
tests Memoise load_inference_config to skip per-request disk scans 2026-05-22 15:52:48 +00:00
utils Memoise load_inference_config to skip per-request disk scans 2026-05-22 15:52:48 +00: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 Studio: persist chat history in backend storage (#5272) 2026-05-22 06:18:05 -07:00
run.py Studio: stop hint, Uvicorn log rename, reachability check + Mac UI CI retry hardening (#5503) 2026-05-17 07:44:06 -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