Commit Graph

28 Commits (48ed5ec8bcdc1449c6de7c6da42b3f886fc0f1b4)

Author SHA1 Message Date
voidborne-d 48ed5ec8bc fix: OpenAI API SSE compatibility and stream reliability
Problems:
1. Stream response missing 'data: [DONE]' terminator — OpenAI clients
   (openai-python, LiteLLM, etc.) expect this SSE sentinel to detect
   end-of-stream. Without it, clients hang or raise IncompleteRead.

2. Stream chunks lack required fields (id, object, created, model) —
   the OpenAI spec mandates chat.completion.chunk objects contain these
   metadata fields. Clients that validate response shape reject the
   bare {choices:[{delta:{}}]} payloads.

3. Non-stream path uses max_length instead of max_new_tokens — stream
   path correctly uses max_new_tokens, but non-stream passes
   max_length=prompt_len+max_tokens. This creates inconsistent behavior
   (different effective generation limits) between the two code paths.

4. Generation thread exceptions silently swallowed — if model.generate()
   throws (OOM, dtype mismatch, etc.), the queue never receives None,
   causing the consumer to block forever on queue.get(). Added sentinel-
   based error propagation so exceptions surface to the SSE generator.

5. No CORS headers — browser-based clients (web UIs, chatbots) get
   blocked by same-origin policy. Added CORSMiddleware.

6. Generation thread not daemonized — if the main process exits during
   generation (e.g. client disconnect + server shutdown), the non-daemon
   thread keeps the process alive. Set daemon=True.

Tests:
- 7 tests for parse_response (plain text, think tags, tool calls, edge cases)
- 6 tests for SSE stream format (DONE marker, chunk fields, CORS, max_new_tokens, daemon, error propagation)
2026-04-17 00:56:36 +00:00
jingyaogong 5351424bf0 [fix] lora moe 2026-04-09 16:36:48 +08:00
jingyaogong b7e0ae21d6 [update] default model 2026-03-31 13:40:16 +08:00
jingyaogong 6b0b0c5e2f [update] fp16 inference 2026-03-27 16:29:46 +08:00
jingyaogong 101d7df2da [update] minimind-3 2026-03-25 23:57:45 +08:00
jingyaogong 04616c41a5 [update] safe half 2026-01-30 20:29:31 +08:00
jingyaogong 07364c3fbe [update] rename train tokenizer 2026-01-06 01:17:33 +08:00
jingyaogong a8455ca8a3 [fix] messages num 2026-01-04 11:03:16 +08:00
jingyaogong eead9538b2 [feat] update config 2025-12-31 10:29:13 +08:00
jingyaogong 936d105e9b [feat] compatible tokenizer 2025-12-31 10:26:46 +08:00
jingyaogong 81e869fc3e [fix] harmonize template 2025-11-06 13:14:08 +08:00
jingyaogong 509d8dacf1 [feat] clear cache 2025-11-06 13:12:28 +08:00
jingyaogong 8a0b04ed82 [fix] harmonize template 2025-11-02 23:18:11 +08:00
jingyaogong 08ce3da228 [feat] update args 2025-10-30 10:48:31 +08:00
jingyaogong bf123b585d [feat] add args 2025-10-30 10:05:12 +08:00
jingyaogong 28cc44579a [feat] convert2llama 2025-10-23 20:22:42 +08:00
jingyaogong 7d877db79b [feat] minimind-2510 2025-10-21 21:19:47 +08:00
jingyaogong 2e118e9d3d update convert script 2025-04-27 15:44:40 +08:00
jingyaogong a62faf34bd 250426 2025-04-26 10:05:47 +08:00
jingyaogong 7da201a944 update chat-openai-api 2025-04-18 12:43:57 +08:00
jingyaogong 4a758564e4 fix top_p float bug 2025-04-09 16:52:20 +08:00
jingyaogong 08e9a22a25 update web_demo 2025-04-04 11:25:40 +08:00
gongjy c1a77f5c0f update web_demo 2025-02-14 19:38:55 +08:00
gongjy d519d2a233 update web_demo 2025-02-14 19:37:27 +08:00
gongjy b5d10d9a7d fix bugs 2025-02-13 20:56:14 +08:00
gongjy c9ca0f57dc update config 2025-02-10 00:14:11 +08:00
gongjy 29d6cd9cd2 update scripts file 2025-02-09 23:52:50 +08:00
gongjy 58e3af0359 add minimind2 2025-02-09 23:49:47 +08:00