Class: Tep::Llm::OpenAI::ModelsHandler
- Defined in:
- lib/tep/openai_server.rb
Overview
GET /v1/models – the standard OpenAI list envelope, built from backend.list_models. Dispatches through APP.openai_backend so the app’s subclass override is what answers.
Instance Method Summary collapse
Methods inherited from Handler
#is_regex?, #re_capture, #re_match?
Instance Method Details
#handle(req, res) ⇒ Object
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
# File 'lib/tep/openai_server.rb', line 496 def handle(req, res) res.headers["Content-Type"] = "application/json" models = Tep::APP.openai_backend.list_models owner = Tep::APP.openai_backend.model_owner created = Time.now.to_i out = "{\"object\":\"list\",\"data\":[" i = 0 while i < models.length if i > 0 out = out + "," end out = out + "{" + Tep::Json.encode_pair_str("id", models[i]) + "," + Tep::Json.encode_pair_str("object", "model") + "," + Tep::Json.encode_pair_int("created", created) + "," + Tep::Json.encode_pair_str("owned_by", owner) + "}" i += 1 end out = out + "]}" out end |