Skip to content

Commit

Permalink
merge latest changes (#1)
Browse files Browse the repository at this point in the history
* Merge pull request microsoft#429 from microsoft/geearl/6323-large-tables

Geearl/6323 large tables

* Resolve function debug issue and add logic for multiple table spans

* Update deployment.md

Updates on Setting the right tenant if you're part of multiple tenant. Otherwise deployment will fail.

* Bump fastapi from 0.103.2 to 0.109.1 in /app/enrichment

Bumps [fastapi](https://github.com/tiangolo/fastapi) from 0.103.2 to 0.109.1.
- [Release notes](https://github.com/tiangolo/fastapi/releases)
- [Commits](tiangolo/fastapi@0.103.2...0.109.1)

---
updated-dependencies:
- dependency-name: fastapi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* gov changes

* gov changes

* gov changes

* new app service app setting and readme update

* url update

* Pushing out temp fixes until python sdk is resolved.

* Remove media_service and avam modules

* script fix

* updated link

* Remove base_url breaking param

* Resolve issue with new gov logic on aoai endpoint resolution

* Merge pull request microsoft#523 and microsoft#530 from vNext-Dev for large table fixes

* Update app.py

added `.lower()` to ensure the str read is in correctly converted to a bool.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dayland <dayland@microsoft.com>
Co-authored-by: dayland <48474707+dayland@users.noreply.github.com>
Co-authored-by: avidunixuser <avidunixuser@users.noreply.github.com>
Co-authored-by: ryonsteele <ryonsteele@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Danimal <dbiscup@microsoft.com>
Co-authored-by: Brandon Rohrer <brandon.rohrer@outlook.com>
Co-authored-by: Nehemiah Kuhns <85817913+nhwkuhns@users.noreply.github.com>
  • Loading branch information
9 people committed Apr 8, 2024
1 parent 9c80bd8 commit a45eb51
Show file tree
Hide file tree
Showing 12 changed files with 305 additions and 98 deletions.
27 changes: 19 additions & 8 deletions app/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import openai
from approaches.chatreadretrieveread import ChatReadRetrieveReadApproach
from azure.core.credentials import AzureKeyCredential
from azure.identity import DefaultAzureCredential
from azure.identity import DefaultAzureCredential, AzureAuthorityHosts
from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient
from azure.search.documents import SearchClient
from azure.storage.blob import (
Expand Down Expand Up @@ -49,6 +49,7 @@
EMBEDDING_DEPLOYMENT_NAME = ( os.environ.get("EMBEDDING_DEPLOYMENT_NAME") or "")
AZURE_OPENAI_EMBEDDINGS_MODEL_NAME = ( os.environ.get("AZURE_OPENAI_EMBEDDINGS_MODEL_NAME") or "")
AZURE_OPENAI_EMBEDDINGS_VERSION = ( os.environ.get("AZURE_OPENAI_EMBEDDINGS_VERSION") or "")
AZURE_MANAGEMENT_URL = ( os.environ.get("AZURE_MANAGEMENT_URL") or "")

AZURE_OPENAI_SERVICE_KEY = os.environ.get("AZURE_OPENAI_SERVICE_KEY")
AZURE_SUBSCRIPTION_ID = os.environ.get("AZURE_SUBSCRIPTION_ID")
Expand Down Expand Up @@ -76,18 +77,26 @@

# embedding_service_suffix = "xyoek"

# Used by the OpenAI SDK
openai.api_type = "azure"

authority = AzureAuthorityHosts.AZURE_PUBLIC_CLOUD

if (IS_GOV_CLOUD_DEPLOYMENT):
authority = AzureAuthorityHosts.AZURE_GOVERNMENT
openai.api_base = f"https://{AZURE_OPENAI_SERVICE}.openai.azure.us"
else:
openai.api_base = f"https://{AZURE_OPENAI_SERVICE}.openai.azure.com"

openai.api_version = "2023-06-01-preview"

# Use the current user identity to authenticate with Azure OpenAI, Cognitive Search and Blob Storage (no secrets needed,
# just use 'az login' locally, and managed identity when deployed on Azure). If you need to use keys, use separate AzureKeyCredential instances with the
# keys for each service
# If you encounter a blocking error during a DefaultAzureCredntial resolution, you can exclude the problematic credential by using a parameter (ex. exclude_shared_token_cache_credential=True)
azure_credential = DefaultAzureCredential()
azure_credential = DefaultAzureCredential(authority=authority)
azure_search_key_credential = AzureKeyCredential(AZURE_SEARCH_SERVICE_KEY)

# Used by the OpenAI SDK
openai.api_type = "azure"
openai.api_base = f"https://{AZURE_OPENAI_SERVICE}.openai.azure.com"
openai.api_version = "2023-06-01-preview"

# Setup StatusLog to allow access to CosmosDB for logging
statusLog = StatusLog(
COSMOSDB_URL, COSMODB_KEY, COSMOSDB_LOG_DATABASE_NAME, COSMOSDB_LOG_CONTAINER_NAME
Expand Down Expand Up @@ -116,13 +125,15 @@
model_name = ''
model_version = ''

# Python issue Logged > https://github.com/Azure/azure-sdk-for-python/issues/34337
# Once fixed, this If statement can be removed.
if (IS_GOV_CLOUD_DEPLOYMENT):
model_name = AZURE_OPENAI_CHATGPT_MODEL_NAME
model_version = AZURE_OPENAI_CHATGPT_MODEL_VERSION
embedding_model_name = AZURE_OPENAI_EMBEDDINGS_MODEL_NAME
embedding_model_version = AZURE_OPENAI_EMBEDDINGS_VERSION
else:
# Set up OpenAI management client
#Set up OpenAI management client
openai_mgmt_client = CognitiveServicesManagementClient(
credential=azure_credential,
subscription_id=AZURE_SUBSCRIPTION_ID)
Expand Down
8 changes: 6 additions & 2 deletions app/backend/approaches/chatreadretrieveread.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ def __init__(
self.embedding_service_url = f'https://{ENRICHMENT_APPSERVICE_NAME}.azurewebsites.us'
else:
self.embedding_service_url = f'https://{ENRICHMENT_APPSERVICE_NAME}.azurewebsites.net'

openai.api_base = 'https://' + oai_service_name + '.openai.azure.com/'

if is_gov_cloud_deployment:
openai.api_base = 'https://' + oai_service_name + '.openai.azure.us/'
else:
openai.api_base = 'https://' + oai_service_name + '.openai.azure.com/'

openai.api_type = 'azure'
openai.api_key = oai_service_key

Expand Down
13 changes: 10 additions & 3 deletions app/enrichment/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@
"TARGET_EMBEDDINGS_MODEL": None,
"EMBEDDING_VECTOR_SIZE": None,
"AZURE_SEARCH_SERVICE_ENDPOINT": None,
"AZURE_BLOB_STORAGE_ENDPOINT": None
"AZURE_BLOB_STORAGE_ENDPOINT": None,
"IS_GOV_CLOUD_DEPLOYMENT": None
}

str_to_bool = {'true': True, 'false': False}

for key, value in ENV.items():
new_value = os.getenv(key)
if new_value is not None:
Expand All @@ -70,8 +73,12 @@
raise ValueError(f"Environment variable {key} not set")

search_creds = AzureKeyCredential(ENV["AZURE_SEARCH_SERVICE_KEY"])

openai.api_base = "https://" + ENV["AZURE_OPENAI_SERVICE"] + ".openai.azure.com/"

if str_to_bool.get(ENV["IS_GOV_CLOUD_DEPLOYMENT"].lower()):
openai.api_base = "https://" + ENV["AZURE_OPENAI_SERVICE"] + ".openai.azure.us/"
else:
openai.api_base = "https://" + ENV["AZURE_OPENAI_SERVICE"] + ".openai.azure.com/"

openai.api_type = "azure"
openai.api_key = ENV["AZURE_OPENAI_SERVICE_KEY"]
openai.api_version = "2023-06-01-preview"
Expand Down
2 changes: 1 addition & 1 deletion app/enrichment/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#### Any version change made here should also be made and tested for the webapp backend and function apps in /functions and /app/backend

sentence-transformers == 2.2.2
fastapi == 0.103.2
fastapi == 0.109.1
fastapi-utils == 0.2.1
uvicorn == 0.23.2
azure-storage-queue == 12.6.0
Expand Down
6 changes: 6 additions & 0 deletions docs/deployment/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ The output here should show that you're logged into the intended Azure subscript
az account list
```

If you're a part of multiple tenants, ensure you're in the right tenant by setting the tenantID

``` bash
az login --tenant tenantID
```

From this output, grab the Subscription ID of the subscription you intend to deploy to and run:

``` bash
Expand Down
16 changes: 11 additions & 5 deletions docs/deployment/enable_sovereign_deployment.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Enable Sovereign Region Deployment

Follow these steps to enable a split deployment. All resources outside of AOAI will be deployed in an Sovereign region.
Follow these steps to enable a Sovereign region deployment. If you need access to AOAI in a UsGov region please fill out this form https://aka.ms/AOAIgovaccess.

Only Sovereign regions supported today are **US Gov**.
Only Sovereign regions / models supported are listed here: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#azure-government-regions

## Setup the environment

Expand All @@ -14,12 +14,18 @@ To enable a Sovereign region deployment, you need to update the local.env file w
export LOCATION="usgovvirginia"
```

or

```bash
export LOCATION="usgovvarizona"
```

2. Set **IS_USGOV_DEPLOYMENT** parameter to `true`

3. Set **USE_EXISTING_AOAI** parameter to `true`
3. Set **USE_EXISTING_AOAI** parameter to `true` if you have a existing AOAI instance deployed. If you want to create Azure Open AI resource during deployment then set this parameter to `false`

4. Set the following parameters based on your AOAI deployment:
*You can find these values from https://oai.azure.com/portal via the Deployments URL.*
4. If **USE_EXISTING_AOAI** is set to `true` then set the following parameters based on your AOAI deployment:
*You can find these values from https://aoai.azure.us/portal via the Deployments URL.*

```bash
export AZURE_OPENAI_CHATGPT_MODEL_NAME="gpt-35-turbo-16k"
Expand Down
4 changes: 2 additions & 2 deletions functions/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ azure-storage-queue == 12.6.0
nltk == 3.8.1
tenacity == 8.2.3
azure-ai-vision == 0.15.1b1
unstructured[csv,doc,docx,email,html,md,msg,ppt,pptx,text,xlsx,xml] == 0.10.27
unstructured[csv,doc,docx,email,html,md,msg,ppt,pptx,text,xlsx,xml] == 0.12.5
pyoo == 1.4
azure-search-documents == 11.4.0b11

beautifulsoup4 == 4.12.2
Loading

0 comments on commit a45eb51

Please sign in to comment.