Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwd9000-ML committed Jan 22, 2024
1 parent 0c1cd90 commit 0764931
Show file tree
Hide file tree
Showing 35 changed files with 52 additions and 3,779 deletions.
13 changes: 0 additions & 13 deletions 06_librechat_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,6 @@ resource "azurerm_role_assignment" "librechat_app_kv_access" {

#TODO: Implement DALL-E
#TODO:
# # Deploy code from a public GitHub repo
# # resource "azurerm_app_service_source_control" "sourcecontrol" {
# # app_id = azurerm_linux_web_app.librechat.id
# # repo_url = "https://github.com/danny-avila/LibreChat"
# # branch = "main"
# # type = "Github"

# # # use_manual_integration = true
# # # use_mercurial = false
# # depends_on = [
# # azurerm_linux_web_app.librechat,
# # ]
# # }

# Implement a Search (either Meili or Azure AI Search)
# # Generate random strings as keys for meilisearch and librechat (Stored securely in Azure Key Vault)
Expand Down
4 changes: 2 additions & 2 deletions 06_librechat_app_config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ locals {
DEBUG_PLUGINS = var.libre_app_debug_plugins
CREDS_KEY = var.libre_app_plugins_creds_key != null ? var.libre_app_plugins_creds_key : "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.libre_app_creds_key.id})"
CREDS_IV = var.libre_app_plugins_creds_iv != null ? var.libre_app_plugins_creds_iv : "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.libre_app_creds_iv.id})"
PLUGIN_MODELS = var.libre_app_plugin_models
PLUGINS_USE_AZURE = var.libre_app_plugins_use_azure
#PLUGIN_MODELS = var.libre_app_plugin_models
#PLUGINS_USE_AZURE = var.libre_app_plugins_use_azure

### Azure OpenAI DALL-E-3 Plugin (Only in 'SwedenCentral' and 'EastUS') ###
DALLE3_AZURE_API_VERSION = var.libre_app_az_oai_dall3_api_version
Expand Down
88 changes: 0 additions & 88 deletions 07_test.tf

This file was deleted.

58 changes: 9 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

# Module: Azure OpenAI Private ChatGPT

**NOTE:** Your Azure subscription will need to be whitelisted for **Azure Open AI**. At the release time of this module (August 2023) you will need to request access via this **[form](https://aka.ms/oai/access)** and a further form for **[GPT 4](https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR7en2Ais5pxKtso_Pz4b1_xURjE4QlhVUERGQ1NXOTlNT0w1NldTWjJCMSQlQCN0PWcu)**. Once you have access deploy either **GPT-35-Turbo**, **GPT-35-Turbo-16k** or if you have access to **GPT-4-32k**, go forward with that model.
## Legacy Version 1.x

Easily construct a ChatGPT-style interface using Azure OpenAI and a suite of Azure services. Simplifying the complex.
**NOTE:** This module is now in version **2.x**. The legacy version **1.x** can be found in the legacy branch **[here](https://github.com/Pwd9000-ML/terraform-azurerm-openai-private-chatgpt/tree/legacy-v1)
This version is a complete rewrite of the module and is not backwards compatible with version 1.x.
New integrations and features have been added to the module to use the latest **Azure OpenAI** services and features such as `GPT-4-1106`, `GPT-4-Vision` and `DALL-E-3`. A new ChatBot UI / [LibreChat](https://docs.librechat.ai/index.html) has been added to the module to provide a complete solution.

![image.png](https://raw.githubusercontent.com/Pwd9000-ML/terraform-azurerm-openai-private-chatgpt/master/assets/chatbotui1.png)
<iframe width="757" height="500" src="https://www.youtube.com/embed/pNIOs1ovsXw" title="LibreChat: An Open Source Enhanced ChatGPT Clone with AI Model Switching, LangChain Plugins, &amp; More" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

## Introduction

Expand All @@ -21,63 +23,21 @@ For a deeper dive, refer to this [Microsoft Learn article](https://learn.microso

While Azure OpenAI does come with a cost, it's highly affordable—often, a conversation costs under 10 cents. You can review Azure [OpenAI's pricing](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/) details here.

This terraform module helps establishing a secure **ChatGPT-like** interface. This uses Azure OpenAI, combined with an array of Azure's other services, such as **Azure Container App**, **Azure Front Door / CDN**, **Web Application Firewall**, **Key Vault** and **Azure DNS**, ensuring a confidential and dedicated ChatGPT experience for you.

## Diagram

![image.png](https://raw.githubusercontent.com/Pwd9000-ML/terraform-azurerm-openai-private-chatgpt/master/assets/mainflow1.png)
coming soon...

## Description

This flexible terraform module is an **OpenAI accelerator** that can be used to deploy a privately hosted instance of a **ChatBot** similar to **ChatGPT** hosted on Azure using **Azure Container Apps**, **Azure OpenAI** and optionally fronted by **Azure CDN/Front Door** with a **WAF / Firewall** and custom allowed IP list.

## This module can be used to create the following

### Create OpenAI Service

1. Create an Azure Key Vault to store the OpenAI account details.
2. Create an OpenAI service account.
Other options include:
- Specify an already existing OpenAI service account to use.

3. Create OpenAI language model deployments on the OpenAI service. (e.g. GPT-3, GPT-4, etc.)
4. Store the OpenAI account and model details in the key vault for consumption.

### Create a container app ChatBot UI linked with OpenAI service hosted in Azure

1. Create a container app log analytics workspace (to link with container app).
2. Create a container app environment.
3. Create a container app instance hosting chatbot-ui from image/container.
4. Link chatbot-ui with corresponding OpenAI account and language model deployment.
5. Grant the container app access to the key vault to retrieve secrets (optional).

### Front solution with an Azure front door (optional)

1. Deploy Azure Front Door to front solution with CDN + WAF.
2. Setup a custom domain in Azure Front Door with AFD managed certificate.
Other options include:
- This example specifies an already existing DNZ zone to use. (e.g. `existingzone.com` - see `common.auto.tfvars`)
- **Note:** Remember to add the zone to your DNS registrar as the module creates a TXT auth. (Certificates fully managed by AFD)

3. Create a CNAME and TXT record in the custom DNS zone. (e.g. `privategpt.existingzone.com`)
4. Setup and apply an AFD WAF policy with `IPAllow list` for allowed IPs to connect using a custom rule.
coming soon...

## ChatBot Demo

![image.png](https://raw.githubusercontent.com/Pwd9000-ML/terraform-azurerm-openai-private-chatgpt/master/assets/chatbotui2.png)
coming soon...

## Examples

See **[Private ChatGPT with Azure Front Door + Firewall on existing DNS zone](https://github.com/Pwd9000-ML/terraform-azurerm-openai-private-chatgpt/tree/master/examples/PrivateGPT_w_AFD_WAF_existing_DNS_zone):**
For an example of how to create a Privately hosted instance of ChatBot/ChatGPT on Azure OpenAI with AFD + WAF using an existing DNS zone for the custom domain configuration.

See **[Private ChatGPT with Azure Front Door + Firewall on new DNS zone](https://github.com/Pwd9000-ML/terraform-azurerm-openai-private-chatgpt/tree/master/examples/PrivateGPT_w_AFD_WAF_new_DNS_zone):**
For an example of how to create a Privately hosted instance of ChatBot/ChatGPT on Azure OpenAI with AFD + WAF using a new DNS zone for the custom domain configuration.

See **[Private ChatGPT instance only](https://github.com/Pwd9000-ML/terraform-azurerm-openai-private-chatgpt/tree/master/examples/PrivateGPT_without_AFD_WAF):**
For an example of how to create a Privately hosted instance of ChatBot/ChatGPT on Azure OpenAI only. (No AFD + WAF + DNS zone)

This module is published on the **[Public Terraform Registry - openai-private-chatgpt](https://registry.terraform.io/modules/Pwd9000-ML/openai-private-chatgpt/azurerm/latest)**
coming soon...

Enjoy!

Expand Down
Binary file removed assets/chatbotui1.png
Binary file not shown.
Binary file removed assets/chatbotui2.png
Binary file not shown.
Empty file added assets/coming_soon.md
Empty file.
Binary file removed assets/mainflow1.png
Binary file not shown.
22 changes: 0 additions & 22 deletions data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,3 @@
# DATA #
##################################################
data "azurerm_client_config" "current" {}

# data "azurerm_subnet" "openai_subnet" {
# name = var.subnet_config.subnet_name
# virtual_network_name = var.virtual_network_name
# resource_group_name = var.resource_group_name
# depends_on = [azurerm_subnet.az_openai_subnet]
# }

# Data sources to get Subnet ID/s for CosmosDB and App Service
# Usage in Module example: subnet_id = data.azurerm_subnet.subnet["app-cosmos-sub"].id
# data "azurerm_subnet" "subnet" {
# for_each = { for each in var.subnet_config : each.subnet_name => each if var.create_openai_networking == false }
# name = each.value.subnet_name
# virtual_network_name = var.virtual_network_name
# resource_group_name = var.network_resource_group_name
# }

# data "azurerm_cosmosdb_account" "mongo" {
# for_each = { for each in var.cosmosdb_name : each.value => each if var.create_cosmosdb == false }
# name = each.value
# resource_group_name = var.cosmosdb_resource_group_name
# }
Empty file added examples/Coming_soon.md
Empty file.
Loading

0 comments on commit 0764931

Please sign in to comment.