File size: 1,412 Bytes
e61d441 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#
# SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org>
# SPDX-License-Identifier: Apache-2.0
#
# Import APIRouter class from fastapi module to create a router instance for grouping related API routes
from fastapi import APIRouter
# Import JSONResponse to send JSON formatted HTTP responses from endpoint functions
from fastapi.responses import JSONResponse
# Import MODEL constant from config module, which specifies the default model identifier
from config import MODEL
# Create an APIRouter instance to collect and organize routes related to model operations
router = APIRouter()
# Define an asynchronous GET endpoint at path "/models" on this router
@router.get("/models")
async def list_models():
"""
OpenAI-compatible endpoint to list available models.
Returns a fixed list containing our default model.
This endpoint is required by many OpenAI-compatible clients to discover available models.
"""
# Return a JSON response with a list object containing one model dictionary
# The model dictionary includes id from config, a static object type, a placeholder created timestamp
return JSONResponse({
"object": "list",
"data": [
{
"id": MODEL,
"object": "model",
"created": 0, # Timestamp not available, so set to zero
"owned_by": "J.A.R.V.I.S."
}
]
})
|