From d919422836929a5e95ea92b52da5ba16befb1836 Mon Sep 17 00:00:00 2001 From: "Huu Le (Lee)" <39040748+leehuwuj@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:08:53 +0700 Subject: [PATCH] fix: add missing env value; improve docs and error message (#638) --- create-app.ts | 4 ++-- helpers/env-variables.ts | 1 + index.ts | 2 +- templates/types/simple/fastapi/README-template.md | 6 ++++-- templates/types/simple/fastapi/main.py | 3 ++- templates/types/streaming/fastapi/README-template.md | 6 ++++-- templates/types/streaming/fastapi/main.py | 3 ++- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/create-app.ts b/create-app.ts index f59a9e9a6..8d6ce9c50 100644 --- a/create-app.ts +++ b/create-app.ts @@ -116,14 +116,14 @@ export async function createApp({ await installTemplate({ ...args, backend: true }); } + await writeDevcontainer(root, templatesDir, framework, frontend); + process.chdir(root); if (tryGitInit(root)) { console.log("Initialized a git repository."); console.log(); } - await writeDevcontainer(root, templatesDir, framework, frontend); - if (toolsRequireConfig(tools)) { console.log( yellow( diff --git a/helpers/env-variables.ts b/helpers/env-variables.ts index 20d4cb7d9..f9f6d370a 100644 --- a/helpers/env-variables.ts +++ b/helpers/env-variables.ts @@ -199,6 +199,7 @@ Given this information, please answer the question: {query_str} name: "NEXT_PUBLIC_MODEL", description: "The LLM model to use (hardcode to front-end artifact).", + value: opts.model || "gpt-3.5-turbo", } : {}, ], diff --git a/index.ts b/index.ts index 47e78c26a..131d6eba2 100644 --- a/index.ts +++ b/index.ts @@ -315,7 +315,7 @@ Got error: ${(error as Error).message}.\n`, ), ); console.log( - `Make sure you have VSCode installed and added to your PATH. + `Make sure you have VSCode installed and added to your PATH (shell alias will not work). Please check ${cyan( terminalLink( "This documentation", diff --git a/templates/types/simple/fastapi/README-template.md b/templates/types/simple/fastapi/README-template.md index 38f3c4a3f..b1a35c42e 100644 --- a/templates/types/simple/fastapi/README-template.md +++ b/templates/types/simple/fastapi/README-template.md @@ -2,7 +2,9 @@ This is a [LlamaIndex](https://www.llamaindex.ai/) project using [FastAPI](https ## Getting Started -First, setup the environment: +First, setup the environment with poetry: + +> **_Note:_** This step is not needed if you are using the dev-container. ``` poetry install @@ -44,7 +46,7 @@ Open [http://localhost:8000/docs](http://localhost:8000/docs) with your browser The API allows CORS for all origins to simplify development. You can change this behavior by setting the `ENVIRONMENT` environment variable to `prod`: ``` -ENVIRONMENT=prod uvicorn main:app +ENVIRONMENT=prod python main.py ``` ## Learn More diff --git a/templates/types/simple/fastapi/main.py b/templates/types/simple/fastapi/main.py index 691f543d6..41721a8f2 100644 --- a/templates/types/simple/fastapi/main.py +++ b/templates/types/simple/fastapi/main.py @@ -34,5 +34,6 @@ if __name__ == "__main__": app_host = os.getenv("APP_HOST", "0.0.0.0") app_port = int(os.getenv("APP_PORT", "8000")) + reload = True if environment == "dev" else False - uvicorn.run(app="main:app", host=app_host, port=app_port, reload=True) + uvicorn.run(app="main:app", host=app_host, port=app_port, reload=reload) diff --git a/templates/types/streaming/fastapi/README-template.md b/templates/types/streaming/fastapi/README-template.md index fdbb73a15..35ef1125a 100644 --- a/templates/types/streaming/fastapi/README-template.md +++ b/templates/types/streaming/fastapi/README-template.md @@ -2,7 +2,9 @@ This is a [LlamaIndex](https://www.llamaindex.ai/) project using [FastAPI](https ## Getting Started -First, setup the environment: +First, setup the environment with poetry: + +> **_Note:_** This step is not needed if you are using the dev-container. ``` poetry install @@ -44,7 +46,7 @@ Open [http://localhost:8000/docs](http://localhost:8000/docs) with your browser The API allows CORS for all origins to simplify development. You can change this behavior by setting the `ENVIRONMENT` environment variable to `prod`: ``` -ENVIRONMENT=prod uvicorn main:app +ENVIRONMENT=prod python main.py ``` ## Learn More diff --git a/templates/types/streaming/fastapi/main.py b/templates/types/streaming/fastapi/main.py index 7e7d42496..edba3d3a7 100644 --- a/templates/types/streaming/fastapi/main.py +++ b/templates/types/streaming/fastapi/main.py @@ -35,5 +35,6 @@ if __name__ == "__main__": app_host = os.getenv("APP_HOST", "0.0.0.0") app_port = int(os.getenv("APP_PORT", "8000")) + reload = True if environment == "dev" else False - uvicorn.run(app="main:app", host=app_host, port=app_port, reload=True) + uvicorn.run(app="main:app", host=app_host, port=app_port, reload=reload)