File tree Expand file tree Collapse file tree 8 files changed +88
-1
lines changed Expand file tree Collapse file tree 8 files changed +88
-1
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,13 @@ name = "lightspeed-stack"
33version = " 0.1.0"
44description = " LLM tooling stack"
55authors = []
6- dependencies = []
76requires-python = " >=3.11.1,<=3.12.10"
87readme = " README.md"
98license = {file = " LICENSE" }
9+ dependencies = [
10+ " fastapi>=0.115.6" ,
11+ " uvicorn>=0.32.1" ,
12+ ]
1013
1114[project .urls ]
1215Homepage = " https://github.com/lightspeed-core/lightspeed-stack"
@@ -19,3 +22,6 @@ distribution = true
1922dev = [
2023 " black>=25.1.0"
2124 ]
25+
26+ [tool .pdm .scripts ]
27+ start = " pdm run make run"
Original file line number Diff line number Diff line change 1+ """REST API service based on FastAPI."""
Original file line number Diff line number Diff line change 1+ """Handler for REST API call to provide info."""
2+
3+ import asyncio
4+ import logging
5+ from typing import Any , Optional
6+
7+ from fastapi import APIRouter , Request
8+
9+ logger = logging .getLogger (__name__ )
10+ router = APIRouter (tags = ["info" ])
11+
12+
13+ @router .get ("/info" )
14+ def info_endpoint_handler (request : Request ) -> dict :
15+ return {
16+ "foo" : 1 ,
17+ "bar" : 2 ,
18+ }
Original file line number Diff line number Diff line change 1+ from fastapi import FastAPI , Request , Response
2+ from app import routers
3+ import version
4+
5+ app = FastAPI (
6+ title = "Swagger service - OpenAPI" ,
7+ description = f" service API specification." ,
8+ version = version .__version__ ,
9+ license_info = {
10+ "name" : "Apache 2.0" ,
11+ "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" ,
12+ },
13+ )
14+
15+ routers .include_routers (app )
Original file line number Diff line number Diff line change 1+ """REST API routers."""
2+
3+ from fastapi import FastAPI
4+
5+ from app .endpoints import (
6+ info ,
7+ )
8+
9+
10+ def include_routers (app : FastAPI ) -> None :
11+ """Include FastAPI routers for different endpoints.
12+
13+ Args:
14+ app: The `FastAPI` app instance.
15+ """
16+ app .include_router (info .router , prefix = "/v1" )
Original file line number Diff line number Diff line change 11"""Lightspeed stack."""
22
3+ from runners .uvicorn import start_uvicorn
4+ import version
5+
36if __name__ == "__main__" :
47 print ("Lightspeed stack" )
8+ start_uvicorn ()
Original file line number Diff line number Diff line change 1+ """Uvicorn runner."""
2+
3+ import logging
4+
5+ import uvicorn
6+
7+ logger : logging .Logger = logging .getLogger (__name__ )
8+
9+
10+ def start_uvicorn () -> None :
11+ """Start Uvicorn-based REST API service."""
12+ logger .info ("Starting Uvicorn" )
13+
14+ host = "localhost"
15+ port = 8080
16+ workers = 1
17+
18+ uvicorn .run (
19+ "app.main:app" ,
20+ host = host ,
21+ port = port ,
22+ workers = workers ,
23+ )
Original file line number Diff line number Diff line change 1+ """Service version that is read by project manager tools."""
2+
3+ # this should be the only version value used in all source codes!!!
4+ __version__ = "0.0.1"
You can’t perform that action at this time.
0 commit comments