From d5d02d314aee78f64fea485f16ff7c93a79af4bf Mon Sep 17 00:00:00 2001 From: Devis Lucato Date: Wed, 30 Aug 2023 10:01:33 -0700 Subject: [PATCH 1/3] Make bash scripts executable --- scripts/{Configure.sh => _Configure.sh} | 0 scripts/{Install-apt.sh => _Install-apt.sh} | 0 scripts/{Install-brew.sh => _Install-brew.sh} | 0 scripts/{Start-Backend.sh => _Start-Backend.sh} | 0 scripts/{Start-Frontend.sh => _Start-Frontend.sh} | 0 scripts/{Start.sh => _Start.sh} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename scripts/{Configure.sh => _Configure.sh} (100%) mode change 100644 => 100755 rename scripts/{Install-apt.sh => _Install-apt.sh} (100%) mode change 100644 => 100755 rename scripts/{Install-brew.sh => _Install-brew.sh} (100%) mode change 100644 => 100755 rename scripts/{Start-Backend.sh => _Start-Backend.sh} (100%) mode change 100644 => 100755 rename scripts/{Start-Frontend.sh => _Start-Frontend.sh} (100%) mode change 100644 => 100755 rename scripts/{Start.sh => _Start.sh} (100%) mode change 100644 => 100755 diff --git a/scripts/Configure.sh b/scripts/_Configure.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/Configure.sh rename to scripts/_Configure.sh diff --git a/scripts/Install-apt.sh b/scripts/_Install-apt.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/Install-apt.sh rename to scripts/_Install-apt.sh diff --git a/scripts/Install-brew.sh b/scripts/_Install-brew.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/Install-brew.sh rename to scripts/_Install-brew.sh diff --git a/scripts/Start-Backend.sh b/scripts/_Start-Backend.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/Start-Backend.sh rename to scripts/_Start-Backend.sh diff --git a/scripts/Start-Frontend.sh b/scripts/_Start-Frontend.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/Start-Frontend.sh rename to scripts/_Start-Frontend.sh diff --git a/scripts/Start.sh b/scripts/_Start.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/Start.sh rename to scripts/_Start.sh From b44f3d4d61ab46b18adf0a1ce5c9dfbcebb04af8 Mon Sep 17 00:00:00 2001 From: Devis Lucato Date: Wed, 30 Aug 2023 10:01:45 -0700 Subject: [PATCH 2/3] Rename bash scripts to lowercase, fix shebang to use $PATH (portability) --- .editorconfig | 4 ++++ .github/workflows/copilot-build-frontend.yml | 2 +- .vscode/settings.json | 2 ++ README.md | 15 +++++++-------- scripts/{_Configure.sh => configure.sh} | 2 +- scripts/deploy/deploy-azure.sh | 2 +- scripts/deploy/deploy-webapi.sh | 2 +- scripts/deploy/deploy-webapp.sh | 2 +- scripts/deploy/package-webapi.sh | 2 +- scripts/{_Install-apt.sh => install-apt.sh} | 2 +- scripts/{_Install-brew.sh => install-brew.sh} | 2 +- scripts/{_Start-Backend.sh => start-backend.sh} | 2 +- scripts/{_Start-Frontend.sh => start-frontend.sh} | 2 +- scripts/{_Start.sh => start.sh} | 2 +- 14 files changed, 24 insertions(+), 19 deletions(-) rename scripts/{_Configure.sh => configure.sh} (99%) mode change 100644 => 100755 scripts/deploy/deploy-webapi.sh mode change 100644 => 100755 scripts/deploy/package-webapi.sh rename scripts/{_Install-apt.sh => install-apt.sh} (97%) rename scripts/{_Install-brew.sh => install-brew.sh} (93%) rename scripts/{_Start-Backend.sh => start-backend.sh} (96%) rename scripts/{_Start-Frontend.sh => start-frontend.sh} (91%) rename scripts/{_Start.sh => start.sh} (92%) diff --git a/.editorconfig b/.editorconfig index 1a05f3eb4..6021d364e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,6 +8,10 @@ root = true indent_style = space end_of_line = lf +# Bash scripts +[*.sh] +indent_size = 2 + # XML project files [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] indent_size = 2 diff --git a/.github/workflows/copilot-build-frontend.yml b/.github/workflows/copilot-build-frontend.yml index 7c8fb46ce..3d7e989a8 100644 --- a/.github/workflows/copilot-build-frontend.yml +++ b/.github/workflows/copilot-build-frontend.yml @@ -26,7 +26,7 @@ jobs: - name: Run yarn install, yarn build, & yarn format run: | - #!/bin/bash + #!/usr/bin/env bash set -e # exit with nonzero exit code if anything fails echo "Running yarn install, yarn build, & yarn format" yarn install --frozen-lockfile # install dependencies and ensure lockfile is unchanged. diff --git a/.vscode/settings.json b/.vscode/settings.json index de116f78c..00085e410 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -49,4 +49,6 @@ "**/Thumbs.db": true, "**.lock": true, }, + "dotnet.defaultSolution": "CopilotChat.sln", + "editor.tabSize": 2, } \ No newline at end of file diff --git a/README.md b/README.md index 0b589b0ba..92f056ecc 100644 --- a/README.md +++ b/README.md @@ -73,13 +73,12 @@ You will need the following items to run the sample: ```bash cd /scripts/ - chmod +x *.sh - ``` + ``` **Ubuntu/Debian Linux** ```bash - ./Install-apt.sh + ./install-apt.sh ``` > NOTE: This script uses `apt` to install `dotnet-sdk-7.0`, `nodejs`, and `yarn`. @@ -87,7 +86,7 @@ You will need the following items to run the sample: **macOS** ```bash - ./Install-brew.sh + ./install-brew.sh ``` > NOTE: This script uses `homebrew` to install `dotnet-sdk`, `nodejs`, and `yarn`. @@ -95,7 +94,7 @@ You will need the following items to run the sample: 3. Configure Chat Copilot. ```bash - ./Configure.sh --aiservice {AI_SERVICE} --apikey {API_KEY} --endpoint {AZURE_OPENAI_ENDPOINT} + ./configure.sh --aiservice {AI_SERVICE} --apikey {API_KEY} --endpoint {AZURE_OPENAI_ENDPOINT} ``` - `AI_SERVICE`: `AzureOpenAI` or `OpenAI`. @@ -112,7 +111,7 @@ You will need the following items to run the sample: 4. Run Chat Copilot locally. This step starts both the backend API and frontend application. ```bash - ./Start.sh + ./start.sh ``` It may take a few minutes for Yarn packages to install on the first run. @@ -199,7 +198,7 @@ By default, Chat Copilot runs locally without authentication, using a guest user **Bash** ```bash - ./Configure.sh --aiservice {AI_SERVICE} --apikey {API_KEY} --endpoint {AZURE_OPENAI_ENDPOINT} --frontend-clientid {FRONTEND_APPLICATION_ID} --backend-clientid {BACKEND_APPLICATION_ID} --tenantid {TENANT_ID} --instance {AZURE_AD_INSTANCE} + ./configure.sh --aiservice {AI_SERVICE} --apikey {API_KEY} --endpoint {AZURE_OPENAI_ENDPOINT} --frontend-clientid {FRONTEND_APPLICATION_ID} --backend-clientid {BACKEND_APPLICATION_ID} --tenantid {TENANT_ID} --instance {AZURE_AD_INSTANCE} ``` - `AI_SERVICE`: `AzureOpenAI` or `OpenAI`. @@ -221,7 +220,7 @@ By default, Chat Copilot runs locally without authentication, using a guest user **Bash** ```bash - ./Start.sh + ./start.sh ``` # Troubleshooting diff --git a/scripts/_Configure.sh b/scripts/configure.sh similarity index 99% rename from scripts/_Configure.sh rename to scripts/configure.sh index 1812f68c3..eeddb6f11 100755 --- a/scripts/_Configure.sh +++ b/scripts/configure.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Configure user secrets, appsettings.Development.json, and webapp/.env for Chat Copilot. set -e diff --git a/scripts/deploy/deploy-azure.sh b/scripts/deploy/deploy-azure.sh index db2b07285..aefd6cdce 100755 --- a/scripts/deploy/deploy-azure.sh +++ b/scripts/deploy/deploy-azure.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Deploy Chat Copilot Azure resources. diff --git a/scripts/deploy/deploy-webapi.sh b/scripts/deploy/deploy-webapi.sh old mode 100644 new mode 100755 index 1413a7f77..aa489d2aa --- a/scripts/deploy/deploy-webapi.sh +++ b/scripts/deploy/deploy-webapi.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Deploy CopilotChat's WebAPI to Azure. diff --git a/scripts/deploy/deploy-webapp.sh b/scripts/deploy/deploy-webapp.sh index 02347e2cc..9bba0a0de 100755 --- a/scripts/deploy/deploy-webapp.sh +++ b/scripts/deploy/deploy-webapp.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Deploy CopilotChat's WebApp to Azure diff --git a/scripts/deploy/package-webapi.sh b/scripts/deploy/package-webapi.sh old mode 100644 new mode 100755 index 97b624d8a..8a81125a8 --- a/scripts/deploy/package-webapi.sh +++ b/scripts/deploy/package-webapi.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Package CiopilotChat's WebAPI for deployment to Azure diff --git a/scripts/_Install-apt.sh b/scripts/install-apt.sh similarity index 97% rename from scripts/_Install-apt.sh rename to scripts/install-apt.sh index 5153baa5a..ab1850f11 100755 --- a/scripts/_Install-apt.sh +++ b/scripts/install-apt.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Installs the requirements for running Chat Copilot. diff --git a/scripts/_Install-brew.sh b/scripts/install-brew.sh similarity index 93% rename from scripts/_Install-brew.sh rename to scripts/install-brew.sh index 7cd1444be..4b4be44e9 100755 --- a/scripts/_Install-brew.sh +++ b/scripts/install-brew.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Installs the requirements for running Chat Copilot. diff --git a/scripts/_Start-Backend.sh b/scripts/start-backend.sh similarity index 96% rename from scripts/_Start-Backend.sh rename to scripts/start-backend.sh index b887473e2..8b9a9ed68 100755 --- a/scripts/_Start-Backend.sh +++ b/scripts/start-backend.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Builds and runs the Chat Copilot backend. diff --git a/scripts/_Start-Frontend.sh b/scripts/start-frontend.sh similarity index 91% rename from scripts/_Start-Frontend.sh rename to scripts/start-frontend.sh index 86d30d505..0421a979a 100755 --- a/scripts/_Start-Frontend.sh +++ b/scripts/start-frontend.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Builds and runs the Chat Copilot frontend. diff --git a/scripts/_Start.sh b/scripts/start.sh similarity index 92% rename from scripts/_Start.sh rename to scripts/start.sh index edf88aff4..e6d878a9e 100755 --- a/scripts/_Start.sh +++ b/scripts/start.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Initializes and runs both the backend and frontend for Copilot Chat. From e35fee0ec008c57c3e8c5c72dbb09402eeb5c5db Mon Sep 17 00:00:00 2001 From: Devis Lucato Date: Wed, 30 Aug 2023 10:35:43 -0700 Subject: [PATCH 3/3] Improve setup docs in README --- README.md | 39 +++++++++++++++++++++++++++++---------- scripts/start-backend.sh | 4 ++-- scripts/start.sh | 4 ++-- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 92f056ecc..1f9915540 100644 --- a/README.md +++ b/README.md @@ -93,20 +93,39 @@ You will need the following items to run the sample: 3. Configure Chat Copilot. - ```bash - ./configure.sh --aiservice {AI_SERVICE} --apikey {API_KEY} --endpoint {AZURE_OPENAI_ENDPOINT} - ``` + 1. For OpenAI - - `AI_SERVICE`: `AzureOpenAI` or `OpenAI`. - - `API_KEY`: The `API key` for Azure OpenAI or for OpenAI. - - `AZURE_OPENAI_ENDPOINT`: The Azure OpenAI resource `Endpoint` address. Omit `--endpoint` if using OpenAI. + ```bash + ./configure.sh --aiservice OpenAI --apikey {API_KEY} + ``` + - `API_KEY`: The `API key` for OpenAI. - - > **IMPORTANT:** For `AzureOpenAI`, if you deployed models `gpt-35-turbo` and `text-embedding-ada-002` with custom names (instead of each own's given name), also use the parameters: - ```bash - --completionmodel {DEPLOYMENT_NAME} --embeddingmodel {DEPLOYMENT_NAME} --plannermodel {DEPLOYMENT_NAME} - ``` + 2. For Azure OpenAI + + ```bash + ./configure.sh --aiservice AzureOpenAI \ + --endpoint {AZURE_OPENAI_ENDPOINT} \ + --apikey {API_KEY} + ``` + + - `AZURE_OPENAI_ENDPOINT`: The Azure OpenAI resource `Endpoint` address. + - `API_KEY`: The `API key` for Azure OpenAI. + + + **IMPORTANT:** If you deployed models `gpt-35-turbo` and `text-embedding-ada-002` + with custom names (instead of each own's given name), you need to specify + the deployment names with three additional parameters: + + ```bash + ./configure.sh --aiservice AzureOpenAI \ + --endpoint {AZURE_OPENAI_ENDPOINT} \ + --apikey {API_KEY} \ + --completionmodel {DEPLOYMENT_NAME} \ + --plannermodel {DEPLOYMENT_NAME} \ + --embeddingmodel {DEPLOYMENT_NAME} + ``` 4. Run Chat Copilot locally. This step starts both the backend API and frontend application. diff --git a/scripts/start-backend.sh b/scripts/start-backend.sh index 8b9a9ed68..c5bc2b820 100755 --- a/scripts/start-backend.sh +++ b/scripts/start-backend.sh @@ -5,7 +5,7 @@ set -e # Stop any existing backend API process -while pid=$(pgrep CopilotChatWebA); do +while pid=$(pgrep CopilotChatWebA); do echo $pid | sed 's/\([0-9]\{4\}\) .*/\1/' | xargs kill done @@ -14,7 +14,7 @@ SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" . $SCRIPT_DIRECTORY/.env cd "$SCRIPT_DIRECTORY/../webapi" -# Environment variable `ASPNETCORE_ENVIRONMENT` required to override appsettings.json with +# Environment variable `ASPNETCORE_ENVIRONMENT` required to override appsettings.json with # appsettings.$ENV_ASPNETCORE.json. See `webapi/ConfigurationExtensions.cs` export ASPNETCORE_ENVIRONMENT=$ENV_ASPNETCORE diff --git a/scripts/start.sh b/scripts/start.sh index e6d878a9e..9d035e16e 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -8,7 +8,7 @@ ScriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$ScriptDir" # Start backend (in background) -./Start-Backend.sh & +./start-backend.sh & # Start frontend -./Start-Frontend.sh +./start-frontend.sh