MCPcopy
hub / github.com/microsoft/sample-app-aoai-chatGPT

github.com/microsoft/sample-app-aoai-chatGPT @main sqlite

repository ↗ · DeepWiki ↗
3,034 symbols 9,042 edges 55 files 30 documented · 1%
README

(Preview) Sample Chat App with AOAI

Deploying with the Azure Developer CLI

IMPORTANT: In order to deploy and run this example, you'll need an Azure subscription with access enabled for the Azure OpenAI service. You can request access here. You can also visit here to get some free Azure credits to get you started. Your Azure Account must have Microsoft.Authorization/roleAssignments/write permissions, such as User Access Administrator or Owner.

AZURE RESOURCE COSTS by default this sample will create Azure App Service and Azure Cognitive Search resources that have a monthly cost, as well as Form Recognizer resource that has cost per document page. You can switch them to free versions of each of them if you want to avoid this cost by changing the parameters file under the infra folder (though 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.)

Opening the project

This project has Dev Container support, so it will be be setup automatically if you open it in Github Codespaces or in local VS Code with the Dev Containers extension.

If you're not using one of those options for opening the project, then you'll need to:

  1. Install prerequisites:

    • Azure Developer CLI
    • Python 3+
      • Important: Python and the pip package manager must be in the path in Windows for the setup scripts to work.
    • Node.js
    • Git
    • Powershell 7+ (pwsh) - For Windows users only.
    • Important: Ensure you can run pwsh.exe from a PowerShell command. If this fails, you likely need to upgrade PowerShell.

Deploying from scratch:

If you don't have any pre-existing Azure services (i.e. OpenAI or Cognitive Search service), then you can provision all resources from scratch by following these steps:

  1. Run azd auth login to login to your Azure account.
  2. Run azd up to provision Azure resources and deploy this sample to those resources. This also runs a script to build the search index based on files in the ./data folder.
    • For the target location, the regions that currently support the models used in this sample are East US or South Central US. For an up-to-date list of regions and models, check here
  3. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser. > NOTE: It may take a minute for the application to be fully deployed. If you see a "Python Developer" welcome screen, then wait a minute and refresh the page.

Using existing resources:

If you have existing Azure resources that you want to reuse, then you must first set azd environment variables before running azd up.

Run the following commands based on what you want to customize:

  • azd env set AZURE_OPENAI_RESOURCE {Name of existing OpenAI service}
  • azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}
  • azd env set AZURE_OPENAI_SKU_NAME {Name of OpenAI SKU}. Defaults to 'S0'.
  • azd env set AZURE_SEARCH_SERVICE {Name of existing Cognitive Search service}
  • azd env set AZURE_SEARCH_SERVICE_RESOURCE_GROUP {Name of existing resource group that Cognitive Search service is provisioned to}
  • azd env set AZURE_SEARCH_SKU_NAME {Name of Cognitive Search SKY}. Defaults to 'standard'.
  • azd env set AZURE_FORMRECOGNIZER_SERVICE {Name of existing Form Recognizer service}. Used by prepdocs.py for text extraction from docs.
  • azd env set AZURE_FORMRECOGNIZER_SERVICE_RESOURCE_GROUP {Name of existing resource group that Form Recognizer service is provisioned to}.
  • azd env set AZURE_FORMRECOGNIZER_SKU_NAME {Name of Form Recognizer SKU}. Defaults to 'S0'.

If you have enabled Microsoft Defender for Cloud's threat protection for AI workloads on your Azure OpenAI resource and want to add user context to alerts, you can do so by using the azd commands below. If you haven't set up threat protection yet, please follow this guide: Microsoft Defender for Cloud documentation.

To add security context to your alerts, run the following command:

azd env set MS_DEFENDER_ENABLED true
  1. Run azd auth login to login to your Azure account.
  2. Run azd up to provision Azure resources and deploy this sample to those resources. This also runs a script to build the search index based on files in the ./data folder.
  3. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser. > NOTE: It may take a minute for the application to be fully deployed. If you see a "Python Developer" welcome screen, then wait a minute and refresh the page.

Re-deploying changes

If you make any changes to the app code (JS or Python), you can re-deploy the app code to App Service by running the azd deploy command.

If you change any of the Bicep files in the infra folder, then you should re-run azd up to both provision resources and deploy code.

Running locally:

  1. Run azd auth login
  2. Run ./start.cmd or ./start.sh to start the project locally.
  3. Navigate to http://127.0.0.1:5000 in your browser. The deployed code requires authentication, but the local app should allow access as long as it's access from 127.0.0.1.

Note

Note: The PDF documents used in this demo contain information generated using a language model (Azure OpenAI Service). The information contained in these documents is only for demonstration purposes and does not reflect the opinions or beliefs of Microsoft. Microsoft makes no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information contained in this document. All rights reserved to Microsoft.

Extension points exported contracts — how you extend this code

ChatHistoryListItemCellProps (Interface)
(no doc)
frontend/src/components/ChatHistory/ChatHistoryListItem.tsx
ChatHistoryListItemGroupsProps (Interface)
(no doc)
frontend/src/components/ChatHistory/ChatHistoryListItem.tsx
ChatHistoryListProps (Interface)
(no doc)
frontend/src/components/ChatHistory/ChatHistoryList.tsx
GroupedChatHistory (Interface)
(no doc)
frontend/src/components/ChatHistory/ChatHistoryList.tsx
ChatHistoryPanelProps (Interface)
(no doc)
frontend/src/components/ChatHistory/ChatHistoryPanel.tsx

Core symbols most depended-on inside this repo

push
called by 364
static/assets/index-8a2d939c.js
H
called by 241
static/assets/index-8a2d939c.js
consume
called by 224
static/assets/index-8a2d939c.js
replace
called by 214
static/assets/index-8a2d939c.js
n
called by 184
static/assets/index-8a2d939c.js
a
called by 128
static/assets/index-8a2d939c.js
_err
called by 115
static/assets/index-8a2d939c.js
r
called by 109
static/assets/index-8a2d939c.js

Shape

Function 2,615
Method 339
Class 50
Route 15
Interface 9
Enum 6

Languages

TypeScript92%
Python8%

Modules by API surface

static/assets/index-8a2d939c.js2,676 symbols
scripts/data_utils.py65 symbols
backend/settings.py56 symbols
app.py47 symbols
frontend/src/pages/chat/Chat.tsx20 symbols
frontend/src/components/ChatHistory/ChatHistoryListItem.tsx15 symbols
frontend/src/api/api.ts14 symbols
frontend/src/components/Answer/Answer.tsx13 symbols
backend/history/cosmosdbservice.py12 symbols
backend/utils.py11 symbols
tests/integration_tests/test_datasources.py10 symbols
scripts/data_preparation.py7 symbols

Dependencies from manifests, versioned

@eslint/eslintrc3.0.2 · 1×
@eslint/js9.1.1 · 1×
@fluentui/react8.109.0 · 1×
@fluentui/react-hooks8.6.29 · 1×
@fluentui/react-icons2.0.195 · 1×
@types/dompurify3.0.5 · 1×
@types/eslint-config-prettier6.11.3 · 1×
@types/jest29.5.12 · 1×
@types/lodash-es4.17.12 · 1×
@types/mocha10.0.6 · 1×
@types/node20.12.7 · 1×
@types/react18.0.27 · 1×

For agents

$ claude mcp add sample-app-aoai-chatGPT \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact