Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
fastapi.py19 linesDownload Raw Back to utils
1from uuid import UUID
2from starlette.responses import JSONResponse
3
4from chromadb.errors import ChromaError, InvalidUUIDError
5
6
7def fastapi_json_response(error: ChromaError) -> JSONResponse:
8    return JSONResponse(
9        content={"error": error.name(), "message": error.message()},
10        status_code=error.code(),
11    )
12
13
14def string_to_uuid(uuid_str: str) -> UUID:
15    try:
16        return UUID(uuid_str)
17    except ValueError:
18        raise InvalidUUIDError(f"Could not parse {uuid_str} as a UUID")
19 
codekingpro/portable-devtools · Team Ai