Skip to content

Commit

Permalink
keyvault
Browse files Browse the repository at this point in the history
  • Loading branch information
placerda committed Aug 15, 2023
1 parent a725034 commit a9f8f43
Show file tree
Hide file tree
Showing 17 changed files with 3,639 additions and 265 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.azure
.azure
local/
101 changes: 43 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,69 @@
# GPT on Your Data

## Main components
Reference implementation of the Retrieval-Augmented Generation (RAG) pattern.

1) [Data ingestion](https://github.com/Azure/gpt-rag-ingestion)

2) [Orchestrator](https://github.com/Azure/gpt-rag-orchestrator)

3) [App Front-End](https://github.com/Azure/gpt-rag-frontend)

## General Architecture Overview
## Architecture Overview

<img src="media/oyd-rag.png" alt="imagem" width="1024">

Components:

[1 Data ingestion](https://github.com/Azure/gpt-rag-ingestion) ;
[2 Orchestrator](https://github.com/Azure/gpt-rag-orchestrator) ;
[3 App Front-End](https://github.com/Azure/gpt-rag-frontend)

## A Simple Retrieval-Augmented Generation Model

<img src="media/RAG.png" alt="imagem" width="1024">


## Zero Trust Architecture Overview

<img src="media/GPT-RAG_35.png" alt="imagem" width="1024">

<!-- ## Prerequisites
- [Azure Developer CLI](https://aka.ms/azure-dev/install) -->

## Prerequisites
## Deploy

- [Azure Developer CLI](https://aka.ms/azure-dev/install)
To deploy this solution you just need to execute the next four steps:

## Deploy
**1) Provision required Azure services**

You can do it by clicking on the following button

1) Create a new folder and switch to it in the terminal.
2) Run `azd auth login` (if you did not run this before).
3) If did not clone the repo already, run `azd init -t azure/gpt-rag`.
4) There are 2 options how you can set the name of the resources created on Azure:

- Pick the name for each resource at `infra/main.parameters.json`. Add a key and value for each of the next keys within the `parameters` map:
```json
"resourceGroupName": {
"value": "name-for-the-resource-group"
},
"keyVaultName": {
"value": "name-for-key-vault"
},
"azureFunctionsServicePlanName":{
"value": "name-for-service-plan"
},
"orchestratorFunctionsName":{
"value": "name-for-orchestrator-function"
},
"dataIngestionFunctionsName":{
"value": "name-for-data-ingestion-function"
},
"searchServiceName": {
"value": "name-for-search-service"
}
"openAiServiceName": {
"value": "name-for-open-ai-service"
}
```

- Alternately, you can set the name of each resource and save it within the azd-environment. Add the `infra` and `parameters` fields within the `config.json` file, next to the azd .env file. For example `.azure/azd-env-name/config.json`.

```json
"infra": {
"parameters": {
"azureFunctionsServicePlanName": "the-plan",
"dataIngestionFunctionsName": "data-ingest-func",
"keyVaultName": "vv-kv-vh2",
"openAiServiceName": "ai-s-r",
"orchestratorFunctionsName": "o-fun",
"resourceGroupName": "viva-rg",
"searchServiceName": "sea"
}
}
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazure%2Fgpt-rag%2Fmain%2Finfra%2Fmain.json)

or by installing [Azure Developer CLI (azd)](https://aka.ms/azure-dev/install) and executing the following lines in terminal

```
azd auth login
azd init -t azure/gpt-rag
azd up
```

5) Run `azd up`.
\* Important: when selecting the target location check [here](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/models) the regions that currently support the Azure OpenAI models you want to use.

**2) Ingestion Component**

Use [Data ingestion](https://github.com/Azure/gpt-rag-ingestion) repo template to create your data ingestion git repo and execute the steps in its **Deploy** section.

**3) Orchestrator Component**

Use [Orchestrator](https://github.com/Azure/gpt-rag-orchestrator) repo template to create your orchestrator git repo and execute the steps in its **Deploy** section.

**4) Front-end Component**

Use [App Front-end](https://github.com/Azure/gpt-rag-frontend) repo template to create your own frontend git repo and execute the steps in its **Deploy** section.

<!-- ## Main components
1) [Data ingestion](https://github.com/Azure/gpt-rag-ingestion)
2) [Orchestrator](https://github.com/Azure/gpt-rag-orchestrator)
3) [App Front-End](https://github.com/Azure/gpt-rag-frontend) -->

* 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](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/models)

## References

Expand Down
33 changes: 0 additions & 33 deletions infra/app/data-ingestion.bicep

This file was deleted.

33 changes: 0 additions & 33 deletions infra/app/orchestrator.bicep

This file was deleted.

2 changes: 2 additions & 0 deletions infra/core/ai/cognitiveservices.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ resource deployment 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01
output endpoint string = account.properties.endpoint
output id string = account.id
output name string = account.name
// output apiKey string = listkeys(account.id, '2023-05-01').key1
output apiKey string = account.listKeys().key1
123 changes: 123 additions & 0 deletions infra/core/db/cosmos.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
@description('Cosmos DB account name, max length 44 characters, lowercase')
param accountName string

@description('Location for the Cosmos DB account.')
param location string = resourceGroup().location

param tags object = {}

@description('The default consistency level of the Cosmos DB account.')
@allowed([
'Eventual'
'ConsistentPrefix'
'Session'
'BoundedStaleness'
'Strong'
])
param defaultConsistencyLevel string = 'Session'

@description('Max stale requests. Required for BoundedStaleness. Valid ranges, Single Region: 10 to 2147483647. Multi Region: 100000 to 2147483647.')
@minValue(10)
@maxValue(2147483647)
param maxStalenessPrefix int = 100000

@description('Max lag time (minutes). Required for BoundedStaleness. Valid ranges, Single Region: 5 to 84600. Multi Region: 300 to 86400.')
@minValue(5)
@maxValue(86400)
param maxIntervalInSeconds int = 300

@description('Enable system managed failover for regions')
param systemManagedFailover bool = true

@description('The name for the database')
param databaseName string

@description('The name for the container')
param containerName string

@description('Maximum autoscale throughput for the container')
@minValue(1000)
@maxValue(1000000)
param autoscaleMaxThroughput int = 1000

var consistencyPolicy = {
Eventual: {
defaultConsistencyLevel: 'Eventual'
}
ConsistentPrefix: {
defaultConsistencyLevel: 'ConsistentPrefix'
}
Session: {
defaultConsistencyLevel: 'Session'
}
BoundedStaleness: {
defaultConsistencyLevel: 'BoundedStaleness'
maxStalenessPrefix: maxStalenessPrefix
maxIntervalInSeconds: maxIntervalInSeconds
}
Strong: {
defaultConsistencyLevel: 'Strong'
}
}
var locations = [
{
locationName: location
failoverPriority: 0
isZoneRedundant: false
}
]

resource account 'Microsoft.DocumentDB/databaseAccounts@2022-05-15' = {
name: toLower(accountName)
kind: 'GlobalDocumentDB'
location: location
tags: tags
properties: {
consistencyPolicy: consistencyPolicy[defaultConsistencyLevel]
locations: locations
databaseAccountOfferType: 'Standard'
enableAutomaticFailover: systemManagedFailover
}
}

resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-05-15' = {
parent: account
name: databaseName
properties: {
resource: {
id: databaseName
}
}
}

resource container 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-05-15' = {
parent: database
name: containerName
properties: {
resource: {
id: containerName
partitionKey: {
paths: [
'/id'
]
kind: 'Hash'
}
indexingPolicy: {
indexingMode: 'consistent'
includedPaths: [
{
path: '/*'
}
]
}
defaultTtl: 86400
}
options: {
autoscaleSettings: {
maxThroughput: autoscaleMaxThroughput
}
}
}
}

output azureDBkey string = account.listKeys().primaryMasterKey
24 changes: 24 additions & 0 deletions infra/core/delay.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
param location string = resourceGroup().location
param utcValue string = utcNow()
param sleepName string = 'sleep-1'
param sleepSeconds int = 120
resource sleepDelay 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
name: sleepName
location: location
kind: 'AzurePowerShell'
properties: {
forceUpdateTag: utcValue
azPowerShellVersion: '8.3'
timeout: 'PT10M'
arguments: '-seconds ${sleepSeconds}'
scriptContent: '''
param ( [string] $seconds )
Write-Output Sleeping for: $seconds ....
Start-Sleep -Seconds $seconds
Write-Output Sleep over - resuming ....
'''
cleanupPreference: 'OnSuccess'
retentionInterval: 'P1D'
}
}
output location string = sleepDelay.location
14 changes: 14 additions & 0 deletions infra/core/host/appinsights.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
param applicationInsightsName string
param appInsightsLocation string

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: applicationInsightsName
location: appInsightsLocation
kind: 'web'
properties: {
Application_Type: 'web'
Request_Source: 'rest'
}
}

output instrumentationKey string = applicationInsights.properties.InstrumentationKey
Loading

0 comments on commit a9f8f43

Please sign in to comment.