Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ name = "lightspeed-stack"
version = "0.1.0"
description = "LLM tooling stack"
authors = []
dependencies = []
requires-python = ">=3.11.1,<=3.12.10"
readme = "README.md"
license = {file = "LICENSE"}
dependencies = [
"fastapi>=0.115.6",
"uvicorn>=0.32.1",
]

[project.urls]
Homepage = "https://github.com/lightspeed-core/lightspeed-stack"
Expand All @@ -19,3 +22,6 @@ distribution = true
dev = [
"black>=25.1.0"
]

[tool.pdm.scripts]
start = "pdm run make run"
1 change: 1 addition & 0 deletions src/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""REST API service based on FastAPI."""
18 changes: 18 additions & 0 deletions src/app/endpoints/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Handler for REST API call to provide info."""

import asyncio
import logging
from typing import Any, Optional

from fastapi import APIRouter, Request

logger = logging.getLogger(__name__)
router = APIRouter(tags=["info"])


@router.get("/info")
def info_endpoint_handler(request: Request) -> dict:
return {
"foo": 1,
"bar": 2,
}
15 changes: 15 additions & 0 deletions src/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from fastapi import FastAPI, Request, Response
from app import routers
import version

app = FastAPI(
title="Swagger service - OpenAPI",
description=f" service API specification.",
version=version.__version__,
license_info={
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html",
},
)

routers.include_routers(app)
16 changes: 16 additions & 0 deletions src/app/routers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""REST API routers."""

from fastapi import FastAPI

from app.endpoints import (
info,
)


def include_routers(app: FastAPI) -> None:
"""Include FastAPI routers for different endpoints.

Args:
app: The `FastAPI` app instance.
"""
app.include_router(info.router, prefix="/v1")
4 changes: 4 additions & 0 deletions src/lightspeed-stack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""Lightspeed stack."""

from runners.uvicorn import start_uvicorn
import version

if __name__ == "__main__":
print("Lightspeed stack")
start_uvicorn()
23 changes: 23 additions & 0 deletions src/runners/uvicorn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Uvicorn runner."""

import logging

import uvicorn

logger: logging.Logger = logging.getLogger(__name__)


def start_uvicorn() -> None:
"""Start Uvicorn-based REST API service."""
logger.info("Starting Uvicorn")

host = "localhost"
port = 8080
workers = 1

uvicorn.run(
"app.main:app",
host=host,
port=port,
workers=workers,
)
4 changes: 4 additions & 0 deletions src/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Service version that is read by project manager tools."""

# this should be the only version value used in all source codes!!!
__version__ = "0.0.1"