Spaces:
Sleeping
Sleeping
Download backend/routers/search.py from solvorlabs/docforge-api: direct link, hf CLI and curl.
- Browser
- Download file 668 Bytes
-
https://huggingface.co/spaces/solvorlabs/docforge-api/resolve/main/backend/routers/search.py
- Command line
-
hf download hf://spaces/solvorlabs/docforge-api/backend/routers/search.py
-
curl -L -o search.py https://huggingface.co/spaces/solvorlabs/docforge-api/resolve/main/backend/routers/search.py
668 Bytes
| """GET /api/search?q={query} — search cached libraries.""" | |
| from fastapi import APIRouter, Query | |
| from ..models.schemas import SearchResponse, SearchResult | |
| from ..services.cache import search_cached_libraries | |
| router = APIRouter(prefix="/api/search", tags=["search"]) | |
| async def search_libraries(q: str = Query("", description="Search query"), limit: int = Query(20)) -> SearchResponse: | |
| """Search the DocForge cache for libraries matching a query string.""" | |
| raw_results = await search_cached_libraries(q) | |
| results = [SearchResult(**r) for r in raw_results][:limit] | |
| return SearchResponse(results=results) |