Skip to content

Commit

Permalink
upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
thivy committed Feb 4, 2024
1 parent 601086b commit 0113351
Show file tree
Hide file tree
Showing 310 changed files with 14,040 additions and 5,360 deletions.
64 changes: 0 additions & 64 deletions .devcontainer/devcontainer.json

This file was deleted.

23 changes: 14 additions & 9 deletions .github/workflows/open-ai-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:

steps:
- name: 🌱 Checkout to the branch
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 🍏 Set up Node.js version
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18.x"
node-version: "20.x"

- name: ⚙️ npm install and build
run: |
Expand All @@ -41,16 +41,16 @@ jobs:
- name: 📦 Package Next application
run: |
cd ./site-deploy
zip Nextjs-site.zip ./* .next -qr
zip Nextjs-site.zip ./* .next -qr
- name: 🔍 Diagnostics
run: |
ls ./src
ls ./src/.next
ls ./site-deploy
- name: ⬆️ Publish Next Application artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Nextjs-site
path: ./site-deploy/Nextjs-site.zip
Expand All @@ -59,11 +59,16 @@ jobs:
runs-on: ubuntu-latest
needs: build
environment:
name: "Production"
name: Production

steps:
- name: 🍏 Set up Node.js version
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: ⬇️ Download artifact from build job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Nextjs-site

Expand All @@ -72,7 +77,7 @@ jobs:
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Set the build during deployment setting to false. This setting was added in the templates to all azd to work, but breaks deployment via webapps-deploy
# Set the build during deployment setting to false. This setting was added in the templates to all azd to work, but breaks deployment via webapps-deploy
- name: Azure CLI script
uses: azure/CLI@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ next-env.d.ts

.azure/
infra/aad_setup.sh
.vscode
31 changes: 0 additions & 31 deletions .vscode/launch.json

This file was deleted.

22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
1. [Deploy to Azure with GitHub Actions](/docs/4-deploy-to-azure.md)
1. [Add identity provider](/docs/5-add-identity.md)
1. [Chatting with your file](/docs/6-chat-over-file.md)
1. [Environment variables](/docs/7-environment-variables.md)
1. [Persona](/docs/6-persona.md)
1. [Extensions](/docs/8-extensions.md)
1. [Environment variables](/docs/9-environment-variables.md)

# Introduction

_Azure Chat Solution Accelerator powered by Azure Open AI Service_

![](/images/intro.png)
![](/docs/images/intro.png)

_Azure Chat Solution Accelerator powered by Azure Open AI Service_ is a solution accelerator that allows organisations to deploy a private chat tenant in their Azure Subscription, with a familiar user experience and the added capabilities of chatting over your data and files.

Expand All @@ -38,25 +40,31 @@ You can deploy the application using one of the following options:

### 1. Azure Developer CLI

> **Important**
> [!IMPORTANT]
> This section will create Azure resources and deploy the solution from your local environment using the Azure Developer CLI. Note that you do not need to clone this repo to complete these steps.
1. Download the [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/overview)
1. If you have not cloned this repo, run `azd init -t microsoft/azurechat`. If you have cloned this repo, just run 'azd init' from the repo root directory.
1. Run `azd up` to provision and deploy the application

```pwsh
azd init -t microsoft/azurechat
azd up
# if you are wanting to see logs run with debug flag
azd up --debug
```

### 2. Azure Portal Deployment

> **Warning**
> [!WARNING]
> This button will only create Azure resources. You will still need to deploy the application by following the [deploy to Azure section](/docs/4-deploy-to-azure.md) to build and deploy the application using GitHub actions.
Click on the Deploy to Azure button to deploy the Azure resources for the application.

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://aka.ms/anzappazurechatgpt)

## Setup Authentication

> **Important**
> [!IMPORTANT]
> The application is protected by an identity provider and follow the steps in [Add an identity provider](/docs/5-add-identity.md) section for adding authentication to your app.
[Next](./docs/1-introduction.md)
Expand Down
4 changes: 2 additions & 2 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

name: azurechat
name: azure-chat
metadata:
template: azurechat@0.0.1
template: azure-chat@0.0.1
services:
frontend:
project: ./src
Expand Down
16 changes: 8 additions & 8 deletions docs/1-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Please make sure the following prerequisites are in place prior to deploying thi
2. Setup GitHub or Azure AD for Authentication:
The [add an identity provider](./5-add-identity.md) section below shows how to configure authentication providers.

> **Note**
> You can configure the authentication provider to your identity solution using [NextAuth providers](https://next-auth.js.org/providers/)
> [!NOTE]
> You can configure the authentication provider to your identity solution using [NextAuth providers](https://next-auth.js.org/providers/)
## 👋🏻 Introduction

Expand All @@ -20,7 +20,7 @@ _Azure Chat Solution Accelerator powered by Azure Open AI Service_ solution acce

- [NextAuth.js](https://next-auth.js.org/): configurable authentication framework for Next.js 13

- [ai sdk](https://sdk.vercel.ai/docs) Open-source library that simplifies building conversational UI on top Next.js and JavaScript
- [OpenAI sdk](https://github.com/openai/openai-node) NodeJS library that simplifies building conversational UI

- [Tailwind CSS](https://tailwindcss.com/): is a utility-first CSS framework that provides a series of predefined classes that can be used to style each element by mixing and matching

Expand All @@ -38,7 +38,7 @@ The following Azure services can be deployed to expand the feature set of your s

- [Azure Document Intelligence](https://learn.microsoft.com/en-GB/azure/ai-services/document-intelligence/) Microsoft Azure Form Recognizer is an automated data processing system that uses AI and OCR to quickly extract text and structure from documents. We use this service for extracting information from documents.

- [Azure Cognitive Search](https://learn.microsoft.com/en-GB/azure/search/) Azure Cognitive Search is an AI-powered platform as a service (PaaS) that helps developers build rich search experiences for applications. We use this service for indexing and retrieving information.
- [Azure AI Search ](https://learn.microsoft.com/en-GB/azure/search/) Azure AI Search is an AI-powered platform as a service (PaaS) that helps developers build rich search experiences for applications. We use this service for indexing and retrieving information.

- [Azure OpenAI Embeddings](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/embeddings?tabs=console) for embed content extracted from files.

Expand All @@ -48,7 +48,7 @@ The following Azure services can be deployed to expand the feature set of your s

The following high-level diagram depicts the architecture of the solution accelerator:

![Architecture diagram](/images/architecture.png)
![Architecture diagram](/docs/images/architecture.png)

# Azure Deployment Costs

Expand All @@ -58,13 +58,13 @@ However, you can try the [Azure pricing calculator - Sample Estimate](https://az
- Azure App Service: Premium V3 Tier 1 CPU core, 4 GB RAM, 250 GB Storage. Pricing per hour. [Pricing](https://azure.microsoft.com/pricing/details/app-service/linux/)
- Azure Open AI: Standard tier, ChatGPT and Embedding models. Pricing per 1K tokens used, and at least 1K tokens are used per question. [Pricing](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/)
- Form Recognizer: SO (Standard) tier using pre-built layout. Pricing per document page, sample documents have 261 pages total. [Pricing](https://azure.microsoft.com/pricing/details/form-recognizer/)
- Azure Cognitive Search: Standard tier, 1 replica, free level of semantic search. Pricing per hour.[Pricing](https://azure.microsoft.com/pricing/details/search/)
- Azure AI Search : Standard tier, 1 replica, free level of semantic search. Pricing per hour.[Pricing](https://azure.microsoft.com/pricing/details/search/)
- Azure Cosmos DB: Standard provisioned throughput with ZRS (Zone-redundant storage). Pricing per storage and read operations. [Pricing](https://azure.microsoft.com/en-us/pricing/details/cosmos-db/autoscale-provisioned/)
- Azure Monitor: Pay-as-you-go tier. Costs based on data ingested. [Pricing](https://azure.microsoft.com/pricing/details/monitor/)

To reduce costs, you can switch to free SKUs for Azure App Service, Azure Cognitive Search, and Form Recognizer by changing the parameters file under the `./infra` folder. There are some limits to consider; for example, you can have up to 1 free Cognitive Search resource per subscription, and the free Form Recognizer resource only analyzes the first 2 pages of each document. You can also reduce costs associated with the Form Recognizer by reducing the number of documents you upload.
To reduce costs, you can switch to free SKUs for Azure App Service, Azure AI Search , and Form Recognizer by changing the parameters file under the `./infra` folder. There are some limits to consider; for example, you can have up to 1 free Cognitive Search resource per subscription, and the free Form Recognizer resource only analyzes the first 2 pages of each document. You can also reduce costs associated with the Form Recognizer by reducing the number of documents you upload.

> **Warning**
> [!WARNING]
> To avoid unnecessary costs, remember to destroy your provisioned resources by deleting the resource group.
[Next](/docs/2-provision-azure-resources.md)
92 changes: 6 additions & 86 deletions docs/3-run-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,94 +11,14 @@ Clone this repository locally or fork to your Github account. Run all of the the
## Steps

1. Change directory to the `src` folder
2. Copy the file `.env.example` and rename it to `.env.local`.
3. Populate the environment variables in this file.
<details><summary>Environment Variables (ref src/.env.example)</summary>
```bash
# NOTES:
# - Do not use double-quotes and do not delete any of the variables.
# - Make sure that NEXTAUTH_URL=http://localhost:3000 has no comments in the same line.

# Update your Azure OpenAI details

# AZURE_OPENAI_API_INSTANCE_NAME should be just the name of azure openai resource and not the full url;

# AZURE_OPENAI_API_DEPLOYMENT_NAME should be deployment name from your azure openai studio and not the model name.

# AZURE_OPENAI_API_VERSION should be Supported versions checkout docs https://learn.microsoft.com/en-us/azure/ai-services/openai/reference

OPENAI_API_KEY=
AZURE_OPENAI_API_INSTANCE_NAME=
AZURE_OPENAI_API_DEPLOYMENT_NAME=
AZURE_OPENAI_API_VERSION=2023-03-15-preview
AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME=

# Update your admin email address

ADMIN_EMAIL_ADDRESS="[email protected],[email protected]"

# You must have atleast one of the following auth providers configured

AUTH_GITHUB_ID=
AUTH_GITHUB_SECRET=
AZURE_AD_CLIENT_ID=
AZURE_AD_CLIENT_SECRET=
AZURE_AD_TENANT_ID=

# Update your production URL in NEXTAUTH_URL

NEXTAUTH_SECRET=AZURE-OPENIAI-NEXTAUTH-OWNKEY@1
NEXTAUTH_URL=http://localhost:3000

# Update your Cosmos Environment details here

AZURE_COSMOSDB_URI=https://<cosmoresourcename>.documents.azure.com:443/
AZURE_COSMOSDB_KEY=

# Update your Cosmos DB_NAME and CONTAINER_NAME if you want to overwrite the default values

AZURE_COSMOSDB_DB_NAME=chat
AZURE_COSMOSDB_CONTAINER_NAME=history

# Azure cognitive search is used for chat over your data

AZURE_SEARCH_API_KEY=
AZURE_SEARCH_NAME=
AZURE_SEARCH_INDEX_NAME=
AZURE_SEARCH_API_VERSION="2023-07-01-Preview"

# Azure AI Document Intelligence to extract content from your data

AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT="https://REGION.api.cognitive.microsoft.com/"
AZURE_DOCUMENT_INTELLIGENCE_KEY=

# Azure Speech to Text to convert audio to text

# Enabled must be set to "true" any other value will disable the feature

PUBLIC_SPEECH_ENABLED=true
AZURE_SPEECH_REGION=<region, e.g. australiaeast>
AZURE_SPEECH_KEY=

```
</details>

```
4. Install npm packages by running `npm install`
5. Start the app by running `npm run dev`
6. Access the app on [http://localhost:3000](http://localhost:3000)
2. Rename the file `.env.example` to `.env.local` and populate the environment variables based on the deployed resources in Azure.
3. Install npm packages by running `npm install`
4. Start the app by running `npm run dev`
5. Access the app on [http://localhost:3000](http://localhost:3000)

You should now be prompted to login with your chosen OAuth provider.

> NOTE: If using Basic Auth (DEV ONLY) any username you enter will create a new user id (hash of username@localhost). You can use this to simulate multiple users.
![Chat Login (DEV)](/images/chat-login-dev.png)
Once successfully logged in, you can start creating new conversations.
![Chat Home](/images/chat-home.png)
![Chat history](/images/chat-history.png)
> [!NOTE]
> If using Basic Auth (DEV ONLY) any username you enter will create a new user id (hash of username@localhost). You can use this to simulate multiple users. Once successfully logged in, you can start creating new conversations.
[Next](/docs/4-deploy-to-azure.md)
2 changes: 1 addition & 1 deletion docs/4-deploy-to-azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ Under the same repository secrets add a new variable `AZURE_APP_SERVICE_NAME` to

Once the secrets are configured, the GitHub Actions will be triggered for every code push to the repository. Alternatively, you can manually run the workflow by clicking on the "Run Workflow" button in the Actions tab in GitHub.

![Workflow screenshot](/images/runworkflow.png)
![Workflow screenshot](/docs/images/runworkflow.png)

[Next](/docs/5-add-identity.md)
Loading

0 comments on commit 0113351

Please sign in to comment.