unsloth/studio/frontend
Daniel Han e945f43652 Add dedicated streaming server for fast GGUF SSE inference
Adds a separate streaming server (Option B) that bypasses the main
app's asyncio event loop for GGUF token streaming.

When UNSLOTH_FAST_SSE=1 or UNSLOTH_STREAM_SERVER=1 is set, a
lightweight FastAPI app starts in a daemon thread on a random port.
The frontend negotiates a one-time token via /api/inference/stream-url
and streams directly from this server, falling back to the baseline
/v1/chat/completions transparently on failure.

Architecture:
- streaming_server.py: standalone FastAPI app with three paths:
  - Path A (hot): async httpx.AsyncClient streaming direct to
    llama-server. No cumulative-to-delta conversion needed since
    llama-server sends delta tokens natively via OpenAI SSE.
  - Path B: tool calling via asyncio.to_thread (tool execution
    is the bottleneck, not the streaming proxy).
  - Path C: non-streaming one-shot JSON response.
- stream_token_store.py: thread-safe one-time token store (10s TTL)
  shared between the main app and streaming server.
- routes/inference.py: /stream-url endpoint for token issuance,
  /direct-stream for Option C, /internal/consume-stream-token for
  future subprocess mode.
- llama_cpp.py: --api-key support so the streaming server can
  authenticate to llama-server directly.
- chat-api.ts: transparent fast-path negotiation with silent fallback.

Handles: vision (image_url + legacy image_base64), thinking models
(reasoning_content -> <think> tags), CORS preflight, friendly error
messages, stream_options usage/timings passthrough.

Only sends repeat_penalty when the client explicitly provides it,
avoiding the 24% TPS penalty from repetition scanning.
2026-03-27 02:03:30 +00:00
..
public studio: windows desktop shortcut launcher (#4558) 2026-03-24 23:41:02 -07:00
src Add dedicated streaming server for fast GGUF SSE inference 2026-03-27 02:03:30 +00:00
.gitignore perf(studio): upgrade to Vite 8 + auto-install bun for faster frontend builds (#4522) 2026-03-25 04:27:41 -07:00
.gitkeep add studio root folder 2026-02-02 09:14:35 +00:00
biome.json feat: add seed dataset support with configuration, preview, and builder utilities 2026-02-14 18:44:38 +01:00
components.json add studio root folder 2026-02-02 09:14:35 +00:00
data-designer.openapi (1).yaml save and import, and fixes 2026-02-04 14:32:49 +01:00
eslint.config.js Final cleanup 2026-03-12 18:28:04 +00:00
index.html Final cleanup 2026-03-12 18:28:04 +00:00
package.json perf(studio): upgrade to Vite 8 + auto-install bun for faster frontend builds (#4522) 2026-03-25 04:27:41 -07:00
tsconfig.app.json Relax frontend unused local check (#4388) 2026-03-17 16:04:11 -07:00
tsconfig.json cleanup 2026-02-04 13:28:39 +01:00
tsconfig.node.json cleanup 2026-02-04 13:28:39 +01:00
vite.config.ts Fix Install commands for Windows + 1 line installs (#4447) 2026-03-19 02:09:09 -07:00