diff --git a/.github/workflows/check-static-files.yml b/.github/workflows/check-static-files.yml index c45568ee85..0c688be28f 100644 --- a/.github/workflows/check-static-files.yml +++ b/.github/workflows/check-static-files.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - main + - AddQueryStringForInitialPrompting jobs: changed_files: diff --git a/.github/workflows/docker-image-build.yml b/.github/workflows/docker-image-build.yml index 44f852dbd7..eb7b7691f6 100644 --- a/.github/workflows/docker-image-build.yml +++ b/.github/workflows/docker-image-build.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - main + - AddQueryStringForInitialPrompting jobs: diff --git a/.github/workflows/docker-image-publish.yml b/.github/workflows/docker-image-publish.yml index 7a3ccdc1ba..4940b2c63e 100644 --- a/.github/workflows/docker-image-publish.yml +++ b/.github/workflows/docker-image-publish.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - AddQueryStringForInitialPrompting jobs: diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index c261c90580..cd949719bf 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -5,9 +5,9 @@ name: Build Frontend on: push: - branches: [ "main" ] + branches: [ "main", "AddQueryStringForInitialPrompting" ] pull_request: - branches: [ "main" ] + branches: [ "main", "AddQueryStringForInitialPrompting" ] jobs: @@ -29,6 +29,15 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' cache-dependency-path: '**/package-lock.json' - - run: npm ci + + + - name: Remove node_modules and package-lock.json + run: | + rm -rf node_modules + rm -f package-lock.json + + - name: Install dependencies and generate package-lock.json + run: npm install + - run: NODE_OPTIONS=--max_old_space_size=8192 npm run build --if-present - run: npm run test --if-present diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index 5895601d5d..0000000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,83 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python application - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - test_linux: - runs-on: - - ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.11 - uses: actions/setup-python@v3 - with: - python-version: "3.11" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt - - name: Test with pytest - env: - AZURE_OPENAI_ENDPOINT: ${{ secrets.AZUREOPENAIENDPOINT }} - AZURE_OPENAI_MODEL: ${{ secrets.AZUREOPENAIMODEL }} - AZURE_OPENAI_KEY: ${{ secrets.AZUREOPENAIKEY }} - AZURE_OPENAI_EMBEDDING_NAME: ${{ secrets.AZUREOPENAIEMBEDDINGNAME }} - AZURE_COSMOSDB_ACCOUNT: ${{ secrets.AZURECOSMOSDBACCOUNT }} - AZURE_COSMOSDB_DATABASE: ${{ secrets.AZURECOSMOSDBDATABASE }} - AZURE_COSMOSDB_CONVERSATIONS_CONTAINER: ${{ secrets.AZURECOSMOSDBCONVERSATIONSCONTAINER }} - AZURE_COSMOSDB_ACCOUNT_KEY: ${{ secrets.AZURECOSMOSDBACCOUNTKEY }} - AZURE_SEARCH_SERVICE: ${{ secrets.AZURESEARCHSERVICE }} - AZURE_SEARCH_INDEX: ${{ secrets.AZURESEARCHINDEX }} - AZURE_SEARCH_KEY: ${{ secrets.AZURESEARCHKEY }} - AZURE_SEARCH_QUERY: ${{ secrets.AZURESEARCHQUERY }} - ELASTICSEARCH_EMBEDDING_MODEL_ID: ${{ secrets.ELASTICSEARCHEMBEDDINGMODELID }} - ELASTICSEARCH_ENCODED_API_KEY: ${{ secrets.ELASTICSEARCHENCODEDAPIKEY }} - ELASTICSEARCH_ENDPOINT: ${{ secrets.ELASTICSEARCHENDPOINT }} - ELASTICSEARCH_INDEX: ${{ secrets.ELASTICSEARCHINDEX }} - ELASTICSEARCH_QUERY: ${{ secrets.ELASTICSEARCHQUERY }} - run: | - export PYTHONPATH=$(pwd) - coverage run -m pytest -v --show-capture=stdout - coverage report -m --include=app.py,backend/*,tests/* - coverage xml - - - name: Code Coverage Report - uses: irongut/CodeCoverageSummary@v1.3.0 - with: - filename: coverage.xml - badge: true - fail_below_min: true - format: markdown - hide_branch_rate: false - hide_complexity: true - indicators: true - output: both - thresholds: '50 80' - - test_windows: - runs-on: - - windows-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.11 - uses: actions/setup-python@v3 - with: - python-version: "3.11" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt - - name: Test with pytest - run: | - $env:PYTHONPATH=$pwd - pytest -v --show-capture=stdout -k "not integration" diff --git a/.github/workflows/sample-app-github-cd.yml b/.github/workflows/sample-app-github-cd.yml index 25c62ec876..863ef80083 100644 --- a/.github/workflows/sample-app-github-cd.yml +++ b/.github/workflows/sample-app-github-cd.yml @@ -8,6 +8,7 @@ on: push: branches: - main + - AddQueryStringForInitialPrompting workflow_dispatch: jobs: @@ -28,8 +29,7 @@ jobs: source venv/bin/activate - name: Install dependencies - run: pip install -r requirements.txt - + run: pip install -r requirements.txt # Optional: Add step to run tests here (PyTest, Django test suites, etc.) - name: Zip artifact for deployment @@ -46,6 +46,7 @@ jobs: deploy: runs-on: ubuntu-latest needs: build + environment: name: 'Production' url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} @@ -60,7 +61,6 @@ jobs: - name: Unzip artifact for deployment run: unzip release.zip - - name: Login to Azure uses: azure/login@v1 diff --git a/WebApp.Dockerfile b/WebApp.Dockerfile index d902410534..ab1a001871 100644 --- a/WebApp.Dockerfile +++ b/WebApp.Dockerfile @@ -4,10 +4,18 @@ RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app WORKDIR /home/node/app COPY ./frontend/package*.json ./ USER node -RUN npm ci + +# Remove node_modules and package-lock.json +RUN rm -rf node_modules && rm -f package-lock.json + +# Install dependencies and generate package-lock.json +RUN npm install + COPY --chown=node:node ./frontend/ ./frontend COPY --chown=node:node ./static/ ./static WORKDIR /home/node/app/frontend + +# Build the project RUN NODE_OPTIONS=--max_old_space_size=8192 npm run build FROM python:3.11-alpine diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 60a3b70dd2..ba1bb3bf39 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -19,6 +19,7 @@ "react-dom": "^18.2.0", "react-markdown": "^7.0.1", "react-plotly.js": "^2.6.0", + "react-query": "^3.0.0", "react-router-dom": "^6.8.1", "react-syntax-highlighter": "^15.5.0", "react-uuid": "^2.0.0", diff --git a/frontend/package.json b/frontend/package.json index adf63e3bc9..663a858cee 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -26,6 +26,7 @@ "react-dom": "^18.2.0", "react-markdown": "^7.0.1", "react-plotly.js": "^2.6.0", + "react-query": "^3.0.0", "react-router-dom": "^6.8.1", "react-syntax-highlighter": "^15.5.0", "react-uuid": "^2.0.0", diff --git a/frontend/src/pages/chat/Chat.tsx b/frontend/src/pages/chat/Chat.tsx index 2964882539..8a454c4bc0 100644 --- a/frontend/src/pages/chat/Chat.tsx +++ b/frontend/src/pages/chat/Chat.tsx @@ -1,6 +1,8 @@ import { useRef, useState, useEffect, useContext, useLayoutEffect } from 'react' import { CommandBarButton, IconButton, Dialog, DialogType, Stack } from '@fluentui/react' import { SquareRegular, ShieldLockRegular, ErrorCircleRegular } from '@fluentui/react-icons' +import { useLocation } from 'react-router-dom' +import { QueryClient, QueryClientProvider } from 'react-query' import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' @@ -45,6 +47,11 @@ const enum messageStatus { Done = 'Done' } +function useQueryParams() { + console.log("URL Params: ", useLocation().search); + return new URLSearchParams(useLocation().search); +} + const Chat = () => { const appStateContext = useContext(AppStateContext) const ui = appStateContext?.state.frontendSettings?.ui @@ -82,6 +89,26 @@ const Chat = () => { const [ASSISTANT, TOOL, ERROR] = ['assistant', 'tool', 'error'] const NO_CONTENT_ERROR = 'No content in messages object.' + const query = useQueryParams(); + const [dialogVisible, setDialogVisible] = useState(true); + const [queryParams, setQueryParams] = useState(""); + + useEffect(() => { + const params: string[] = []; + query.forEach((value, key) => { + params.push(`${key}: ${value}`); + console.log(`${key}: ${value}`); + }); + setQueryParams(params.join("\n")); + + console.log("Query Params: ", params); + console.log("Dialog Visible: ", dialogVisible); + }, [query]); + + const hideDialog = () => { + setDialogVisible(false); + }; + useEffect(() => { if ( appStateContext?.state.isCosmosDBAvailable?.status !== CosmosDBStatus.Working && @@ -739,285 +766,9 @@ const Chat = () => { ) } - return ( -
- {showAuthMessage ? ( - - -

Authentication Not Configured

-

- This app does not have authentication configured. Please add an identity provider by finding your app in the{' '} - - Azure Portal - - and following{' '} - - these instructions - - . -

-

- Authentication configuration takes a few minutes to apply. -

-

- If you deployed in the last 10 minutes, please wait and reload the page after 10 minutes. -

-
- ) : ( - -
- {!messages || messages.length < 1 ? ( - - -

{ui?.chat_title}

-

{ui?.chat_description}

-
- ) : ( -
- {messages.map((answer, index) => ( - <> - {answer.role === 'user' ? ( -
-
{answer.content}
-
- ) : answer.role === 'assistant' ? ( -
- onShowCitation(c)} - onExectResultClicked={() => onShowExecResult()} - /> -
- ) : answer.role === ERROR ? ( -
- - - Error - - {answer.content} -
- ) : null} - - ))} - {showLoadingMessage && ( - <> -
- null} - onExectResultClicked={() => null} - /> -
- - )} -
-
- )} - - - {isLoading && messages.length > 0 && ( - (e.key === 'Enter' || e.key === ' ' ? stopGenerating() : null)}> - - )} - - {appStateContext?.state.isCosmosDBAvailable?.status !== CosmosDBStatus.NotConfigured && ( - - )} - - - - { - appStateContext?.state.isCosmosDBAvailable?.cosmosDB - ? makeApiRequestWithCosmosDB(question, id) - : makeApiRequestWithoutCosmosDB(question, id) - }} - conversationId={ - appStateContext?.state.currentChat?.id ? appStateContext?.state.currentChat?.id : undefined - } - /> - -
- {/* Citation Panel */} - {messages && messages.length > 0 && isCitationPanelOpen && activeCitation && ( - - - - Citations - - setIsCitationPanelOpen(false)} - /> - -
onViewSource(activeCitation)}> - {activeCitation.title} -
-
- -
-
- )} - {messages && messages.length > 0 && isIntentsPanelOpen && ( - - - - Intents - - setIsIntentsPanelOpen(false)} - /> - - - {execResults.map((execResult) => { - return ( - - <>Intent:

{execResult.intent}

- {execResult.search_query && <>Search Query: - - {execResult.search_query} - } - {execResult.search_result && <>Search Result:

{execResult.search_result}

} - {execResult.code_generated && <>Code Generated: - - {execResult.code_generated} - - } -
- ) - })} -
-
- )} - {appStateContext?.state.isChatHistoryOpen && - appStateContext?.state.isCosmosDBAvailable?.status !== CosmosDBStatus.NotConfigured && } - - )} + return ( +
+ This is a test.
) } diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 4cddbe62bb..46ab1f1f10 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -15,7 +15,7 @@ "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", - "types": ["vite/client", "jest", "mocha"], + "types": ["vite/client", "jest", "mocha", "react-query"], "noUnusedLocals": false }, "include": ["src"],