From 2913d1d1272663006df6f70d304487a7264cce44 Mon Sep 17 00:00:00 2001 From: Desmond Howard Date: Tue, 8 Aug 2023 16:39:50 -0400 Subject: [PATCH] Run formatting scripts during PR builds (#124) ### Motivation and Context brings in the renaming/consolidation changes from #60 and adds the format scripts to run as part of PR builds. hopefully one day we will have automated fixing of the formatting errors, but for now they must be fixed by the developer manually. ### Description - fixes all formatting errors. - updates READMEs to use relative links where possible since absolute links are not caught by `markdown-link-check`. - github workflows: - adds `copilot-format-frontend` which runs `yarn format` to check if formatting is correct. - renames `node-pr` to `copilot-build-frontend` and removes the `find-yarn-projects` job from the workflow. - removes `copilot-chat-package` in favor of `copilot-build-backend` since the two workflows seem identical. also changes `copilot-build-backend` to run `dotnet format`, and also run when PRs are created. ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [Contribution Guidelines](https://github.com/microsoft/copilot-chat/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/copilot-chat/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone :smile: --- ...ot-build.yml => copilot-build-backend.yml} | 19 +- .github/workflows/copilot-build-frontend.yml | 33 +++ .github/workflows/copilot-chat-package.yml | 55 ---- .github/workflows/copilot-deploy-backend.yml | 2 +- .github/workflows/copilot-deploy-frontend.yml | 4 +- .github/workflows/copilot-deploy-pipeline.yml | 2 +- ...ot-chat-tests.yml => copilot-test-e2e.yml} | 2 +- .github/workflows/node-pr.yml | 70 ----- README.md | 242 +++++++++--------- scripts/README.md | 3 +- webapi/Controllers/BotController.cs | 10 +- webapi/Controllers/ChatController.cs | 10 +- webapi/Controllers/ChatHistoryController.cs | 14 +- webapi/Controllers/ChatMemoryController.cs | 6 +- .../Controllers/ChatParticipantController.cs | 6 +- .../Controllers/DocumentImportController.cs | 16 +- webapi/Controllers/SpeechTokenController.cs | 4 +- webapi/Extensions/SemanticKernelExtensions.cs | 10 +- webapi/Extensions/ServiceExtensions.cs | 10 +- webapi/Models/Response/Bot.cs | 4 +- webapi/Program.cs | 6 +- webapi/Skills/ChatSkills/ChatSkill.cs | 12 +- .../Skills/ChatSkills/CopilotChatPlanner.cs | 8 +- .../Skills/ChatSkills/DocumentMemorySkill.cs | 2 +- .../ChatSkills/ExternalInformationSkill.cs | 8 +- .../ChatSkills/SemanticChatMemoryExtractor.cs | 4 +- .../ChatSkills/SemanticChatMemorySkill.cs | 6 +- webapi/Skills/TokenUtilities.cs | 1 - webapp/package.json | 3 +- .../chat/chat-list/ListItemActions.tsx | 4 +- .../components/chat/controls/ShareBotMenu.tsx | 4 +- .../InvitationCreateDialog.tsx | 13 +- .../InvitationJoinDialog.tsx | 8 +- .../components/header/UserSettingsMenu.tsx | 14 +- .../header/settings-dialog/SettingSection.tsx | 4 +- .../plugin-wizard/steps/EnterManifestStep.tsx | 2 +- webapp/src/components/shared/BundledIcons.tsx | 2 +- webapp/src/components/utils/PluginUtils.ts | 6 +- webapp/src/components/views/BackendProbe.tsx | 4 +- webapp/src/components/views/Login.tsx | 10 +- .../views/MissingEnvVariablesError.tsx | 4 +- webapp/src/index.css | 6 +- .../conversations/ConversationsState.ts | 2 +- 43 files changed, 310 insertions(+), 345 deletions(-) rename .github/workflows/{copilot-build.yml => copilot-build-backend.yml} (67%) create mode 100644 .github/workflows/copilot-build-frontend.yml delete mode 100644 .github/workflows/copilot-chat-package.yml rename .github/workflows/{copilot-chat-tests.yml => copilot-test-e2e.yml} (99%) delete mode 100644 .github/workflows/node-pr.yml diff --git a/.github/workflows/copilot-build.yml b/.github/workflows/copilot-build-backend.yml similarity index 67% rename from .github/workflows/copilot-build.yml rename to .github/workflows/copilot-build-backend.yml index 7f88f2080..0eed8fb3f 100644 --- a/.github/workflows/copilot-build.yml +++ b/.github/workflows/copilot-build-backend.yml @@ -1,17 +1,21 @@ -name: copilot-build +name: copilot-build-backend on: + pull_request: + branches: ["main"] + merge_group: + branches: ["main"] workflow_call: outputs: artifact: description: "The name of the uploaded artifact." - value: ${{jobs.web-api.outputs.artifact}} + value: ${{jobs.webapi.outputs.artifact}} permissions: contents: read jobs: - web-api: + webapi: strategy: fail-fast: false matrix: @@ -33,7 +37,12 @@ jobs: - name: Package Copilot Chat WebAPI run: | - deploy\package-webapi.ps1 -Configuration Release -DotnetFramework net6.0 -TargetRuntime win-x64 -OutputDirectory ${{ github.workspace }}\deploy + scripts\deploy\package-webapi.ps1 -Configuration Release -DotnetFramework net6.0 -TargetRuntime win-x64 -OutputDirectory ${{ github.workspace }}\scripts\deploy + + - name: Check formatting of Copilot Chat WebAPI + run: | + cd webapi/ + dotnet format --verify-no-changes --verbosity diagnostic - name: Set version tag id: versiontag @@ -46,7 +55,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: copilotchat-webapi-${{ steps.versiontag.outputs.versiontag }} - path: ${{ github.workspace }}\deploy\out\webapi.zip + path: ${{ github.workspace }}\scripts\deploy\out\webapi.zip - name: "Set outputs" id: artifactoutput diff --git a/.github/workflows/copilot-build-frontend.yml b/.github/workflows/copilot-build-frontend.yml new file mode 100644 index 000000000..c74e7e4cf --- /dev/null +++ b/.github/workflows/copilot-build-frontend.yml @@ -0,0 +1,33 @@ +name: copilot-build-frontend + +on: + workflow_dispatch: + pull_request: + branches: ["main"] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + webapp: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: "yarn" + cache-dependency-path: "webapp/yarn.lock" + + - name: Run yarn install, yarn build, & yarn format + run: | + #!/bin/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. + yarn build # run build script + yarn format # run format script + working-directory: webapp diff --git a/.github/workflows/copilot-chat-package.yml b/.github/workflows/copilot-chat-package.yml deleted file mode 100644 index 7f02a25bb..000000000 --- a/.github/workflows/copilot-chat-package.yml +++ /dev/null @@ -1,55 +0,0 @@ -# -# This workflow will package the Copilot Chat application for deployment. -# - -name: copilot-chat-package - -on: - pull_request: - branches: ["main"] - merge_group: - branches: ["main"] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -permissions: - contents: read - -jobs: - copilot-chat-package: - strategy: - fail-fast: false - matrix: - include: - - { dotnet: "6.0", configuration: Release, os: ubuntu-latest } - - runs-on: ${{ matrix.os }} - env: - NUGET_CERT_REVOCATION_MODE: offline - steps: - - uses: actions/checkout@v3 - with: - clean: true - - - name: Pull container dotnet/sdk:${{ matrix.dotnet }} - run: docker pull mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }} - - - name: Package Copilot Chat WebAPI - run: | - chmod +x $(pwd)/scripts/deploy/package-webapi.sh; - docker run --rm -v $(pwd):/app -w /app -e GITHUB_ACTIONS='true' mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }} /bin/sh -c "/app/scripts/deploy/package-webapi.sh --no-zip"; - - - name: Set version tag - id: versiontag - run: | - VERSION_TAG="$(date +'%Y%m%d').${{ github.run_number }}.${{ github.run_attempt }}" - echo $VERSION_TAG - echo "versiontag=$VERSION_TAG" >> $GITHUB_OUTPUT - - - name: Upload package to artifacts - uses: actions/upload-artifact@v3 - with: - name: copilotchat-webapi-${{ steps.versiontag.outputs.versiontag }} - path: ./scripts/deploy/publish diff --git a/.github/workflows/copilot-deploy-backend.yml b/.github/workflows/copilot-deploy-backend.yml index 9ceb4e47e..464426bf4 100644 --- a/.github/workflows/copilot-deploy-backend.yml +++ b/.github/workflows/copilot-deploy-backend.yml @@ -24,7 +24,7 @@ permissions: contents: read jobs: - web-api: + webapi: environment: ${{inputs.ENVIRONMENT}} permissions: id-token: write diff --git a/.github/workflows/copilot-deploy-frontend.yml b/.github/workflows/copilot-deploy-frontend.yml index 311ad371d..77ee5fb9c 100644 --- a/.github/workflows/copilot-deploy-frontend.yml +++ b/.github/workflows/copilot-deploy-frontend.yml @@ -1,4 +1,4 @@ -name: copilot-deploy-backend +name: copilot-deploy-frontend on: workflow_call: @@ -23,7 +23,7 @@ permissions: contents: read jobs: - web-app: + webapp: environment: ${{inputs.ENVIRONMENT}} permissions: id-token: write diff --git a/.github/workflows/copilot-deploy-pipeline.yml b/.github/workflows/copilot-deploy-pipeline.yml index 37dc3b540..63a07437c 100644 --- a/.github/workflows/copilot-deploy-pipeline.yml +++ b/.github/workflows/copilot-deploy-pipeline.yml @@ -15,7 +15,7 @@ permissions: jobs: build: - uses: ./.github/workflows/copilot-build.yml + uses: ./.github/workflows/copilot-build-backend.yml int: needs: build diff --git a/.github/workflows/copilot-chat-tests.yml b/.github/workflows/copilot-test-e2e.yml similarity index 99% rename from .github/workflows/copilot-chat-tests.yml rename to .github/workflows/copilot-test-e2e.yml index 3c4bc9d46..d82167c93 100644 --- a/.github/workflows/copilot-chat-tests.yml +++ b/.github/workflows/copilot-test-e2e.yml @@ -8,7 +8,7 @@ permissions: contents: read jobs: - test: + e2e: defaults: run: working-directory: webapp diff --git a/.github/workflows/node-pr.yml b/.github/workflows/node-pr.yml deleted file mode 100644 index 9b4066c26..000000000 --- a/.github/workflows/node-pr.yml +++ /dev/null @@ -1,70 +0,0 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - -name: node-pr - -on: - workflow_dispatch: - pull_request: - branches: ["main"] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - find-yarn-projects: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-yarn-folders.outputs.matrix }} - - steps: - - uses: actions/checkout@v3 - - - name: Find yarn projects - id: set-yarn-folders - # This step uses a bash script to find all subfolders that contain a yarn.lock file - run: | - #!/bin/bash - set -e # exit with nonzero exit code if anything fails - shopt -s globstar # enable globstar option to use ** for recursive matching - yarndirs=() - for lockfile in **/yarn.lock; do # loop over all yarn.lock files - dir=$(dirname "$lockfile") # get the directory of the lock file - echo "Found yarn project in $dir" - yarndirs+=("$dir") # add the directory to the yarndirs array - done - - echo "All yarn projects found: '${yarndirs[*]}'" - yarndirs_json=$(echo -n "${yarndirs[*]%\n}" | jq -R -s -j --compact-output 'split(" ")') - matrix_json="{\"node_version\":[18], \"yarn_folder\":$yarndirs_json}" - echo "Setting output matrix to $matrix_json" - echo "matrix=$matrix_json" >> $GITHUB_OUTPUT - - build: - runs-on: ubuntu-latest - needs: find-yarn-projects - - strategy: - matrix: ${{ fromJson(needs.find-yarn-projects.outputs.matrix) }} - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node_version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node_version }} - cache: "yarn" - cache-dependency-path: "**/yarn.lock" - - - name: Run yarn install & yarn build - # This step runs yarn install and yarn build for each project. - # The --frozen-lockfile option ensures that the dependencies are installed exactly as specified in the lock file. - # The -cwd option sets the current working directory to the folder where the yarn.lock file is located. - run: | - #!/bin/bash - set -e # exit with nonzero exit code if anything fails - dir=${{ matrix.yarn_folder }} # get the directory of the lock file - echo "Running yarn install and yarn build for $dir" - yarn --cwd "$dir" install --frozen-lockfile # install dependencies - yarn --cwd "$dir" build # run build script diff --git a/README.md b/README.md index e0a27c858..3a5d88d2c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Chat Copilot Sample Application -This sample allows you to build your own integrated large language model (LLM) chat copilot. The sample is built on Microsoft Semantic Kernel and has two components: a frontend [React web app](./webapp/) and a backend [.NET web API service](./webapi/). +This sample allows you to build your own integrated large language model (LLM) chat copilot. The sample is built on Microsoft Semantic Kernel and has two components: a frontend [React web app](./webapp/) and a backend [.NET web API service](./webapi/). -These quick-start instructions run the sample locally. To deploy the sample to Azure, please view [Deploying Chat Copilot](https://github.com/microsoft/chat-copilot/blob/main/deploy/README.md). +These quick-start instructions run the sample locally. To deploy the sample to Azure, please view [Deploying Chat Copilot](./scripts/deploy/README.md). > **IMPORTANT:** This sample is for educational purposes only and is not recommended for production deployments. @@ -11,6 +11,7 @@ These quick-start instructions run the sample locally. To deploy the sample to A ![ChatCopilot](https://github.com/microsoft/chat-copilot/assets/64985898/4b5b4ddd-0ba5-4da1-9769-1bc4a74f1996) # Requirements + You will need the following items to run the sample: - [.NET 7.0 SDK](https://dotnet.microsoft.com/download/dotnet/7.0) _(via Setup script)_ @@ -26,227 +27,238 @@ You will need the following items to run the sample: | OpenAI | - [Account](https://platform.openai.com)
- [API key](https://platform.openai.com/account/api-keys) | # Instructions + ## Register an application + 1. Follow [these instructions](https://learn.microsoft.com/azure/active-directory/develop/quickstart-register-app) and use the values below: - - `Supported account types`: "_Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)_" - - `Redirect URI (optional)`: _Single-page application (SPA)_ and use _http://localhost:3000_. + - `Supported account types`: "_Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)_" + - `Redirect URI (optional)`: _Single-page application (SPA)_ and use _http://localhost:3000_. 2. Take note of the `Application (client) ID`. Chat Copilot will use this ID for authentication. ## Windows + 1. Open PowerShell as an administrator. 2. Setup your environment. - ```powershell - cd \scripts\ - .\Install.ps1 - ``` + ```powershell + cd \scripts\ + .\Install.ps1 + ``` - > NOTE: This script will install `Chocolatey`, `dotnet-7.0-sdk`, `nodejs`, and `yarn`. + > NOTE: This script will install `Chocolatey`, `dotnet-7.0-sdk`, `nodejs`, and `yarn`. 3. Configure Chat Copilot. - - ```powershell - .\Configure.ps1 -AIService {AI_SERVICE} -APIKey {API_KEY} -Endpoint {AZURE_OPENAI_ENDPOINT} -ClientId {AZURE_APPLICATION_ID} - ``` - - `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. - - `AZURE_APPLICATION_ID`: The `Application (client) ID` associated with the registered application. + ```powershell + .\Configure.ps1 -AIService {AI_SERVICE} -APIKey {API_KEY} -Endpoint {AZURE_OPENAI_ENDPOINT} -ClientId {AZURE_APPLICATION_ID} + ``` - - (Optional): To set a specific Tenant Id, use the parameter: + - `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. + - `AZURE_APPLICATION_ID`: The `Application (client) ID` associated with the registered application. - ```powershell - -TenantId {TENANT_ID} - ``` + - (Optional): To set a specific Tenant Id, use the parameter: - - > **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: + ```powershell + -TenantId {TENANT_ID} + ``` - ```powershell - -CompletionModel {DEPLOYMENT_NAME} -EmbeddingModel {DEPLOYMENT_NAME} -PlannerModel {DEPLOYMENT_NAME} - ``` + - > **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: + + ```powershell + -CompletionModel {DEPLOYMENT_NAME} -EmbeddingModel {DEPLOYMENT_NAME} -PlannerModel {DEPLOYMENT_NAME} + ``` 4. Run Chat Copilot locally. This step starts both the backend API and frontend application. - - ```powershell - .\Start.ps1 - ``` - It may take a few minutes for Yarn packages to install on the first run. + ```powershell + .\Start.ps1 + ``` + + It may take a few minutes for Yarn packages to install on the first run. - > NOTE: Confirm pop-ups are not blocked and you are logged in with the same account used to register the application. + > NOTE: Confirm pop-ups are not blocked and you are logged in with the same account used to register the application. ## Linux/macOS + 1. Open Bash as an administrator. 2. Configure environment. - - ```bash - cd /scripts/ - chmod +x *.sh - ``` + + ```bash + cd /scripts/ + chmod +x *.sh + ``` **Ubuntu/Debian Linux** - ```bash - ./Install-apt.sh - ``` + ```bash + ./Install-apt.sh + ``` - > NOTE: This script uses `apt` to install `dotnet-sdk-7.0`, `nodejs`, and `yarn`. + > NOTE: This script uses `apt` to install `dotnet-sdk-7.0`, `nodejs`, and `yarn`. - **macOS** + **macOS** - ```bash - ./Install-brew.sh - ``` + ```bash + ./Install-brew.sh + ``` - > NOTE: This script uses `homebrew` to install `dotnet-sdk`, `nodejs`, and `yarn`. + > NOTE: This script uses `homebrew` to install `dotnet-sdk`, `nodejs`, and `yarn`. 3. Configure Chat Copilot. - ```bash - ./Configure.sh --aiservice {AI_SERVICE} --apikey {API_KEY} --endpoint {AZURE_OPENAI_ENDPOINT} --clientid {AZURE_APPLICATION_ID} - ``` + ```bash + ./Configure.sh --aiservice {AI_SERVICE} --apikey {API_KEY} --endpoint {AZURE_OPENAI_ENDPOINT} --clientid {AZURE_APPLICATION_ID} + ``` - - `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. - - `AZURE_APPLICATION_ID`: The `Application (client) ID` associated with the registered application. + - `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. + - `AZURE_APPLICATION_ID`: The `Application (client) ID` associated with the registered application. - - (Optional): To set a specific Tenant Id, use the parameter: + - (Optional): To set a specific Tenant Id, use the parameter: - ```bash - --tenantid {TENANT_ID} - ``` + ```bash + --tenantid {TENANT_ID} + ``` - - > **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: + - > **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} - ``` + ```bash + --completionmodel {DEPLOYMENT_NAME} --embeddingmodel {DEPLOYMENT_NAME} --plannermodel {DEPLOYMENT_NAME} + ``` 4. Run Chat Copilot locally. This step starts both the backend API and frontend application. - ```bash - ./Start.sh - ``` + ```bash + ./Start.sh + ``` - It may take a few minutes for Yarn packages to install on the first run. + It may take a few minutes for Yarn packages to install on the first run. - > NOTE: Confirm pop-ups are not blocked and you are logged in with the same account used to register the application. + > NOTE: Confirm pop-ups are not blocked and you are logged in with the same account used to register the application. ## (Optional) Enable backend authorization via Azure AD 1. Ensure you created the required application registration mentioned in [Start the WebApp FrontEnd application](#start-the-webapp-frontend-application) 2. Create a second application registration to represent the web api + > For more details on creating an application registration, go [here](https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app). 1. Give the app registration a name - 2. As *Supported account type* choose `Accounts in any organizational directory and personal Microsoft Accounts` + 2. As _Supported account type_ choose `Accounts in any organizational directory and personal Microsoft Accounts` - 3. Do not configure a *Redirect Uri* + 3. Do not configure a _Redirect Uri_ 3. Expose an API within the second app registration - 1. Select *Expose an API* from the menu - 2. Add an *Application ID URI* + 1. Select _Expose an API_ from the menu + + 2. Add an _Application ID URI_ + 1. This will generate an `api://` URI with a generated for you - 2. Click *Save* to store the generated URI + 2. Click _Save_ to store the generated URI 3. Add a scope for `access_as_user` - 1. Click *Add scope* - 2. Set *Scope name* to `access_as_user` + 1. Click _Add scope_ + + 2. Set _Scope name_ to `access_as_user` - 3. Set *Who can consent* to *Admins and users* + 3. Set _Who can consent_ to _Admins and users_ - 4. Set *Admin consent display name* and *User consent display name* to `Access copilot chat as a user` + 4. Set _Admin consent display name_ and _User consent display name_ to `Access copilot chat as a user` - 5. Set *Admin consent description* and *User consent description* to `Allows the accesses to the Copilot chat web API as a user` + 5. Set _Admin consent description_ and _User consent description_ to `Allows the accesses to the Copilot chat web API as a user` 4. Add permissions to web app frontend to access web api as user + 1. Open app registration for web app frontend - 2. Go to *API Permissions* + 2. Go to _API Permissions_ - 3. Click *Add a permission* + 3. Click _Add a permission_ - 4. Select the tab *My APIs* + 4. Select the tab _My APIs_ 5. Choose the app registration representing the web api backend 6. Select permissions `access_as_user` - 7. Click *Add permissions* + 7. Click _Add permissions_ 5. Update frontend web app configuration - 1. Open *.env* file + + 1. Open _.env_ file 2. Set the value of `REACT_APP_AAD_API_SCOPE` to your application ID URI followed by the scope `access_as_user`, e.g. `api://12341234-1234-1234-1234-123412341234/access_as_user` 6. Update backend web api configuration - 1. Open *appsettings.json* + + 1. Open _appsettings.json_ 2. Set the value of `Authorization:AzureAd:Audience` to your application ID URI # Troubleshooting -1. **_Issue:_** Unable to load chats. - - _Details_: interaction_in_progress: Interaction is currently in progress._ +1. **_Issue:_** Unable to load chats. + + _Details_: interaction*in_progress: Interaction is currently in progress.* - _Explanation_: The WebApp can display this error when the application is configured for a different AAD tenant from the browser, (e.g., personal/MSA account vs work/school account). + _Explanation_: The WebApp can display this error when the application is configured for a different AAD tenant from the browser, (e.g., personal/MSA account vs work/school account). - _Solution_: Either use a private/incognito browser tab or clear your browser credentials/cookies. Confirm you are logged in with the same account used to register the application. + _Solution_: Either use a private/incognito browser tab or clear your browser credentials/cookies. Confirm you are logged in with the same account used to register the application. 2. **_Issue:_**: Challenges using text completion models, such as `text-davinci-003` - _Solution_: For OpenAI, see [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) for - the complete list of current models supporting chat completions. For Azure OpenAI, see [model summary table and region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability). + _Solution_: For OpenAI, see [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) for + the complete list of current models supporting chat completions. For Azure OpenAI, see [model summary table and region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability). 3. **_Issue:_** Localhost SSL certificate errors / CORS errors - ![Cert-Issue](https://github.com/microsoft/chat-copilot/assets/64985898/e9072af1-e43c-472d-bebc-d0082d0c9180) + ![Cert-Issue](https://github.com/microsoft/chat-copilot/assets/64985898/e9072af1-e43c-472d-bebc-d0082d0c9180) - _Explanation_: Your browser may be blocking the frontend access to the backend while waiting for your permission to connect. + _Explanation_: Your browser may be blocking the frontend access to the backend while waiting for your permission to connect. - _Solution_: + _Solution_: - 1. Confirm the backend service is running. Open a web browser and navigate to `https://localhost:40443/healthz` - - You should see a confirmation message: `Healthy` - - If your browser asks you to acknowledge the risks of visiting an insecure website, you must acknowledge this before the frontend can connect to the backend server. - 2. Navigate to `http://localhost:3000` or refresh the page to use the Chat Copilot application. + 1. Confirm the backend service is running. Open a web browser and navigate to `https://localhost:40443/healthz` + - You should see a confirmation message: `Healthy` + - If your browser asks you to acknowledge the risks of visiting an insecure website, you must acknowledge this before the frontend can connect to the backend server. + 2. Navigate to `http://localhost:3000` or refresh the page to use the Chat Copilot application. 4. **_Issue:_** Yarn is not working. - _Explanation_: You may have the wrong Yarn version installed such as v2.x+. + _Explanation_: You may have the wrong Yarn version installed such as v2.x+. - _Solution_: Use the classic version. + _Solution_: Use the classic version. - ```bash - npm install -g yarn - yarn set version classic - ``` + ```bash + npm install -g yarn + yarn set version classic + ``` 5. **_Issue:_** Missing `/usr/share/dotnet/host/fxr` folder. - _Details_: "A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist" when running dotnet commands on Linux. + _Details_: "A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist" when running dotnet commands on Linux. - _Explanation_: When .NET (Core) was first released for Linux, it was not yet available in the official Ubuntu repo. So instead, many of us added the Microsoft APT repo in order to install it. Now, the packages are part of the Ubuntu repo, and they are conflicting with the Microsoft packages. This error is a result of mixed packages. ([Source: StackOverflow](https://stackoverflow.com/questions/73753672/a-fatal-error-occurred-the-folder-usr-share-dotnet-host-fxr-does-not-exist)) + _Explanation_: When .NET (Core) was first released for Linux, it was not yet available in the official Ubuntu repo. So instead, many of us added the Microsoft APT repo in order to install it. Now, the packages are part of the Ubuntu repo, and they are conflicting with the Microsoft packages. This error is a result of mixed packages. ([Source: StackOverflow](https://stackoverflow.com/questions/73753672/a-fatal-error-occurred-the-folder-usr-share-dotnet-host-fxr-does-not-exist)) - _Solution_: + _Solution_: - ```bash - # Remove all existing packages to get to a clean state: - sudo apt remove --assume-yes dotnet*; - sudo apt remove --assume-yes aspnetcore*; - sudo apt remove --assume-yes netstandard*; + ```bash + # Remove all existing packages to get to a clean state: + sudo apt remove --assume-yes dotnet*; + sudo apt remove --assume-yes aspnetcore*; + sudo apt remove --assume-yes netstandard*; - # Set the Microsoft package provider priority - echo -e "Package: *\nPin: origin \"packages.microsoft.com\"\nPin-Priority: 1001" | sudo tee /etc/apt/preferences.d/99microsoft-dotnet.pref; + # Set the Microsoft package provider priority + echo -e "Package: *\nPin: origin \"packages.microsoft.com\"\nPin-Priority: 1001" | sudo tee /etc/apt/preferences.d/99microsoft-dotnet.pref; - # Update and install dotnet - sudo apt update; - sudo apt install --assume-yes dotnet-sdk-7.0; - ``` + # Update and install dotnet + sudo apt update; + sudo apt install --assume-yes dotnet-sdk-7.0; + ``` diff --git a/scripts/README.md b/scripts/README.md index a13f13732..5f5e3eb19 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,2 +1,3 @@ # Chat Copilot setup scripts - Local deployment -To use these scripts, please follow the quick-start guide found [here](https://github.com/microsoft/chat-copilot/blob/main/README.md). + +To use these scripts, please follow the quick-start guide found [here](../README.md). diff --git a/webapi/Controllers/BotController.cs b/webapi/Controllers/BotController.cs index 7151766a6..58dff5ed7 100644 --- a/webapi/Controllers/BotController.cs +++ b/webapi/Controllers/BotController.cs @@ -6,6 +6,11 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using CopilotChat.WebApi.Extensions; +using CopilotChat.WebApi.Models.Response; +using CopilotChat.WebApi.Models.Storage; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Storage; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -14,11 +19,6 @@ using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Memory; -using CopilotChat.WebApi.Extensions; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Storage; -using CopilotChat.WebApi.Models.Storage; -using CopilotChat.WebApi.Models.Response; namespace CopilotChat.WebApi.Controllers; diff --git a/webapi/Controllers/ChatController.cs b/webapi/Controllers/ChatController.cs index 85e9e4769..d0e784022 100644 --- a/webapi/Controllers/ChatController.cs +++ b/webapi/Controllers/ChatController.cs @@ -9,6 +9,11 @@ using System.Text.Json; using System.Text.RegularExpressions; using System.Threading.Tasks; +using CopilotChat.WebApi.Hubs; +using CopilotChat.WebApi.Models.Request; +using CopilotChat.WebApi.Models.Response; +using CopilotChat.WebApi.Services; +using CopilotChat.WebApi.Skills.ChatSkills; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -24,11 +29,6 @@ using Microsoft.SemanticKernel.Skills.MsGraph.Connectors.Client; using Microsoft.SemanticKernel.Skills.OpenAPI.Authentication; using Microsoft.SemanticKernel.Skills.OpenAPI.Extensions; -using CopilotChat.WebApi.Hubs; -using CopilotChat.WebApi.Skills.ChatSkills; -using CopilotChat.WebApi.Models.Response; -using CopilotChat.WebApi.Models.Request; -using CopilotChat.WebApi.Services; namespace CopilotChat.WebApi.Controllers; diff --git a/webapi/Controllers/ChatHistoryController.cs b/webapi/Controllers/ChatHistoryController.cs index 73539dc7f..621704d1c 100644 --- a/webapi/Controllers/ChatHistoryController.cs +++ b/webapi/Controllers/ChatHistoryController.cs @@ -4,6 +4,13 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using CopilotChat.WebApi.Hubs; +using CopilotChat.WebApi.Models.Request; +using CopilotChat.WebApi.Models.Response; +using CopilotChat.WebApi.Models.Storage; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Skills; +using CopilotChat.WebApi.Storage; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -11,13 +18,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.SemanticKernel; -using CopilotChat.WebApi.Hubs; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Skills; -using CopilotChat.WebApi.Storage; -using CopilotChat.WebApi.Models.Storage; -using CopilotChat.WebApi.Models.Request; -using CopilotChat.WebApi.Models.Response; namespace CopilotChat.WebApi.Controllers; diff --git a/webapi/Controllers/ChatMemoryController.cs b/webapi/Controllers/ChatMemoryController.cs index 344a32e54..19337509a 100644 --- a/webapi/Controllers/ChatMemoryController.cs +++ b/webapi/Controllers/ChatMemoryController.cs @@ -3,6 +3,9 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Skills.ChatSkills; +using CopilotChat.WebApi.Storage; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -10,9 +13,6 @@ using Microsoft.Extensions.Options; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Memory; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Skills.ChatSkills; -using CopilotChat.WebApi.Storage; namespace CopilotChat.WebApi.Controllers; diff --git a/webapi/Controllers/ChatParticipantController.cs b/webapi/Controllers/ChatParticipantController.cs index ce9d20052..bb07bfad0 100644 --- a/webapi/Controllers/ChatParticipantController.cs +++ b/webapi/Controllers/ChatParticipantController.cs @@ -2,14 +2,14 @@ using System; using System.Threading.Tasks; +using CopilotChat.WebApi.Hubs; +using CopilotChat.WebApi.Models.Storage; +using CopilotChat.WebApi.Storage; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; -using CopilotChat.WebApi.Hubs; -using CopilotChat.WebApi.Storage; -using CopilotChat.WebApi.Models.Storage; namespace CopilotChat.WebApi.Controllers; diff --git a/webapi/Controllers/DocumentImportController.cs b/webapi/Controllers/DocumentImportController.cs index 916132713..ab92ffecd 100644 --- a/webapi/Controllers/DocumentImportController.cs +++ b/webapi/Controllers/DocumentImportController.cs @@ -6,6 +6,14 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using CopilotChat.WebApi.Hubs; +using CopilotChat.WebApi.Models.Request; +using CopilotChat.WebApi.Models.Response; +using CopilotChat.WebApi.Models.Storage; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Services; +using CopilotChat.WebApi.Skills; +using CopilotChat.WebApi.Storage; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -14,16 +22,8 @@ using Microsoft.Extensions.Options; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Text; -using CopilotChat.WebApi.Hubs; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Skills; -using CopilotChat.WebApi.Storage; -using CopilotChat.WebApi.Services; using UglyToad.PdfPig; using UglyToad.PdfPig.DocumentLayoutAnalysis.TextExtractor; -using CopilotChat.WebApi.Models.Request; -using CopilotChat.WebApi.Models.Storage; -using CopilotChat.WebApi.Models.Response; namespace CopilotChat.WebApi.Controllers; diff --git a/webapi/Controllers/SpeechTokenController.cs b/webapi/Controllers/SpeechTokenController.cs index b19c30f10..5d998653e 100644 --- a/webapi/Controllers/SpeechTokenController.cs +++ b/webapi/Controllers/SpeechTokenController.cs @@ -4,13 +4,13 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; +using CopilotChat.WebApi.Models.Response; +using CopilotChat.WebApi.Options; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Models.Response; namespace CopilotChat.WebApi.Controllers; diff --git a/webapi/Extensions/SemanticKernelExtensions.cs b/webapi/Extensions/SemanticKernelExtensions.cs index 1c1e32136..82fce1721 100644 --- a/webapi/Extensions/SemanticKernelExtensions.cs +++ b/webapi/Extensions/SemanticKernelExtensions.cs @@ -4,6 +4,10 @@ using System.IO; using System.Net.Http; using System.Threading.Tasks; +using CopilotChat.WebApi.Hubs; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Skills.ChatSkills; +using CopilotChat.WebApi.Storage; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -15,14 +19,10 @@ using Microsoft.SemanticKernel.Connectors.Memory.Chroma; using Microsoft.SemanticKernel.Connectors.Memory.Qdrant; using Microsoft.SemanticKernel.Memory; +using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.Skills.Core; using Microsoft.SemanticKernel.TemplateEngine; -using CopilotChat.WebApi.Hubs; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Skills.ChatSkills; -using CopilotChat.WebApi.Storage; using static CopilotChat.WebApi.Options.MemoriesStoreOptions; -using Microsoft.SemanticKernel.Orchestration; namespace CopilotChat.WebApi.Extensions; diff --git a/webapi/Extensions/ServiceExtensions.cs b/webapi/Extensions/ServiceExtensions.cs index 350fb913a..3e0f3fa09 100644 --- a/webapi/Extensions/ServiceExtensions.cs +++ b/webapi/Extensions/ServiceExtensions.cs @@ -5,18 +5,18 @@ using System.IO; using System.Reflection; using Azure; +using CopilotChat.WebApi.Auth; +using CopilotChat.WebApi.Models.Storage; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Services; +using CopilotChat.WebApi.Storage; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.Identity.Web; -using CopilotChat.WebApi.Auth; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Storage; -using CopilotChat.WebApi.Services; using Tesseract; -using CopilotChat.WebApi.Models.Storage; namespace CopilotChat.WebApi.Extensions; diff --git a/webapi/Models/Response/Bot.cs b/webapi/Models/Response/Bot.cs index b51338746..eaf5babd3 100644 --- a/webapi/Models/Response/Bot.cs +++ b/webapi/Models/Response/Bot.cs @@ -1,9 +1,9 @@ // Copyright (c) Microsoft. All rights reserved. using System.Collections.Generic; -using Microsoft.SemanticKernel.Memory; -using CopilotChat.WebApi.Options; using CopilotChat.WebApi.Models.Storage; +using CopilotChat.WebApi.Options; +using Microsoft.SemanticKernel.Memory; namespace CopilotChat.WebApi.Models.Response; diff --git a/webapi/Program.cs b/webapi/Program.cs index 9ecae88f0..ec419ff5d 100644 --- a/webapi/Program.cs +++ b/webapi/Program.cs @@ -3,6 +3,9 @@ using System; using System.Linq; using System.Threading.Tasks; +using CopilotChat.WebApi.Extensions; +using CopilotChat.WebApi.Hubs; +using CopilotChat.WebApi.Services; using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.AspNetCore.Builder; @@ -12,9 +15,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using CopilotChat.WebApi.Extensions; -using CopilotChat.WebApi.Hubs; -using CopilotChat.WebApi.Services; namespace CopilotChat.WebApi; diff --git a/webapi/Skills/ChatSkills/ChatSkill.cs b/webapi/Skills/ChatSkills/ChatSkill.cs index 749cb85a9..6d0f8729e 100644 --- a/webapi/Skills/ChatSkills/ChatSkill.cs +++ b/webapi/Skills/ChatSkills/ChatSkill.cs @@ -9,6 +9,12 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using CopilotChat.WebApi.Extensions; +using CopilotChat.WebApi.Hubs; +using CopilotChat.WebApi.Models.Response; +using CopilotChat.WebApi.Models.Storage; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Storage; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -18,12 +24,6 @@ using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.SkillDefinition; using Microsoft.SemanticKernel.TemplateEngine; -using CopilotChat.WebApi.Hubs; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Storage; -using CopilotChat.WebApi.Models.Storage; -using CopilotChat.WebApi.Models.Response; -using CopilotChat.WebApi.Extensions; namespace CopilotChat.WebApi.Skills.ChatSkills; diff --git a/webapi/Skills/ChatSkills/CopilotChatPlanner.cs b/webapi/Skills/ChatSkills/CopilotChatPlanner.cs index 45de1572d..17d8abf00 100644 --- a/webapi/Skills/ChatSkills/CopilotChatPlanner.cs +++ b/webapi/Skills/ChatSkills/CopilotChatPlanner.cs @@ -5,13 +5,13 @@ using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; +using CopilotChat.WebApi.Models.Response; +using CopilotChat.WebApi.Options; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Planning; using Microsoft.SemanticKernel.Planning.Sequential; using Microsoft.SemanticKernel.SkillDefinition; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Models.Response; namespace CopilotChat.WebApi.Skills.ChatSkills; @@ -45,7 +45,7 @@ public class CopilotChatPlanner /// Regex to match variable names from plan parameters. /// Valid variable names can contain letters, numbers, underscores, and dashes but can't start with a number. /// Matches: $variableName, $variable_name, $variable-name, $some_variable_Name, $variableName123, $variableName_123, $variableName-123 - /// Does not match: $123variableName, $100 $200 + /// Does not match: $123variableName, $100 $200 /// private const string VARIABLE_REGEX = @"\$([A-Za-z]+[_-]*[\w]+)"; @@ -92,7 +92,7 @@ public async Task CreatePlanAsync(string goal, ILogger logger) #region Private /// - /// Scrubs plan of functions not available in planner's kernel + /// Scrubs plan of functions not available in planner's kernel /// and flags any effected input dependencies with '$???' to prompt for user input. /// Proposed plan object to sanitize. /// The functions available in the planner's kernel. diff --git a/webapi/Skills/ChatSkills/DocumentMemorySkill.cs b/webapi/Skills/ChatSkills/DocumentMemorySkill.cs index d1832c447..2bf17fa55 100644 --- a/webapi/Skills/ChatSkills/DocumentMemorySkill.cs +++ b/webapi/Skills/ChatSkills/DocumentMemorySkill.cs @@ -4,12 +4,12 @@ using System.ComponentModel; using System.Linq; using System.Threading.Tasks; +using CopilotChat.WebApi.Options; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Memory; using Microsoft.SemanticKernel.SkillDefinition; -using CopilotChat.WebApi.Options; namespace CopilotChat.WebApi.Skills.ChatSkills; diff --git a/webapi/Skills/ChatSkills/ExternalInformationSkill.cs b/webapi/Skills/ChatSkills/ExternalInformationSkill.cs index 48020c2de..d08bfd3b0 100644 --- a/webapi/Skills/ChatSkills/ExternalInformationSkill.cs +++ b/webapi/Skills/ChatSkills/ExternalInformationSkill.cs @@ -9,16 +9,16 @@ using System.Text.Json.Nodes; using System.Text.RegularExpressions; using System.Threading.Tasks; +using CopilotChat.WebApi.Models.Response; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Skills.OpenApiPlugins.GitHubPlugin.Model; +using CopilotChat.WebApi.Skills.OpenApiPlugins.JiraPlugin.Model; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.Planning; using Microsoft.SemanticKernel.SkillDefinition; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Skills.OpenApiPlugins.GitHubPlugin.Model; -using CopilotChat.WebApi.Skills.OpenApiPlugins.JiraPlugin.Model; -using CopilotChat.WebApi.Models.Response; namespace CopilotChat.WebApi.Skills.ChatSkills; diff --git a/webapi/Skills/ChatSkills/SemanticChatMemoryExtractor.cs b/webapi/Skills/ChatSkills/SemanticChatMemoryExtractor.cs index 53319b2ff..ee0cc2c11 100644 --- a/webapi/Skills/ChatSkills/SemanticChatMemoryExtractor.cs +++ b/webapi/Skills/ChatSkills/SemanticChatMemoryExtractor.cs @@ -5,14 +5,14 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using CopilotChat.WebApi.Extensions; +using CopilotChat.WebApi.Options; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.AI.TextCompletion; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Memory; using Microsoft.SemanticKernel.Orchestration; -using CopilotChat.WebApi.Extensions; -using CopilotChat.WebApi.Options; namespace CopilotChat.WebApi.Skills.ChatSkills; diff --git a/webapi/Skills/ChatSkills/SemanticChatMemorySkill.cs b/webapi/Skills/ChatSkills/SemanticChatMemorySkill.cs index fa8bff8e7..25f5f43fa 100644 --- a/webapi/Skills/ChatSkills/SemanticChatMemorySkill.cs +++ b/webapi/Skills/ChatSkills/SemanticChatMemorySkill.cs @@ -5,14 +5,14 @@ using System.ComponentModel; using System.Linq; using System.Threading.Tasks; +using CopilotChat.WebApi.Models.Storage; +using CopilotChat.WebApi.Options; +using CopilotChat.WebApi.Storage; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Memory; using Microsoft.SemanticKernel.SkillDefinition; -using CopilotChat.WebApi.Options; -using CopilotChat.WebApi.Storage; -using CopilotChat.WebApi.Models.Storage; namespace CopilotChat.WebApi.Skills.ChatSkills; diff --git a/webapi/Skills/TokenUtilities.cs b/webapi/Skills/TokenUtilities.cs index 66dafeacd..52fff0478 100644 --- a/webapi/Skills/TokenUtilities.cs +++ b/webapi/Skills/TokenUtilities.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; -using Azure.AI.OpenAI; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk; using Microsoft.SemanticKernel.Connectors.AI.OpenAI.Tokenizers; diff --git a/webapp/package.json b/webapp/package.json index 44c26d734..221994b98 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -4,9 +4,10 @@ "version": "0.0.0", "type": "module", "scripts": { + "format": "prettier src --check", + "format:fix": "prettier src --write", "lint": "eslint src", "lint:fix": "eslint src --fix", - "prettify": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,scss,css,html,svg}\"", "serve": "serve -s build", "start": "react-scripts start", "build": "react-scripts build", diff --git a/webapp/src/components/chat/chat-list/ListItemActions.tsx b/webapp/src/components/chat/chat-list/ListItemActions.tsx index 438c9992d..48391dcbf 100644 --- a/webapp/src/components/chat/chat-list/ListItemActions.tsx +++ b/webapp/src/components/chat/chat-list/ListItemActions.tsx @@ -65,7 +65,9 @@ export const ListItemActions: React.FC = ({ chatId, chatN icon={} appearance="transparent" aria-label="Edit" - onClick={() => { setIsGettingInvitationId(true); }} + onClick={() => { + setIsGettingInvitationId(true); + }} /> {features[FeatureKeys.DeleteChats].enabled && } diff --git a/webapp/src/components/chat/controls/ShareBotMenu.tsx b/webapp/src/components/chat/controls/ShareBotMenu.tsx index 869b8eab7..3163dbe24 100644 --- a/webapp/src/components/chat/controls/ShareBotMenu.tsx +++ b/webapp/src/components/chat/controls/ShareBotMenu.tsx @@ -54,7 +54,9 @@ export const ShareBotMenu: FC = ({ chatId, chatTitle }) => { } - onClick={() => { setIsGettingInvitationId(true); }} + onClick={() => { + setIsGettingInvitationId(true); + }} disabled={!features[FeatureKeys.MultiUserChat].enabled} > Invite others to your Bot diff --git a/webapp/src/components/chat/invitation-dialog/InvitationCreateDialog.tsx b/webapp/src/components/chat/invitation-dialog/InvitationCreateDialog.tsx index b72807250..6c812ddbe 100644 --- a/webapp/src/components/chat/invitation-dialog/InvitationCreateDialog.tsx +++ b/webapp/src/components/chat/invitation-dialog/InvitationCreateDialog.tsx @@ -50,13 +50,20 @@ export const InvitationCreateDialog: React.FC = ({ Invite others to your Bot - + - - diff --git a/webapp/src/components/chat/invitation-dialog/InvitationJoinDialog.tsx b/webapp/src/components/chat/invitation-dialog/InvitationJoinDialog.tsx index 9a2acfc4a..bedca4e43 100644 --- a/webapp/src/components/chat/invitation-dialog/InvitationJoinDialog.tsx +++ b/webapp/src/components/chat/invitation-dialog/InvitationJoinDialog.tsx @@ -68,8 +68,12 @@ export const InvitationJoinDialog: React.FC = ({ onCl - - + + diff --git a/webapp/src/components/header/UserSettingsMenu.tsx b/webapp/src/components/header/UserSettingsMenu.tsx index 836765387..cf8d94d39 100644 --- a/webapp/src/components/header/UserSettingsMenu.tsx +++ b/webapp/src/components/header/UserSettingsMenu.tsx @@ -81,7 +81,12 @@ export const UserSettingsMenu: FC = ({ setLoadingState }) => avatar={{ color: 'colorful' }} /> - { setOpenSettingsDialog(true); }}> + { + setOpenSettingsDialog(true); + }} + > Settings @@ -90,7 +95,12 @@ export const UserSettingsMenu: FC = ({ setLoadingState }) => - { setOpenSettingsDialog(false); }} /> + { + setOpenSettingsDialog(false); + }} + /> ); }; diff --git a/webapp/src/components/header/settings-dialog/SettingSection.tsx b/webapp/src/components/header/settings-dialog/SettingSection.tsx index ecf1e5a3b..b34180472 100644 --- a/webapp/src/components/header/settings-dialog/SettingSection.tsx +++ b/webapp/src/components/header/settings-dialog/SettingSection.tsx @@ -53,7 +53,9 @@ export const SettingSection: React.FC = ({ setting, conte label={feature.label} checked={feature.enabled} disabled={feature.inactive} - onChange={() => { onFeatureChange(key); }} + onChange={() => { + onFeatureChange(key); + }} /> = ({ manifestDomainError, }) => { const classes = useClasses(); - const [input, setInput] = useState( manifestDomain ?? ''); + const [input, setInput] = useState(manifestDomain ?? ''); const keyStrokeTimeout = useRef(-1); diff --git a/webapp/src/components/shared/BundledIcons.tsx b/webapp/src/components/shared/BundledIcons.tsx index 81a90efb4..7a10d1f96 100644 --- a/webapp/src/components/shared/BundledIcons.tsx +++ b/webapp/src/components/shared/BundledIcons.tsx @@ -46,4 +46,4 @@ export const Filter20 = bundleIcon(Filter20Filled, Filter20Regular); export const Info16 = bundleIcon(Info16Filled, Info16Regular); export const Share20 = bundleIcon(Share20Filled, Share20Regular); export const ThumbLike16 = bundleIcon(ThumbLike16Filled, ThumbLike16Regular); -export const ThumbDislike16 = bundleIcon(ThumbDislike16Filled, ThumbDislike16Regular); \ No newline at end of file +export const ThumbDislike16 = bundleIcon(ThumbDislike16Filled, ThumbDislike16Regular); diff --git a/webapp/src/components/utils/PluginUtils.ts b/webapp/src/components/utils/PluginUtils.ts index 65dfcd636..94dc7ad1d 100644 --- a/webapp/src/components/utils/PluginUtils.ts +++ b/webapp/src/components/utils/PluginUtils.ts @@ -1,10 +1,10 @@ -import { +import { PluginManifest, PluginManifestKeys, isManifestAuthType, isHttpAuthorizationType, - requiresUserLevelAuth -} from "../../libs/models/PluginManifest"; + requiresUserLevelAuth, +} from '../../libs/models/PluginManifest'; export const isValidPluginManifest = (manifest: PluginManifest) => { const missingKeys: string[] = []; diff --git a/webapp/src/components/views/BackendProbe.tsx b/webapp/src/components/views/BackendProbe.tsx index 1a27f2018..a4eec1239 100644 --- a/webapp/src/components/views/BackendProbe.tsx +++ b/webapp/src/components/views/BackendProbe.tsx @@ -33,8 +33,8 @@ const BackendProbe: FC = ({ uri, onBackendFound }) => { Looking for your backend - This sample expects to find a Semantic Kernel service from{' '} - webapi/ running at {uri} + This sample expects to find a Semantic Kernel service from webapi/ running at{' '} + {uri} Run your Semantic Kernel service locally using Visual Studio, Visual Studio Code or by typing the diff --git a/webapp/src/components/views/Login.tsx b/webapp/src/components/views/Login.tsx index 5442b7491..33ffdd4a5 100644 --- a/webapp/src/components/views/Login.tsx +++ b/webapp/src/components/views/Login.tsx @@ -12,13 +12,19 @@ export const Login: React.FC = () => {
Login with your Microsoft Account - {'Don\'t have an account? Create one for free at'}{' '} + {"Don't have an account? Create one for free at"}{' '} https://account.microsoft.com/ -
diff --git a/webapp/src/components/views/MissingEnvVariablesError.tsx b/webapp/src/components/views/MissingEnvVariablesError.tsx index e1b4d42b4..bcdbe84e0 100644 --- a/webapp/src/components/views/MissingEnvVariablesError.tsx +++ b/webapp/src/components/views/MissingEnvVariablesError.tsx @@ -18,7 +18,9 @@ const MissingEnvVariablesError: FC = ({ missingVariables }) => {
- {'Please ensure your ".env" file is set up correctly with all environment variables defined in ".env.example" then restart the app.'} + { + 'Please ensure your ".env" file is set up correctly with all environment variables defined in ".env.example" then restart the app.' + } You are missing the following variables: {missingVariables.join(', ')}
diff --git a/webapp/src/index.css b/webapp/src/index.css index 95a9b18f5..5b4bd078e 100644 --- a/webapp/src/index.css +++ b/webapp/src/index.css @@ -19,9 +19,9 @@ body, } ::-webkit-scrollbar { - width: .4rem; + width: 0.4rem; } ::-webkit-scrollbar-thumb { border-radius: 12px; - visibility: 'hidden', -} \ No newline at end of file + visibility: 'hidden'; +} diff --git a/webapp/src/redux/features/conversations/ConversationsState.ts b/webapp/src/redux/features/conversations/ConversationsState.ts index 5aabffec2..60a90ca0d 100644 --- a/webapp/src/redux/features/conversations/ConversationsState.ts +++ b/webapp/src/redux/features/conversations/ConversationsState.ts @@ -33,4 +33,4 @@ export interface ConversationInputChange { export interface ConversationSystemDescriptionChange { id: string; newSystemDescription: string; -} \ No newline at end of file +}