-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gateway,agents-api): Add scalar for documentation
Signed-off-by: Diwank Tomer <[email protected]>
- Loading branch information
Diwank Tomer
committed
Aug 28, 2024
1 parent
2bf6359
commit 617ad83
Showing
9 changed files
with
80 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
|
||
from .common.exceptions import BaseCommonException | ||
from .dependencies.auth import get_api_key | ||
from .env import sentry_dsn | ||
from .env import api_prefix, hostname, sentry_dsn | ||
from .exceptions import PromptTooBigError | ||
from .routers import ( | ||
agents, | ||
|
@@ -84,22 +84,37 @@ def register_exceptions(app: FastAPI) -> None: | |
# Because some routes don't require auth | ||
# See: https://fastapi.tiangolo.com/tutorial/bigger-applications/ | ||
# | ||
app: Any = FastAPI(docs_url="/swagger") | ||
app: Any = FastAPI( | ||
docs_url="/swagger", | ||
openapi_prefix=api_prefix, | ||
redoc_url=None, | ||
title="Julep Agents API", | ||
description="API for Julep Agents", | ||
version="0.4.0", | ||
terms_of_service="https://www.julep.ai/terms", | ||
contact={ | ||
"name": "Julep", | ||
"url": "https://www.julep.ai", | ||
"email": "[email protected]", | ||
}, | ||
root_path=api_prefix, | ||
) | ||
|
||
# Create a new router for the docs | ||
docs_router = APIRouter() | ||
scalar_router = APIRouter() | ||
|
||
|
||
@docs_router.get("/docs", include_in_schema=False) | ||
@scalar_router.get("/docs", include_in_schema=False) | ||
async def scalar_html(): | ||
return get_scalar_api_reference( | ||
openapi_url=app.openapi_url[1:], # Remove leading '/' | ||
title=app.title, | ||
servers=[{"url": f"http://{hostname}{api_prefix}"}], | ||
) | ||
|
||
|
||
# Add the docs_router without dependencies | ||
app.include_router(docs_router) | ||
app.include_router(scalar_router) | ||
|
||
# Add other routers with the get_api_key dependency | ||
app.include_router(agents.router, dependencies=[Depends(get_api_key)]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters