### Starting Development Server Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/README.md Scripts to start the local development server on Windows or Linux/Mac. Also mentions VS Code task for starting the app. ```powershell ./app/start.ps1 ``` ```shell ./app/start.sh ``` -------------------------------- ### Deployment Options Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/README.md Outlines the available methods for setting up the project, highlighting GitHub Codespaces as the easiest option due to automated tool setup, and mentioning local environment setup as an alternative. ```APIDOC Setup Options: 1. GitHub Codespaces: Recommended for ease of use and automated setup. 2. Local Environment: Manual setup required. See #local-environment for details. ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/CONTRIBUTING.md Installs pre-commit hooks to automatically format code and run linters before commits. ```shell pre-commit install ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/CONTRIBUTING.md Installs the necessary Python packages for development, including testing and linting tools. ```shell python -m pip install -r requirements-dev.txt ``` -------------------------------- ### Deploy Application with AZD Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/login_and_acl.md Provisions and deploys the application using the 'azd' CLI. This is the final step in the automatic setup process to get the application running. ```shell azd up ``` -------------------------------- ### Install Python for Windows Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/README.md Ensures Python and pip are installed and accessible in the system's PATH for Windows users. This is crucial for the setup scripts to function correctly. ```powershell # Ensure you can run `python --version` from console. # On Ubuntu, you might need to run `sudo apt install python-is-python3` to link `python` to `python3`. ``` -------------------------------- ### Install Playwright Browser Dependencies Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/CONTRIBUTING.md Installs the necessary browser binaries for Playwright to run end-to-end tests. ```shell playwright install --with-deps ``` -------------------------------- ### Azure Search OpenAI Demo - C# Backend Example Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt Provides a C# code example for the backend of the Azure Search OpenAI Demo. This might involve setting up controllers and services for search functionality. ```csharp using Azure.Search.Documents; using Azure.Search.Documents.Models; using System; using System.Collections.Generic; using System.Threading.Tasks; public class SearchService { private readonly SearchClient _searchClient; public SearchService(string endpoint, string apiKey) { _searchClient = new SearchClient(new Uri(endpoint), "your-index-name", new AzureKeyCredential(apiKey)); } public async Task> SearchAsync(string query) { var searchOptions = new SearchOptions { IncludeTotalCount = true }; var response = await _searchClient.SearchAsync(query, searchOptions); return response.Value.GetResults().ToList(); } } ``` -------------------------------- ### Setup Azure OpenAI and AI Search Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/index.html This snippet outlines the steps to set up the necessary Azure resources, including Azure OpenAI and Azure AI Search, and configure them for the demo. ```Bash # Install Azure CLI extensions # az extension add --name openai # az extension add --name search # Create Resource Group # az group create --name MyResourceGroup --location eastus # Create Azure OpenAI resource # az cognitiveservices account create --name MyOpenAIResource --resource-group MyResourceGroup --kind OpenAI --sku F0 --location eastus # Create Azure AI Search resource # az search service create --name mysearchservice --resource-group MyResourceGroup --location eastus --sku basic # Deploy an OpenAI model (e.g., text-davinci-003) # az cognitiveservices account deployment create --resource-group MyResourceGroup --account-name MyOpenAIResource --name MyModel --SkuCapacity 10 --SkuName TextDavinci003 # Get API keys and endpoints # az cognitiveservices account keys list --resource-group MyResourceGroup --account-name MyOpenAIResource # az search admin-key list --resource-group MyResourceGroup --service-name mysearchservice ``` -------------------------------- ### Azure Search OpenAI Demo - Setup and Configuration Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt This section provides guidance on setting up and configuring the Azure Search OpenAI Demo project. It covers essential steps for initialization and deployment. ```bash # Example setup command (replace with actual command) ./setup.sh --azure-search-key --openai-key ``` -------------------------------- ### App Service Hosting Guide Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/architecture.md Instructions for deploying the application using Azure App Service, a Platform-as-a-Service hosting option. ```APIDOC App Service Hosting Guide: - Provides detailed instructions for deploying the application on Azure App Service. - Refer to appservice.md for configuration and deployment steps. ``` -------------------------------- ### Start Development Server Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/localdev.md Commands to start the development server locally on Windows, Linux, or macOS. Assumes `azd up` has been run previously. ```powershell ./app/start.ps1 ``` ```shell ./app/start.sh ``` -------------------------------- ### Compile Frontend JavaScript Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/CONTRIBUTING.md Navigates to the frontend directory, installs Node.js dependencies, and builds the JavaScript assets. ```shell ( cd ./app/frontend ; npm install ; npm run build ) ``` -------------------------------- ### C# - Azure OpenAI Chat Completion Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt A C# example using the Azure OpenAI SDK to perform chat completions. It shows how to initialize the client and send a request to the API. ```csharp using Azure; using Azure.AI.OpenAI; using Azure.Identity; string azureOpenAIEndpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"); string azureOpenAIKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_KEY"); string deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME"); OpenAIClient client = new OpenAIClient(new Uri(azureOpenAIEndpoint), new AzureKeyCredential(azureOpenAIKey)); var chatCompletionsOptions = new ChatCompletionsOptions { DeploymentName = deploymentName, Messages = { new ChatRequestSystemMessage("You are a helpful assistant."), new ChatRequestUserMessage("What is Azure OpenAI?"), }, }; Response response = await client.GetChatCompletionsAsync(chatCompletionsOptions); Console.WriteLine(response.Value.Choices[0].Message.Content); ``` -------------------------------- ### Azure Search OpenAI Demo - C# Implementation Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt This provides a C# implementation for interacting with Azure Search and OpenAI, showcasing an alternative to the Python example for backend services or other .NET applications. ```csharp using Azure.Search.Documents; using OpenAI.Azure; using System; using System.Threading.Tasks; public class SearchService { private readonly SearchClient _searchClient; private readonly OpenAIClient _openaiClient; public SearchService(string searchEndpoint, string searchKey, string openaiApiKey) { _searchClient = new SearchClient(new Uri(searchEndpoint), "YOUR_INDEX_NAME", new AzureKeyCredential(searchKey)); _openaiClient = new OpenAIClient(new Uri("YOUR_OPENAI_ENDPOINT"), new AzureKeyCredential(openaiApiKey)); } public async Task AskQuestionAsync(string question) { // Similar logic to Python example for query generation and result processing // using Azure.Search.Documents.Models.SearchOptions and OpenAI SDK // Placeholder for actual implementation return "Answer from Azure Search OpenAI Demo"; } } ``` -------------------------------- ### Install PowerShell 7+ on Windows Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/README.md Verifies the installation and accessibility of PowerShell 7+ (pwsh.exe) on Windows systems. An upgrade might be necessary if the command fails. ```powershell # Ensure you can run `pwsh.exe` from a PowerShell terminal. # If this fails, you likely need to upgrade PowerShell. ``` -------------------------------- ### Azure Search OpenAI Demo - Core Functionality Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt This section outlines the fundamental components and workflows of the Azure Search OpenAI Demo project. It covers the setup and interaction between Azure Search and OpenAI for advanced search scenarios. ```python from azure.search.documents import SearchClient from openai import OpenAI # Initialize Azure Search Client search_client = SearchClient(endpoint="YOUR_SEARCH_ENDPOINT", credential=..., index_name="YOUR_INDEX_NAME") # Initialize OpenAI Client openai_client = OpenAI(api_key="YOUR_OPENAI_API_KEY") def ask_question(question): # Generate a search query using OpenAI response = openai_client.chat.completions.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant that translates natural language questions into Azure Search queries."}, {"role": "user", "content": f"Translate this question into an Azure Search query: {question}"} ] ) search_query = response.choices[0].message.content # Perform search using Azure Search search_results = search_client.search(search_text=search_query) # Process search results and generate an answer using OpenAI context = " ".join([result['content'] for result in search_results]) answer_response = openai_client.chat.completions.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant that answers questions based on the provided context."}, {"role": "user", "content": f"Context: {context}\nQuestion: {question}\nAnswer: "} ] ) return answer_response.choices[0].message.content # Example usage: # print(ask_question("What are the covered services for hearing care?")) ``` -------------------------------- ### PowerShell - Azure CLI for Azure OpenAI Deployment Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt A PowerShell script utilizing the Azure CLI to create an Azure OpenAI deployment. This is equivalent to the Bash example but for PowerShell environments. ```powershell az cognitiveservices account deployment create ` --name "my-deployment-ps` --resource-group "my-resource-group" ` --account-name "my-cognitive-services-account" ` --model-name "gpt-35-turbo" ` --model-version "0301" ` --sku-name "S1" ``` -------------------------------- ### Python Package Installation Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/appservice.md Lists all Python packages successfully installed for the Azure Search OpenAI Demo project. This includes core libraries for Azure services, AI, web frameworks, and utilities. ```python Successfully installed aiofiles-23.2.1 aiohttp-3.9.3 aiosignal-1.3.1 annotated-types-0.6.0 anyio-4.2.0 asgiref-3.7.2 attrs-23.2.0 azure-common-1.1.28 azure-core-1.29.7 azure-core-tracing-opentelemetry-1.0.0b11 azure-identity-1.15.0 azure-keyvault-secrets-4.7.0 azure-monitor-opentelemetry-1.2.0 azure-monitor-opentelemetry-exporter-1.0.0b21 azure-search-documents-11.6.0b1 azure-storage-blob-12.19.0 blinker-1.7.0 certifi-2023.11.17 cffi-1.16.0 charset-normalizer-3.3.2 click-8.1.7 cryptography-42.0.1 deprecated-1.2.14 distro-1.9.0 ecdsa-0.18.0 fixedint-0.1.6 flask-3.0.1 frozenlist-1.4.1 h11-0.14.0 h2-4.1.0 hpack-4.0.0 httpcore-1.0.2 httpx-0.26.0 hypercorn-0.16.0 hyperframe-6.0.1 idna-3.6 importlib-metadata-6.11.0 isodate-0.6.1 itsdangerous-2.1.2 jinja2-3.1.3 markupsafe-2.1.4 msal-1.26.0 msal-extensions-1.1.0 msrest-0.7.1 multidict-6.0.4 numpy-1.26.3 oauthlib-3.2.2 openai-1.10.0 opentelemetry-api-1.22.0 opentelemetry-instrumentation-0.43b0 opentelemetry-instrumentation-aiohttp-client-0.43b0 opentelemetry-instrumentation-asgi-0.43b0 opentelemetry-instrumentation-dbapi-0.43b0 opentelemetry-instrumentation-django-0.43b0 opentelemetry-instrumentation-fastapi-0.43b0 opentelemetry-instrumentation-flask-0.43b0 opentelemetry-instrumentation-httpx-0.43b0 opentelemetry-instrumentation-psycopg2-0.43b0 opentelemetry-instrumentation-requests-0.43b0 opentelemetry-instrumentation-urllib-0.43b0 opentelemetry-instrumentation-urllib3-0.43b0 opentelemetry-instrumentation-wsgi-0.43b0 opentelemetry-resource-detector-azure-0.1.3 opentelemetry-sdk-1.22.0 opentelemetry-semantic-conventions-0.43b0 opentelemetry-util-http-0.43b0 packaging-23.2 pandas-2.2.0 pandas-stubs-2.1.4.231227 pillow-10.2.0 portalocker-2.8.2 priority-2.0.0 pyasn1-0.5.1 pycparser-2.21 pydantic-2.6.0 pydantic-core-2.16.1 pyjwt-2.8.0 python-dateutil-2.8.2 python-jose-3.3.0 pytz-2023.4 quart-0.19.4 quart-cors-0.7.0 regex-2023.12.25 requests-2.31.0 requests-oauthlib-1.3.1 rsa-4.9 six-1.16.0 sniffio-1.3.0 tenacity-8.2.3 tiktoken-0.5.2 tqdm-4.66.1 types-pillow-10.2.0.20240206 types-pytz-2023.4.0.20240130 typing-extensions-4.9.0 tzdata-2023.4 urllib3-2.1.0 uvicorn-0.27.0.post1 werkzeug-3.0.1 wrapt-1.16.0 wsproto-1.2.0 yarl-1.9.4 zipp-3.17.0 ``` -------------------------------- ### Dependency Installation Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/appservice.md This snippet shows the process of downloading and installing various Python packages required for the project. It includes libraries like numpy, oauthlib, openai, and several opentelemetry instrumentation packages. ```python Collecting numpy-1.26.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB) Downloading oauthlib-3.2.2-py3-none-any.whl (151 kB) Collecting openai[datalib]==1.10.0 Downloading openai-1.10.0-py3-none-any.whl.metadata (18 kB) Collecting opentelemetry-api==1.22.0 Downloading opentelemetry_api-1.22.0-py3-none-any.whl.metadata (1.4 kB) Collecting opentelemetry-instrumentation==0.43b0 Downloading opentelemetry_instrumentation-0.43b0-py3-none-any.whl.metadata (5.9 kB) Collecting opentelemetry-instrumentation-aiohttp-client==0.43b0 Downloading opentelemetry_instrumentation_aiohttp_client-0.43b0-py3-none-any.whl.metadata (2.2 kB) Collecting opentelemetry-instrumentation-asgi==0.43b0 Downloading opentelemetry_instrumentation_asgi-0.43b0-py3-none-any.whl.metadata (2.1 kB) Collecting opentelemetry-instrumentation-dbapi==0.43b0 Downloading opentelemetry_instrumentation_dbapi-0.43b0-py3-none-any.whl.metadata (1.9 kB) Collecting opentelemetry-instrumentation-django==0.43b0 Downloading opentelemetry_instrumentation_django-0.43b0-py3-none-any.whl.metadata (2.3 kB) Collecting opentelemetry-instrumentation-fastapi==0.43b0 Downloading opentelemetry_instrumentation_fastapi-0.43b0-py3-none-any.whl.metadata (2.3 kB) Collecting opentelemetry-instrumentation-flask==0.43b0 Downloading opentelemetry_instrumentation_flask-0.43b0-py3-none-any.whl.metadata (2.4 kB) Collecting opentelemetry-instrumentation-httpx==0.43b0 ``` -------------------------------- ### Alternative RAG Chat Samples by Language Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/other_samples.md Links to RAG chat samples implemented in different programming languages. These samples serve as starting points for building RAG chat applications and may not support all features of the primary repository. ```text * [**JavaScript**](https://aka.ms/azai/js/code) * [**.NET**](https://aka.ms/azai/net/code) * [**Java**](https://aka.ms/azai/java/code) ``` -------------------------------- ### Azure Account Permissions Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/README.md Details the required Azure account permissions for deploying and running the demo. This includes specific role assignments and resource deployment permissions necessary for successful setup. ```APIDOC Required Permissions: - Microsoft.Authorization/roleAssignments/write (e.g., Role Based Access Control Administrator, User Access Administrator, Owner) - Microsoft.Resources/deployments/write (Subscription level) Notes: - If lacking subscription-level permissions, RBAC must be granted for an existing resource group. - Refer to deployment guides for deploying to existing resource groups or with specific RBAC roles. ``` -------------------------------- ### Azure Search OpenAI Demo - Python API Usage Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt Demonstrates how to interact with the Azure Search OpenAI Demo using Python. This includes examples of querying the search index and processing results. ```python from azure_search_openai_demo import SearchClient client = SearchClient(azure_search_key='YOUR_SEARCH_KEY', openai_key='YOUR_OPENAI_KEY') results = client.search(query='What are the covered allergy services?') for result in results: print(result['content']) ``` -------------------------------- ### JavaScript - Azure OpenAI Chat Completion Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt A JavaScript example using the OpenAI SDK to call the Azure OpenAI Chat Completion API. It demonstrates how to configure the client and send a chat message. ```javascript import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: process.env.AZURE_OPENAI_KEY, baseURL: `${process.env.AZURE_OPENAI_ENDPOINT}/openai/deployments/${process.env.AZURE_OPENAI_DEPLOYMENT_NAME}`, defaultHeaders: { 'api-key': process.env.AZURE_OPENAI_KEY, }, }); async function main() { const completion = await openai.chat.completions.create({ model: process.env.AZURE_OPENAI_DEPLOYMENT_NAME, // Not needed for Azure messages: [ { role: 'system', content: 'You are a helpful assistant.' }, { role: 'user', content: 'What is Azure OpenAI?' }, ], }); console.log(completion.choices[0].message.content); } main(); ``` -------------------------------- ### Azure OpenAI API Reference Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt This section provides documentation for interacting with the Azure OpenAI API. It covers common operations such as text generation and embeddings, including request parameters, response formats, and usage examples. ```APIDOC AzureOpenAI: Completions: endpoint: "https://YOUR_AZURE_OPENAI_ENDPOINT/openai/deployments/YOUR_DEPLOYMENT_NAME/completions?api-version=2022-12-01" method: POST headers: Content-Type: "application/json" api-key: "YOUR_AZURE_OPENAI_API_KEY" body: prompt: "string (required) - The prompt to generate text from." max_tokens: "integer (optional) - The maximum number of tokens to generate." temperature: "number (optional) - Controls randomness. Lower values make output more focused and deterministic." response: choices: [ { text: "string - The generated text." } ] Embeddings: endpoint: "https://YOUR_AZURE_OPENAI_ENDPOINT/openai/deployments/YOUR_EMBEDDING_DEPLOYMENT_NAME/embeddings?api-version=2022-12-01" method: POST headers: Content-Type: "application/json" api-key: "YOUR_AZURE_OPENAI_API_KEY" body: input: "string | list[string] (required) - The input text(s) to generate embeddings for." response: data: [ { embedding: "list[number] - The generated embedding vector." } ] Example Usage (Completions): POST https://YOUR_AZURE_OPENAI_ENDPOINT/openai/deployments/YOUR_DEPLOYMENT_NAME/completions?api-version=2022-12-01 Content-Type: application/json api-key: YOUR_AZURE_OPENAI_API_KEY { "prompt": "Translate the following English text to French: 'Hello, world!'", "max_tokens": 50, "temperature": 0.7 } Example Usage (Embeddings): POST https://YOUR_AZURE_OPENAI_ENDPOINT/openai/deployments/YOUR_EMBEDDING_DEPLOYMENT_NAME/embeddings?api-version=2022-12-01 Content-Type: application/json api-key: YOUR_AZURE_OPENAI_API_KEY { "input": "This is a sample document for embedding." } ``` -------------------------------- ### Python - Azure OpenAI Chat Completion Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt A Python script to interact with the Azure OpenAI Chat Completion API. It sets up the client with necessary credentials and sends a message to get a response. ```python import os from openai import AzureOpenAI client = AzureOpenAI( api_key=os.environ.get("AZURE_OPENAI_KEY"), api_version="2023-05-15", azure_endpoint=os.environ.get("AZURE_OPENAI_ENDPOINT"), azure_deployment=os.environ.get("AZURE_OPENAI_DEPLOYMENT_NAME") ) response = client.chat.completions.create( model=os.environ.get("AZURE_OPENAI_DEPLOYMENT_NAME"), messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is Azure OpenAI?"} ] ) print(response.choices[0].message.content) ``` -------------------------------- ### How to Submit an Appeal to Northwind Health Plus Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/tests/snapshots/test_prepdocslib_textsplitter/test_sentencetextsplitter_list_parse_and_split/text_splitter_sections.txt Explains what an appeal is in the context of Northwind Health Plus and provides a step-by-step guide on how to submit one. It emphasizes gathering supporting information as the crucial first step. ```English What Is an Appeal? An appeal is a formal request to reconsider a decision or action taken by Northwind Health Plus. This includes decisions on coverage and payment of services, supplies, or drugs. You or your healthcare provider can submit an appeal to Northwind Health Plus. In order to submit an appeal, you must provide information that supports your appeal. How to Submit an Appeal If you disagree with a coverage determination or payment made by Northwind Health Plus, you can appeal the decision. Here are the steps you need to take to submit an appeal: Step 1: Gather Information The first step in submitting an appeal is to gather the information you need. This includes any documents that support your appeal, such as receipts, doctors' notes, and lab test results. ``` -------------------------------- ### Setup Evaluation Environment Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/evaluation.md Configures a dedicated Python virtual environment for the evaluation scripts due to potential dependency conflicts with the main project. It involves creating the environment, activating it, and installing necessary dependencies from a requirements file. ```bash python -m venv .evalenv source .evalenv/bin/activate pip install -r evals/requirements.txt ``` -------------------------------- ### Initialize Azure Search OpenAI Demo Project Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/README.md Initializes the Azure Search OpenAI Demo project by downloading the code using the Azure Developer CLI. This command also sets up a local git repository. ```shell azd init -t azure-search-openai-demo ``` -------------------------------- ### Oryx Build Logs Analysis Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/appservice.md Detailed logs from an Oryx build process for a Python application deployed to Azure App Service. This output shows the steps taken by Oryx, including platform detection, environment setup, and package installation, which can help in diagnosing build failures. ```plaintext Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.11 -p virtualenv_name=antenv --log-file /tmp/build-debug.log -i /tmp/8dc28dad0e10acb --compress-destination-dir | tee /tmp/oryx-build.log Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx You can report issues at https://github.com/Microsoft/Oryx/issues Oryx Version: 0.2.20230508.1, Commit: 7fe2bf39b357dd68572b438a85ca50b5ecfb4592, ReleaseTagName: 20230508.1 Build Operation ID: 7440a33100749a32 Repository Commit : b09bff8b-da36-4d70-9e2f-c7b9131d85bc OS Type : bullseye Image Type : githubactions Detecting platforms... Detected following platforms: python: 3.11.7 Version '3.11.7' of platform 'python' is not installed. Generating script to install it... Using intermediate directory '/tmp/8dc28dad0e10acb'. Copying files to the intermediate directory... Done in 27 sec(s). Source directory : /tmp/8dc28dad0e10acb Destination directory: /home/site/wwwroot Downloading and extracting 'python' version '3.11.7' to '/tmp/oryx/platforms/python/3.11.7'... Detected image debian flavor: bullseye. Downloaded in 5 sec(s). Verifying checksum... Extracting contents... performing sha512 checksum for: python... Done in 48 sec(s). image detector file exists, platform is python.. OS detector file exists, OS is bullseye.. Python Version: /tmp/oryx/platforms/python/3.11.7/bin/python3.11 Creating directory for command manifest file if it does not exist Removing existing manifest file Python Virtual Environment: antenv Creating virtual environment... Activating virtual environment... Running pip install... [19:21:31+0000] Collecting aiofiles==23.2.1 (from -r requirements.txt (line 7)) [19:21:31+0000] Obtaining dependency information for aiofiles==23.2.1 from https://files.pythonhosted.org/packages/c5/19/5af6804c4cc0fed83f47bff6e413a98a36618e7d40185cd36e69737f3b0e/aiofiles-23.2.1-py3-none-any.whl.metadata [19:21:31+0000] Downloading aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB) [19:21:35+0000] Collecting aiohttp==3.9.3 (from -r requirements.txt (line 9)) [19:21:35+0000] Obtaining dependency information for aiohttp==3.9.3 from https://files.pythonhosted.org/packages/84/bb/74c9f32e1a76fab04b54ed6cd4b0dc4a07bd9dc6f3bb37f630149a9c3068/aiohttp-3.9.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata [19:21:35+0000] Downloading aiohttp-3.9.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.4 kB) [19:21:35+0000] Collecting aiosignal==1.3.1 (from -r requirements.txt (line 11)) [19:21:35+0000] Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB) [19:21:36+0000] Collecting annotated-types==0.6.0 (from -r requirements.txt (line 13)) [19:21:36+0000] Obtaining dependency information for annotated-types==0.6.0 from https://files.pythonhosted.org/packages/28/78/d31230046e58c207284c6b2c4e8d96e6d3cb4e52354721b944d3e1ee4aa5/annotated_types-0.6.0-py3-none-any.whl.metadata [19:21:36+0000] Downloading annotated_types-0.6.0-py3-none-any.whl.metadata (12 kB) [19:21:36+0000] Collecting anyio==4.2.0 (from -r requirements.txt (line 15)) [19:21:36+0000] Obtaining dependency information for anyio==4.2.0 from https://files.pythonhosted.org/packages/bf/cd/d6d9bb1dadf73e7af02d18225cbd2c93f8552e13130484f1c8dcfece292b/anyio-4.2.0-py3-none-any.whl.metadata [19:21:36+0000] Downloading anyio-4.2.0-py3-none-any.whl.metadata (4.6 kB) [19:21:36+0000] Collecting asgiref==3.7.2 (from -r requirements.txt (line 19)) ``` -------------------------------- ### User Query Example Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/http_protocol.md An example of a user asking a question about their healthcare plan. ```json { "role": "user", "content": "What is included in my Northwind Health Plus plan that is not in standard?" } ``` -------------------------------- ### Initialize Azure Search OpenAI Demo Project Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/sharing_environments.md Initializes the Azure Search OpenAI Demo project using Azure Developer CLI. This command clones the repository and sets up the project structure. ```azurecli azd init -t azure-search-openai-demo ``` -------------------------------- ### Oryx Build Process - Pip Install Confirmation Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/appservice.md Indicates that Oryx is running the pip install command, which is expected to install all dependencies listed in the requirements.txt file. The presence of this message suggests the build is proceeding as planned. ```text _Running pip install..._ ``` -------------------------------- ### Assistant Response Example Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/http_protocol.md An example of the AI assistant's response to a user query, including a citation. ```json { "role": "assistant", "content": "There is no specific information provided about what is included in the Northwind Health Plus plan that is not in the standard plan. It is recommended to read the plan details carefully and ask questions to understand the specific benefits of the Northwind Health Plus plan [Northwind_Standard_Benefits_Details.pdf#page=91]." } ``` -------------------------------- ### Install Locust Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/productionizing.md Installs the locust package in your Python environment, which is used for load testing the chat application. ```shell python -m pip install locust ``` -------------------------------- ### Use OpenAI.com Account Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/deploy_freetrial.md Configures the application to use an existing OpenAI.com account instead of Azure OpenAI. This requires setting the OPENAI_HOST, OPENAI_ORGANIZATION, and OPENAI_API_KEY environment variables. ```shell azd env set OPENAI_HOST openai azd env set OPENAI_ORGANIZATION {Your OpenAI organization} azd env set OPENAI_API_KEY {Your OpenAI API key} ``` -------------------------------- ### Login to Azure Account Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/deploy_lowcost.md Logs the user into their Azure account using the Azure Developer CLI. ```shell azd auth login ``` -------------------------------- ### Provision and Deploy Resources Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/azure_app_service.md Provisions necessary Azure resources and deploys the RAG chat sample code. This command also builds the search index using files from the './data' folder. It warns about immediate costs associated with created resources, particularly the AI Search resource. ```bash azd up ``` -------------------------------- ### Comparison of RAG Chat Repositories Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/other_samples.md Compares the 'azure-search-openai-demo' repository with another popular repository ('sample-app-aoai-chatGPT') for RAG chat use cases. It details differences in RAG approaches, feature support, and technology stacks. ```markdown Feature comparison: | Feature | azure-search-openai-demo | sample-app-aoai-chatGPT | | --- | --- | --- | | RAG approach | Multiple approaches | Only via ChatCompletion API data_sources | | Vector support | ✅ Yes | ✅ Yes | | Data ingestion | ✅ Yes ([Many formats](data_ingestion.md#supported-document-formats)) | ✅ Yes ([Many formats](https://learn.microsoft.com/azure/ai-services/openai/concepts/use-your-data?tabs=ai-search#data-formats-and-file-types)) | | Persistent chat history | ✅ Yes | ✅ Yes | | User feedback | ❌ No | ✅ Yes | | GPT-4-vision | ✅ Yes | ❌ No | | Auth + ACL | ✅ Yes | ✅ Yes | | User upload | ✅ Yes | ❌ No | | Speech I/O | ✅ Yes | ❌ No | Technology comparison: | Tech | azure-search-openai-demo | sample-app-aoai-chatGPT | | --- | --- | --- | | Frontend | React | React | | Backend | Python (Quart) | Python (Quart) | | Vector DB | Azure AI Search | Azure AI Search, CosmosDB Mongo vCore, ElasticSearch, Pinecone, AzureML | | Deployment | Azure Developer CLI (azd) | Azure Portal, az, azd | ``` -------------------------------- ### Example Streaming Response Chunks Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/http_protocol.md Provides an example of the first three JSON objects in a streaming response, illustrating the 'delta' and 'context' properties with sample data. ```json { "delta": { "role": "assistant" }, "context": { "data_points": { "text": [ "Benefit_Options.pdf#page=3: The plans also cover preventive care services such as mammograms, colonoscopies, and other cancer screenings...(truncated)", "Benefit_Options.pdf#page=3: Both plans offer coverage for medical services. Northwind Health Plus offers coverage for hospital stays, doctor visits,...(truncated)", "Benefit_Options.pdf#page=3: With Northwind Health Plus, you can choose from a variety of in -network providers, including primary care physicians,...(truncated)" ] }, "thoughts": [ { "title": "Original user query", "description": "What is included in my Northwind Health Plus plan that is not in standard?", "props": null }, { "title": "Generated search query", "description": "Northwind Health Plus plan standard", "props": { "use_semantic_captions": false, "has_vector": false } }, { "title": "Results", "description": [ { "id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": " The plans also cover preventive care services such as mammograms, colonoscopies, and \nother cancer screenings...(truncated)", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options.pdf#page=3", "sourcefile": "Benefit_Options.pdf", "oids": [], "groups": [], "captions": [] }, { "id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-3", "content": " \nBoth plans offer coverage for medical services. Northwind Health Plus offers coverage for hospital stays, \ndoctor visits,...(truncated)", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options.pdf#page=3", "sourcefile": "Benefit_Options.pdf", "oids": [], "groups": [], "captions": [] }, { "id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-1", "content": " With Northwind Health Plus, you can choose \nfrom a variety of in -network providers, including primary care physicians,...(truncated)", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options.pdf#page=3", "sourcefile": "Benefit_Options.pdf", "oids": [], "groups": [], "captions": [] } ], "props": null }, { "title": "Prompt", "description": [ ``` -------------------------------- ### RAG Chat Request Body Example Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/http_protocol.md An example of a valid JSON request body sent to the RAG chat application's endpoints, demonstrating the 'messages' structure for a user query. ```json { "messages": [ { "content": "What is included in my Northwind Health Plus plan that is not in standard?", "role": "user" } ], "context": {}, "session_state": null } ``` -------------------------------- ### RAG Chat Request Context Overrides Example Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/http_protocol.md An example JSON object illustrating the 'overrides' property within the 'context' for customizing RAG chat application behavior, including search parameters and LLM settings. ```json "overrides": { "top": 3, "retrieval_mode": "text", "semantic_ranker": false, "semantic_captions": false, "suggest_followup_questions": false, "use_oid_security_filter": false, "use_groups_security_filter": false, "vector_fields": ["embedding"], "use_gpt4v": false, "gpt4v_input": "textAndImages" } ``` -------------------------------- ### Clean and Deploy Application Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/gpt4v.md This snippet demonstrates commands for managing Azure application deployments using the Azure Developer CLI (`azd`). It includes an optional command to clean old deployments and the command to build, provision, deploy, and initiate document preparation. ```shell azd down --purge azd up ``` -------------------------------- ### System Process Utilities Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/requirements.txt This snippet includes the 'psutil' library, which allows retrieval of information on running processes and system utilization. ```python psutil==5.9.8 ``` -------------------------------- ### Run prepdocs script Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/login_and_acl.md Executes the `prepdocs.py` script to process PDFs in Azure Data Lake Storage Gen2. Requires specific environment variables to be set beforehand. ```bash #!/bin/bash # Set environment variables before running # export AZURE_ADLS_GEN2_STORAGE_ACCOUNT="your_storage_account_name" # export AZURE_ADLS_GEN2_FILESYSTEM="your_filesystem_name" # export AZURE_ADLS_GEN2_FILESYSTEM_PATH="your_path" /scripts/prepdocs.sh ``` -------------------------------- ### Answer Formatting with Citation Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/http_protocol.md An example of how an answer should be formatted to include source citations using square brackets. ```text There is no specific information provided about what is included in the Northwind Health Plus plan that is not in the standard plan. It is recommended to read the plan details carefully and ask questions to understand the specific benefits of the Northwind Health Plus plan [Northwind_Standard_Benefits_Details.pdf#page=91]. ``` -------------------------------- ### Prompty and Cache Dependencies Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/requirements.txt This entry lists the 'prompty' library for prompt engineering and 'propcache' for caching mechanisms. ```python prompty==0.1.50 propcache==0.2.0 ``` -------------------------------- ### Streaming Response Chunk with Error Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/http_protocol.md An example of a JSON chunk sent during a streaming response that indicates an error occurred. ```json { "error": "The app encountered an error processing your request.\nIf you are an administrator of the app, view the full error in the logs." } ``` -------------------------------- ### Set Azure OpenAI Embedding Deployment SKU Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/deploy_features.md Configures the SKU name for the Azure OpenAI embedding model deployment. Examples include GlobalStandard and Standard. ```bash azd env set AZURE_OPENAI_EMB_DEPLOYMENT_SKU GlobalStandard ``` ```bash azd env set AZURE_OPENAI_EMB_DEPLOYMENT_SKU Standard ``` -------------------------------- ### Run Post-Provision Hook Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/deploy_private.md Executes the post-provision hook, typically used for data ingestion, after establishing a VPN connection. ```bash azd hooks run postprovision ``` -------------------------------- ### Configure O3-mini Deployment Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/reasoning.md Sets environment variables for deploying the O3-mini reasoning model (no vision support), including model name, deployment details, and API version. ```shell azd env set AZURE_OPENAI_CHATGPT_MODEL o3-mini azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT o3-mini azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION 2025-01-31 azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU GlobalStandard azd env set AZURE_OPENAI_API_VERSION 2024-12-01-preview ``` -------------------------------- ### Get Signed-in User Azure ID Source: https://github.com/azure-samples/azure-search-openai-demo/blob/main/docs/sharing_environments.md Retrieves the Azure Active Directory ID of the currently signed-in user using the Azure CLI. ```azurecli az ad signed-in-user show ```