Skip to content

Commit

Permalink
Merge pull request langchain-ai#155 from langchain-ai/nc/jan30/fix-ui…
Browse files Browse the repository at this point in the history
…-folder-missing

Fix for when backend/ui folder is missing
  • Loading branch information
nfcampos authored Jan 30, 2024
2 parents d461530 + 2898921 commit 53d885c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit 53d885c

Please sign in to comment.