Class: HealthHandler
- Inherits:
-
Tep::Handler
- Object
- Tep::Handler
- HealthHandler
- Defined in:
- lib/toy/serve/openai/handlers.rb
Overview
lib/toy/serve/openai/handlers.rb – Tep::Handler subclasses for the OpenAI-compatible endpoints.
MOVED from tep_demo/openai_api_llama.rb:268-365 (P4 toy serve). Handlers: Health (/health), Models (/v1/models), Completions (/v1/completions – choices.ids is the gate field), ChatCompletions (/v1/chat/completions -> 501), Index (/). The /v1/embeddings handler lives in embeddings_handler.rb.
FIX during the move: the pre-existing HTML bug in the index page (openai_api_llama.rb:359-360) – an orphaned String literal with no leading ‘+` followed by a stray trailing `++`. It is not gated either way (the gate hits /v1/completions, not /), so fixing it during the lift is safe and removes a latent syntax landmine.
Tep is consumed purely as transport. Spinel hygiene (#16): String-concat JSON, no #{} interpolation, no Struct.new.
Instance Method Summary collapse
Instance Method Details
#handle(req, res) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/toy/serve/openai/handlers.rb', line 20 def handle(req, res) res.headers["Content-Type"] = "text/plain" if STATE.ready "ok\n" else res.set_status(503) "loading\n" end end |