-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add contoso trek product info chatbot custom example scenario (#3)
- Loading branch information
Showing
53 changed files
with
3,401 additions
and
870 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM mcr.microsoft.com/devcontainers/python:1-3.10-bullseye | ||
|
||
# # Install Databricks CLI | ||
RUN curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sudo sh | ||
|
||
# Copy Python dependencies | ||
COPY ./requirements.txt ./requirements.txt | ||
|
||
# Install Python dependencies | ||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir -r ./requirements.txt | ||
|
||
# Install Azure ClI | ||
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash && az bicep install | ||
|
||
# Connect as root non-root user. More info: https://aka.ms/dev-containers-non-root. | ||
USER vscode | ||
|
||
# Add zsh-autosuggestions | ||
RUN git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions | ||
RUN printf 'source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh\n' >> ~/.zshrc | ||
|
||
# Add zsh-syntax-highlighting | ||
RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting | ||
RUN printf 'source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh\n' >> ~/.zshrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/python | ||
{ | ||
"name": "azure-open-ai-example-scenarios", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"build": { | ||
// Path is relative to the devcontainer.json file. | ||
"dockerfile": "Dockerfile" | ||
}, | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2.10.2": {}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {}, | ||
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [ | ||
8501 | ||
], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "", | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-azuretools.vscode-docker", | ||
"charliermarsh.ruff", | ||
"ms-vscode.vscode-node-azure-pack", | ||
"ms-vscode.azurecli", | ||
"ms-azuretools.vscode-bicep", | ||
"ms-vscode-remote.remote-containers", | ||
"databricks.databricks", | ||
"github.vscode-github-actions", | ||
"redhat.vscode-yaml", | ||
"ms-toolsai.jupyter", | ||
"ms-python.python", | ||
"yzhang.markdown-all-in-one" | ||
] | ||
}, | ||
"settings": { | ||
"editor.autoClosingBrackets": "always", | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": "explicit" | ||
}, | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnSave": true, | ||
"editor.inlineSuggest.enabled": true, | ||
"files.autoSave": "afterDelay", | ||
"git.autofetch": true, | ||
"github.copilot.enable": { | ||
"*": true | ||
}, | ||
"notebook.formatOnSave.enabled": true, | ||
"notebook.codeActionsOnSave": { | ||
"notebook.source.fixAll": "explicit", | ||
"notebook.source.organizeImports": "explicit" | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "zsh", | ||
"terminal.integrated.profiles.linux": { | ||
"zsh": { | ||
"path": "/usr/bin/zsh" | ||
} | ||
}, | ||
"[python]": { | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit", | ||
"source.organizeImports": "explicit" | ||
}, | ||
"editor.defaultFormatter": "charliermarsh.ruff" | ||
} | ||
} | ||
}, | ||
// You can use the mounts property to persist the user profile (to keep things like shell history). | ||
"mounts": [ | ||
"source=profile,target=/root,type=volume", | ||
"target=/root/.vscode-server,type=volume" | ||
] | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
azure-identity==1.16.0 | ||
ipykernel==6.29.4 | ||
Jinja2==3.1.4 | ||
openai==1.26.0 | ||
python-dotenv==1.0.1 | ||
requests==2.31.0 | ||
stop-words==2018.7.23 | ||
streamlit==1.34.0 | ||
streamlit-extras==0.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for more information: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
# https://containers.dev/guide/dependabot | ||
|
||
version: 2 | ||
updates: | ||
|
||
- package-ecosystem: "devcontainers" | ||
directory: ".devcontainer/" | ||
schedule: | ||
interval: weekly | ||
|
||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
|
||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Getting Started | ||
|
||
The purpose of this section is to provide an overview of each example scenario. | ||
|
||
## Example Scenario: Contoso Trek Product Info Chatbot (Custom) | ||
|
||
### Overview | ||
|
||
This example scenario demonstrates a small-scale proof-of-concept deployment of a chatbot leveraging Azure OpenAI and Azure AI Search. It coveres the following key areas: | ||
|
||
- Pull-based data ingestion with Azure AI Search | ||
- Custom retrieval-augmented generation (RAG) Implementation | ||
- Built using Streamlit | ||
- Deployed using Azure Container Apps | ||
|
||
### Solution Design | ||
|
||
The below diagram shows a high-level design for the chatbot leveraging Azure OpenAI, Azure AI Search, deployed as part of an Azure Container App. | ||
|
||
![Solution Design](./images/design-01.png) | ||
|
||
The solution consists of the following services: | ||
|
||
- **[Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/overview)**: Provides the large language model (LLM) capabilities for generating human-like responses based on user queries. | ||
- **[Azure AI Search](https://learn.microsoft.com/azure/search/search-what-is-azure-search)**: Enables efficient retrieval of relevant information from your enterprise knowledge base or data sources. | ||
- **[Container Registry](https://learn.microsoft.com/azure/container-registry/container-registry-intro)**: Used for storing the Docker image. | ||
- **[Container App](https://learn.microsoft.com/azure/container-apps/containers)**: Used for exposing the container as a REST API. | ||
|
||
The following open-source Python framework are used in this project: | ||
|
||
- **[Streamlit](https://streamlit.io/)**: Facilitates a lightweight and user-friendly deployment experience, making the chatbot readily accessible through a web interface. | ||
|
||
### How It Works | ||
|
||
The RAG pattern implemented here utilizes Azure AI Search to retrieve the most relevant information based on the user's query. This retrieved information is then fed into the Azure OpenAI LLM, which generates a comprehensive and informative response tailored to the specific context. | ||
|
||
The chatbot is built using Streamlit, which provides a simple and intuitive interface for users to interact with the chatbot. The chatbot is deployed using Azure Container Apps, which allows for easy scaling and management of the application. | ||
|
||
The [Step-by-Step Setup](.github/docs/step-by-step-setup.md) section of this repository. provides detailed instructions on how to deploy this proof-of-concept. | ||
|
||
> [!CAUTION] | ||
> This solution design is intended for proof-of-concept scenarios and is not recommended for enterprise production scenarios. It is advised to review and adjust the design based on your specific requirements if you plan to use this in a production environment. This could include: | ||
> | ||
> - Securing the solution through network controls. | ||
> - Upflift observability by enabling monitoring and logging for different services. | ||
> - Defining an operational support and lifecycle management plan for the solution. | ||
> - Implementing alerting and notification mechanisms to notify support teams of any issues (e.g. performance, budget, etc.). | ||
> | ||
> The Azure Well-Architected Framework provides guidance on best practices for designing, building, and maintaining cloud solutions. For more information, see the [Azure Well-Architected Framework](https://learn.microsoft.com/azure/well-architected/what-is-well-architected-framework). | ||
## Related Resources | ||
|
||
- [Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/) | ||
- [Azure AI Search](https://learn.microsoft.com/azure/search/) | ||
- [Streamlit](https://streamlit.io/) | ||
- [Azure OpenAI Service REST API reference](https://learn.microsoft.com/azure/ai-services/openai/reference) | ||
- [Securely use Azure OpenAI on your data](https://learn.microsoft.com/azure/ai-services/openai/how-to/use-your-data-securely) | ||
- [Introduction to prompt engineering](https://learn.microsoft.com/azure/ai-services/openai/concepts/prompt-engineering) | ||
- [Prompt engineering techniques](https://learn.microsoft.com/azure/ai-services/openai/concepts/advanced-prompt-engineering?pivots=programming-language-chat-completions) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.