Skip to content

docs: add docker to prerequisites #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
"image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:dev-20-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/turborepo-npm:1": {},
"ghcr.io/devcontainers-contrib/features/typescript:2": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11",
"toolsToInstall": [
"flake8",
"black",
"mypy",
"poetry"
]
}
"ghcr.io/azure/azure-dev/azd:latest": {},
"ghcr.io/devcontainers/features/docker-in-docker:1": {
"version": "20.10.23",
"moby": "false",
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers/features/azure-cli:1": {
"version": "latest",
"installBicep": true
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/typescript:2": {}
},
"customizations": {
"codespaces": {
Expand All @@ -23,24 +27,26 @@
"extensions": [
"ms-vscode.typescript-language-features",
"esbenp.prettier-vscode",
"ms-python.python",
"ms-python.black-formatter",
"ms-python.vscode-flake8",
"ms-python.vscode-pylance"
],
"settings": {
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "basic"
}
"ms-azuretools.vscode-bicep",
"ms-azuretools.vscode-azurecontainerapps",
"ms-azuretools.vscode-docker",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-azuretools.azure-dev",
"GitHub.vscode-pull-request-github",
"EditorConfig.EditorConfig",
"GitHub.copilot"
]
}
},
"containerEnv": {
"POETRY_VIRTUALENVS_CREATE": "false"
"portsAttributes": {
"3000": {
"label": "Next.js",
"onAutoForward": "notify"
}
},
"forwardPorts": [
3000,
8000
3000
],
"postCreateCommand": "npm install"
}
15 changes: 0 additions & 15 deletions .env

This file was deleted.

11 changes: 9 additions & 2 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
# Set this to the mainline branch you are using
branches:
- main
- master

# GitHub Actions workflow to deploy to Azure using azd
# To configure required secrets for connecting to Azure, simply run `azd pipeline config`
Expand Down Expand Up @@ -58,6 +57,14 @@ jobs:

- name: Provision Infrastructure
run: azd provision --no-prompt
env:
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}

- name: Deploy Application
run: azd deploy --no-prompt
run: azd deploy --no-prompt
env:
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ yarn-error.log*

# local env files
.env*.local

.env
# vercel
.vercel

Expand All @@ -35,4 +35,4 @@ yarn-error.log*
next-env.d.ts

tool-output/
.azure
.azure
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Open the URL `http://localhost:3000` in your browser to interact with the bot.

You need to install following tools to work on your local machine:

- [Docker](https://docs.docker.com/get-docker)
- [Node.js LTS](https://nodejs.org/download/)
- [Azure Developer CLI](https://aka.ms/azure-dev/install)
- [Git](https://git-scm.com/downloads)
Expand Down
6 changes: 3 additions & 3 deletions app/api/chat/engine/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export const initSettings = async () => {
console.log(`Using '${process.env.MODEL_PROVIDER}' model provider`);

// if provider is OpenAI, MODEL must be set
if (process.env.MODEL_PROVIDER === 'openai' && process.env.OPENAI_API_TYPE !== 'azure' && !process.env.MODEL) {
if (process.env.MODEL_PROVIDER === 'openai' && process.env.OPENAI_API_TYPE !== 'AzureOpenAI' && !process.env.MODEL) {
throw new Error("'MODEL' env variable must be set.");
}

// if provider is Azure OpenAI, AZURE_DEPLOYMENT_NAME must be set
if (process.env.MODEL_PROVIDER === 'openai' && process.env.OPENAI_API_TYPE === 'azure' && !process.env.AZURE_DEPLOYMENT_NAME) {
if (process.env.MODEL_PROVIDER === 'openai' && process.env.OPENAI_API_TYPE === 'AzureOpenAI' && !process.env.AZURE_DEPLOYMENT_NAME) {
throw new Error("'AZURE_DEPLOYMENT_NAME' env variables must be set.");
}

Expand All @@ -34,7 +34,7 @@ export const initSettings = async () => {
initOllama();
break;
case "openai":
if (process.env.OPENAI_API_TYPE === "azure") {
if (process.env.OPENAI_API_TYPE === "AzureOpenAI") {
await initAzureOpenAI();
} else {
initOpenAI();
Expand Down
8 changes: 8 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ services:
continueOnError: false
interactive: false
run: npm run generate
hooks:
postprovision:
windows:
shell: pwsh
run: azd env get-values > .env
posix:
shell: sh
run: azd env get-values > .env
2 changes: 1 addition & 1 deletion cache/doc_store.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cache/index_store.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cache/vector_store.json

Large diffs are not rendered by default.

31 changes: 26 additions & 5 deletions infra/app/llama-index-nextjs.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ param containerRegistryName string
param containerAppsEnvironmentName string
param applicationInsightsName string
param exists bool

@description('Whether the deployment is running on GitHub Actions')
param runningOnGh string = ''

@description('Id of the user or app to assign application roles')
param principalId string = ''

@secure()
param appDefinition object

Expand Down Expand Up @@ -42,17 +49,31 @@ resource acrPullRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: containerRegistry
name: guid(subscription().id, resourceGroup().id, identity.id, 'acrPullRole')
properties: {
roleDefinitionId: subscriptionResourceId(
'Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')
principalType: 'ServicePrincipal'
principalId: identity.properties.principalId
roleDefinitionId: '7f951dda-4ed3-4680-a7ca-43fe172d538d'
principalType: 'ServicePrincipal'
}
}

// System roles
module openAiRole '../shared/role.bicep' = {

// Roles

// User roles
module openAiRoleUser '../shared/role.bicep' = if (empty(runningOnGh)) {
scope: resourceGroup()
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiUserRole')
params: {
principalId: principalId
// Cognitive Services OpenAI User
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
principalType: 'User'
}
}

// System roles
module openAiRoleBackend '../shared/role.bicep' = {
scope: resourceGroup()
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiServicePrincipalRole')
params: {
principalId: app.identity.principalId
// Cognitive Services OpenAI User
Expand Down
23 changes: 9 additions & 14 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ param environmentName string
@description('Primary location for all resources')
param location string

@description('Whether the deployment is running on GitHub Actions')
param runningOnGh string = ''

param llamaIndexNextjsExists bool
@secure()
param llamaIndexNextjsDefinition object
Expand Down Expand Up @@ -154,26 +157,13 @@ module openAi './shared/cognitiveservices.bicep' = if (empty(openAiUrl)) {
}
}

// Roles

// User roles
module openAiRoleUser './shared/role.bicep' = {
scope: rg
name: 'openai-role-user'
params: {
principalId: principalId
// Cognitive Services OpenAI User
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
principalType: 'User'
}
}

module llamaIndexNextjs './app/llama-index-nextjs.bicep' = {
name: 'llama-index-nextjs'
params: {
name: '${abbrs.appContainerApps}llama-index-${resourceToken}'
location: location
tags: tags
runningOnGh: runningOnGh
identityName: '${abbrs.managedIdentityUserAssignedIdentities}llama-index-${resourceToken}'
applicationInsightsName: monitoring.outputs.applicationInsightsName
containerAppsEnvironmentName: appsEnv.outputs.name
Expand Down Expand Up @@ -237,6 +227,10 @@ module llamaIndexNextjs './app/llama-index-nextjs.bicep' = {
name: 'SYSTEM_PROMPT'
value: llamaIndexConfig.system_prompt
}
{
name: 'OPENAI_API_TYPE'
value: 'AzureOpenAI'
}
]
})
}
Expand All @@ -262,3 +256,4 @@ output LLM_MAX_TOKENS string = llamaIndexConfig.llm_max_tokens
output TOP_K string = llamaIndexConfig.top_k
output FILESERVER_URL_PREFIX string = llamaIndexConfig.fileserver_url_prefix
output SYSTEM_PROMPT string = llamaIndexConfig.system_prompt
output OPENAI_API_TYPE string = 'AzureOpenAI'
4 changes: 2 additions & 2 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"openAiApiVersion": {
"value": "${AZURE_OPENAI_API_VERSION=2024-02-15-preview}"
},
"isContinuousDeployment": {
"value": "${CI=false}"
"runningOnGh": {
"value": "${GITHUB_ACTIONS}"
},
"azureDeploymentName": {
"value": "${AZURE_DEPLOYMENT_NAME=gpt-35-turbo}"
Expand Down
Loading