Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for when backend/ui folder is missing #155

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.gcp.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ AZURE_OPENAI_API_BASE: your_secret_here
AZURE_OPENAI_API_VERSION: your_secret_here
AZURE_OPENAI_API_KEY: your_secret_here
KAY_API_KEY: your_secret_here
ROBOCORP_ACTION_SERVER_URL: https://dummy-action-server.robocorp.link
ROBOCORP_ACTION_SERVER_KEY: dummy-api-key
11 changes: 10 additions & 1 deletion backend/app/server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os
import logging
from pathlib import Path

import orjson
Expand All @@ -7,6 +9,8 @@
from app.api import router as api_router
from app.upload import ingest_runnable

logger = logging.getLogger(__name__)

app = FastAPI(title="OpenGPTs API")


Expand All @@ -24,7 +28,12 @@ def ingest_files(files: list[UploadFile], config: str = Form(...)) -> None:
return ingest_runnable.batch([file.file for file in files], config)


app.mount("", StaticFiles(directory=str(ROOT / "ui"), html=True), name="ui")
ui_dir = str(ROOT / "ui")

if os.path.exists(ui_dir):
app.mount("", StaticFiles(directory=ui_dir, html=True), name="ui")
else:
logger.warn("No UI directory found, serving API only.")

if __name__ == "__main__":
import uvicorn
Expand Down
Loading