Spaces:
Sleeping
Sleeping
Download src/modules/knowledge/api/router.py from dellweb3/VibeCoding: direct link, hf CLI and curl.
- Browser
- Download file 934 Bytes
-
https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/modules/knowledge/api/router.py
- Command line
-
hf download hf://spaces/dellweb3/VibeCoding/src/modules/knowledge/api/router.py
-
curl -L -o router.py https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/modules/knowledge/api/router.py
934 Bytes
| from fastapi import APIRouter, Depends | |
| from pydantic import Field | |
| from src.modules.skill.domain.models import Contract | |
| class Search(Contract): | |
| query: str = Field(min_length=1, max_length=300) | |
| collection_ids: list[str] = Field(min_length=1, max_length=10) | |
| limit: int = Field(default=8, ge=1, le=20) | |
| for_code_reuse: bool = False | |
| def build_router(catalog, principal): | |
| router = APIRouter(prefix="/api/v1", tags=["ZKCoding Knowledge"]) | |
| def collections(actor=Depends(principal)): | |
| return {"items": catalog.collections(actor)} | |
| def search(data: Search, actor=Depends(principal)): | |
| return {"items": catalog.search(actor, data.query, data.collection_ids, data.limit, for_code_reuse=data.for_code_reuse), "mode": "lexical_with_explicit_aliases", "review": "external_reference_not_enterprise_rule"} | |
| return router | |