Coverage for src / lilbee / server / handlers / __init__.py: 100%
17 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-05-15 20:55 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-05-15 20:55 +0000
1"""Framework-agnostic route handlers for the lilbee HTTP server.
3Every public function is a plain async callable; no framework imports.
4Return types are dicts (JSON responses), lists, or async generators of SSE strings.
6Handlers are grouped by concern (sse, rag, models, ingest, config, documents,
7crawl) under sibling submodules. The names re-exported below are the public
8API consumed by ``server/routes/*.py``.
9"""
11from __future__ import annotations
13from lilbee.app.status import gather_status
14from lilbee.app.version import get_version
15from lilbee.server.handlers.config import (
16 get_config,
17 get_config_defaults,
18 update_config,
19)
20from lilbee.server.handlers.crawl import crawl_stream
21from lilbee.server.handlers.documents import (
22 delete_documents,
23 get_source_content,
24 list_documents,
25)
26from lilbee.server.handlers.ingest import (
27 MAX_ADD_FILES,
28 add_files_stream,
29 sync_stream,
30 validate_add_paths,
31)
32from lilbee.server.handlers.models import (
33 TASK_ENDPOINT_PATH,
34 ModelCatalogSection,
35 ModelsResponse,
36 format_task_mismatch,
37 list_external_models,
38 list_models,
39 models_catalog,
40 models_delete,
41 models_installed,
42 models_pull,
43 models_show,
44 set_chat_model,
45 set_embedding_model,
46 set_reranker_model,
47 set_vision_model,
48)
49from lilbee.server.handlers.rag import (
50 ask,
51 ask_stream,
52 chat,
53 chat_stream,
54 search,
55)
56from lilbee.server.handlers.sse import (
57 SseStream,
58 classify_load_error,
59 sse_done,
60 sse_error,
61 sse_event,
62)
63from lilbee.server.models import HealthResponse, StatusResponse
66async def health() -> HealthResponse:
67 """Return service health and version."""
68 return HealthResponse(status="ok", version=get_version())
71async def status() -> StatusResponse:
72 """Return config, sources, and chunk counts."""
73 raw = gather_status()
74 return StatusResponse(**raw.model_dump(exclude_none=True))
77__all__ = [
78 "MAX_ADD_FILES",
79 "TASK_ENDPOINT_PATH",
80 "ModelCatalogSection",
81 "ModelsResponse",
82 "SseStream",
83 "add_files_stream",
84 "ask",
85 "ask_stream",
86 "chat",
87 "chat_stream",
88 "classify_load_error",
89 "crawl_stream",
90 "delete_documents",
91 "format_task_mismatch",
92 "get_config",
93 "get_config_defaults",
94 "get_source_content",
95 "health",
96 "list_documents",
97 "list_external_models",
98 "list_models",
99 "models_catalog",
100 "models_delete",
101 "models_installed",
102 "models_pull",
103 "models_show",
104 "search",
105 "set_chat_model",
106 "set_embedding_model",
107 "set_reranker_model",
108 "set_vision_model",
109 "sse_done",
110 "sse_error",
111 "sse_event",
112 "status",
113 "sync_stream",
114 "update_config",
115 "validate_add_paths",
116]