Skip to content

Commit d85f039

Browse files
authored
Add contoso trek product info chatbot custom example scenario (#3)
1 parent 4d0cae5 commit d85f039

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3401
-870
lines changed

.devcontainer/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM mcr.microsoft.com/devcontainers/python:1-3.10-bullseye
2+
3+
# # Install Databricks CLI
4+
RUN curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sudo sh
5+
6+
# Copy Python dependencies
7+
COPY ./requirements.txt ./requirements.txt
8+
9+
# Install Python dependencies
10+
RUN pip install --no-cache-dir --upgrade pip && \
11+
pip install --no-cache-dir -r ./requirements.txt
12+
13+
# Install Azure ClI
14+
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash && az bicep install
15+
16+
# Connect as root non-root user. More info: https://aka.ms/dev-containers-non-root.
17+
USER vscode
18+
19+
# Add zsh-autosuggestions
20+
RUN git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
21+
RUN printf 'source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh\n' >> ~/.zshrc
22+
23+
# Add zsh-syntax-highlighting
24+
RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting
25+
RUN printf 'source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh\n' >> ~/.zshrc

.devcontainer/devcontainer.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "azure-open-ai-example-scenarios",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"build": {
7+
// Path is relative to the devcontainer.json file.
8+
"dockerfile": "Dockerfile"
9+
},
10+
// Features to add to the dev container. More info: https://containers.dev/features.
11+
"features": {
12+
"ghcr.io/devcontainers/features/docker-in-docker:2.10.2": {},
13+
"ghcr.io/devcontainers/features/github-cli:1": {},
14+
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {}
15+
},
16+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
17+
"forwardPorts": [
18+
8501
19+
],
20+
// Use 'postCreateCommand' to run commands after the container is created.
21+
// "postCreateCommand": "",
22+
// Configure tool-specific properties.
23+
"customizations": {
24+
"vscode": {
25+
"extensions": [
26+
"ms-azuretools.vscode-docker",
27+
"charliermarsh.ruff",
28+
"ms-vscode.vscode-node-azure-pack",
29+
"ms-vscode.azurecli",
30+
"ms-azuretools.vscode-bicep",
31+
"ms-vscode-remote.remote-containers",
32+
"databricks.databricks",
33+
"github.vscode-github-actions",
34+
"redhat.vscode-yaml",
35+
"ms-toolsai.jupyter",
36+
"ms-python.python",
37+
"yzhang.markdown-all-in-one"
38+
]
39+
},
40+
"settings": {
41+
"editor.autoClosingBrackets": "always",
42+
"editor.codeActionsOnSave": {
43+
"source.organizeImports": "explicit"
44+
},
45+
"editor.formatOnPaste": true,
46+
"editor.formatOnSave": true,
47+
"editor.inlineSuggest.enabled": true,
48+
"files.autoSave": "afterDelay",
49+
"git.autofetch": true,
50+
"github.copilot.enable": {
51+
"*": true
52+
},
53+
"notebook.formatOnSave.enabled": true,
54+
"notebook.codeActionsOnSave": {
55+
"notebook.source.fixAll": "explicit",
56+
"notebook.source.organizeImports": "explicit"
57+
},
58+
"terminal.integrated.defaultProfile.linux": "zsh",
59+
"terminal.integrated.profiles.linux": {
60+
"zsh": {
61+
"path": "/usr/bin/zsh"
62+
}
63+
},
64+
"[python]": {
65+
"editor.formatOnSave": true,
66+
"editor.codeActionsOnSave": {
67+
"source.fixAll": "explicit",
68+
"source.organizeImports": "explicit"
69+
},
70+
"editor.defaultFormatter": "charliermarsh.ruff"
71+
}
72+
}
73+
},
74+
// You can use the mounts property to persist the user profile (to keep things like shell history).
75+
"mounts": [
76+
"source=profile,target=/root,type=volume",
77+
"target=/root/.vscode-server,type=volume"
78+
]
79+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
80+
// "remoteUser": "root"
81+
}

.devcontainer/requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
azure-identity==1.16.0
2+
ipykernel==6.29.4
3+
Jinja2==3.1.4
4+
openai==1.26.0
5+
python-dotenv==1.0.1
6+
requests==2.31.0
7+
stop-words==2018.7.23
8+
streamlit==1.34.0
9+
streamlit-extras==0.4.2

.github/dependabot.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
10+
- package-ecosystem: "devcontainers"
11+
directory: ".devcontainer/"
12+
schedule:
13+
interval: weekly
14+
15+
- package-ecosystem: "docker"
16+
directory: "/"
17+
schedule:
18+
interval: weekly
19+
20+
- package-ecosystem: "github-actions"
21+
directory: "/"
22+
schedule:
23+
interval: "weekly"
24+
25+
- package-ecosystem: "pip"
26+
directory: "/"
27+
schedule:
28+
interval: "weekly"

.github/docs/getting-started.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Getting Started
2+
3+
The purpose of this section is to provide an overview of each example scenario.
4+
5+
## Example Scenario: Contoso Trek Product Info Chatbot (Custom)
6+
7+
### Overview
8+
9+
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:
10+
11+
- Pull-based data ingestion with Azure AI Search
12+
- Custom retrieval-augmented generation (RAG) Implementation
13+
- Built using Streamlit
14+
- Deployed using Azure Container Apps
15+
16+
### Solution Design
17+
18+
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.
19+
20+
![Solution Design](./images/design-01.png)
21+
22+
The solution consists of the following services:
23+
24+
- **[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.
25+
- **[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.
26+
- **[Container Registry](https://learn.microsoft.com/azure/container-registry/container-registry-intro)**: Used for storing the Docker image.
27+
- **[Container App](https://learn.microsoft.com/azure/container-apps/containers)**: Used for exposing the container as a REST API.
28+
29+
The following open-source Python framework are used in this project:
30+
31+
- **[Streamlit](https://streamlit.io/)**: Facilitates a lightweight and user-friendly deployment experience, making the chatbot readily accessible through a web interface.
32+
33+
### How It Works
34+
35+
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.
36+
37+
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.
38+
39+
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.
40+
41+
> [!CAUTION]
42+
> 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:
43+
>
44+
> - Securing the solution through network controls.
45+
> - Upflift observability by enabling monitoring and logging for different services.
46+
> - Defining an operational support and lifecycle management plan for the solution.
47+
> - Implementing alerting and notification mechanisms to notify support teams of any issues (e.g. performance, budget, etc.).
48+
>
49+
> 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).
50+
51+
## Related Resources
52+
53+
- [Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/)
54+
- [Azure AI Search](https://learn.microsoft.com/azure/search/)
55+
- [Streamlit](https://streamlit.io/)
56+
- [Azure OpenAI Service REST API reference](https://learn.microsoft.com/azure/ai-services/openai/reference)
57+
- [Securely use Azure OpenAI on your data](https://learn.microsoft.com/azure/ai-services/openai/how-to/use-your-data-securely)
58+
- [Introduction to prompt engineering](https://learn.microsoft.com/azure/ai-services/openai/concepts/prompt-engineering)
59+
- [Prompt engineering techniques](https://learn.microsoft.com/azure/ai-services/openai/concepts/advanced-prompt-engineering?pivots=programming-language-chat-completions)

.github/docs/images/design-01.png

239 KB
Loading

0 commit comments

Comments
 (0)