Spaces:
Running
Running
Add welcome message route
Browse files- README.md +1 -1
- README_infos.md +3 -0
- src/adapters/inbound/api/app.py +8 -0
- tests/contract/http/test_app_contract.py +13 -0
README.md
CHANGED
|
@@ -4,6 +4,6 @@ emoji: 🐢
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
| 7 |
-
pinned:
|
| 8 |
short_description: RAG with a ChromaDB vectorstore (hexagonal architecture)
|
| 9 |
---
|
|
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
| 7 |
+
pinned: true
|
| 8 |
short_description: RAG with a ChromaDB vectorstore (hexagonal architecture)
|
| 9 |
---
|
README_infos.md
CHANGED
|
@@ -26,10 +26,13 @@ Points forts du projet :
|
|
| 26 |
|---|---|
|
| 27 |
| https://loren-rag-backend-api.hf.space/docs | https://loren-rag-backend-api.hf.space/health |
|
| 28 |
|
|
|
|
|
|
|
| 29 |
Schéma OpenAPI brut : `/openapi.json`. Redoc : `/redoc`.
|
| 30 |
|
| 31 |
Endpoints :
|
| 32 |
|
|
|
|
| 33 |
- `POST /api/v1/ask` : pose une question (`question`, `top_k`, `use_mmr`, `lambda_mult`, `similarity_threshold`, `trace_name`, `user_id`).
|
| 34 |
- `POST /api/v1/feedback` : envoie un feedback sur une réponse (`trace_id`, `score_value`, `feedback_type`, `comment`).
|
| 35 |
- `GET /health` : état du service.
|
|
|
|
| 26 |
|---|---|
|
| 27 |
| https://loren-rag-backend-api.hf.space/docs | https://loren-rag-backend-api.hf.space/health |
|
| 28 |
|
| 29 |
+
La racine `https://loren-rag-backend-api.hf.space/` affiche un message d'accueil JSON avec les liens vers `/docs` et `/health`.
|
| 30 |
+
|
| 31 |
Schéma OpenAPI brut : `/openapi.json`. Redoc : `/redoc`.
|
| 32 |
|
| 33 |
Endpoints :
|
| 34 |
|
| 35 |
+
- `GET /` : message d'accueil et liens utiles.
|
| 36 |
- `POST /api/v1/ask` : pose une question (`question`, `top_k`, `use_mmr`, `lambda_mult`, `similarity_threshold`, `trace_name`, `user_id`).
|
| 37 |
- `POST /api/v1/feedback` : envoie un feedback sur une réponse (`trace_id`, `score_value`, `feedback_type`, `comment`).
|
| 38 |
- `GET /health` : état du service.
|
src/adapters/inbound/api/app.py
CHANGED
|
@@ -21,6 +21,14 @@ def create_app(container: Container | None = None) -> FastAPI:
|
|
| 21 |
def get_container() -> Container:
|
| 22 |
return runtime_container
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
@app.middleware("http")
|
| 25 |
async def inbound_logging_middleware(request: Request, call_next):
|
| 26 |
request_id = request.headers.get("x-request-id", str(uuid.uuid4()))
|
|
|
|
| 21 |
def get_container() -> Container:
|
| 22 |
return runtime_container
|
| 23 |
|
| 24 |
+
@app.get("/")
|
| 25 |
+
def welcome() -> dict[str, str]:
|
| 26 |
+
return {
|
| 27 |
+
"message": "Bienvenue sur l'API RAG.",
|
| 28 |
+
"docs": "/docs",
|
| 29 |
+
"health": "/health",
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
@app.middleware("http")
|
| 33 |
async def inbound_logging_middleware(request: Request, call_next):
|
| 34 |
request_id = request.headers.get("x-request-id", str(uuid.uuid4()))
|
tests/contract/http/test_app_contract.py
CHANGED
|
@@ -40,6 +40,19 @@ class AppContractTests(unittest.TestCase):
|
|
| 40 |
self.container = FakeContainer()
|
| 41 |
self.client = TestClient(create_app(container=self.container))
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
def test_health_endpoint(self):
|
| 44 |
response = self.client.get("/health")
|
| 45 |
|
|
|
|
| 40 |
self.container = FakeContainer()
|
| 41 |
self.client = TestClient(create_app(container=self.container))
|
| 42 |
|
| 43 |
+
def test_root_endpoint_returns_welcome_message(self):
|
| 44 |
+
response = self.client.get("/")
|
| 45 |
+
|
| 46 |
+
self.assertEqual(response.status_code, 200)
|
| 47 |
+
self.assertEqual(
|
| 48 |
+
response.json(),
|
| 49 |
+
{
|
| 50 |
+
"message": "Bienvenue sur l'API RAG.",
|
| 51 |
+
"docs": "/docs",
|
| 52 |
+
"health": "/health",
|
| 53 |
+
},
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
def test_health_endpoint(self):
|
| 57 |
response = self.client.get("/health")
|
| 58 |
|