Skip to content

Commit

Permalink
Move acme-assist to apps folder (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
dingmeng-xue authored Aug 11, 2023
1 parent b34c8e4 commit a147d83
Show file tree
Hide file tree
Showing 93 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ azure/setup-env-variables.sh
azure/setup-db-env-variables.sh
azure/setup-sso-variables.sh
azure/setup-env-variables-keyvault.sh
ai/setup-ai-env-variables.sh
azure/setup-ai-env-variables.sh
redis.json
ad.json
sso.json
Expand Down
5 changes: 0 additions & 5 deletions ai/prepare_data.sh

This file was deleted.

1 change: 1 addition & 0 deletions ai/acme-assist/.gitignore → apps/acme-assist/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
HELP.md
target/
*.sql
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
Expand Down
21 changes: 10 additions & 11 deletions ai/README.md → apps/acme-assist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@


## Prepare the Environment Variables
1. Please navigate to the root folder of this project.
1. Run `cp azure/setup-env-variables-template.sh azure/setup-env-variables.sh` and update the values in `setup-env-variables.sh` with your own values.
1. Run `cp ai/setup-ai-env-variables-template.sh ai/setup-ai-env-variables.sh` and update the values in `setup-ai-env-variables.sh` with your own values.
1. Run `cp azure/setup-ai-env-variables-template.sh azure/setup-ai-env-variables.sh` and update the values in `setup-ai-env-variables.sh` with your own values.


## Prepare Azure OpenAI Service
Expand All @@ -29,7 +30,7 @@
--custom-domain ${OPENAI_RESOURCE_NAME}
```

1. Create the model deployments for `text-embedding-ada-002` and `gpt-35-turbo` in your Azure OpenAI service.
1. Create the model deployments for `text-embedding-ada-002` and `gpt-35-turbo-16k` in your Azure OpenAI service.
```bash
az cognitiveservices account deployment create \
-g ${RESOURCE_GROUP} \
Expand All @@ -53,18 +54,17 @@

Before building the `assist-service` service, we need to preprocess the data into the vector store. The vector store is a file that contains the vector representation of each product description. There's already a pre-built file `vector_store.json` in the repo so you can skip this step. If you want to build the vector store yourself, please run the following commands:
```bash
cd ai && source ./setup-ai-env-variables.sh
cd acme-assist
./preprocess.sh ../data/bikes.json,../data/accessories.json src/main/resources/vector_store.json
source ./azure/setup-ai-env-variables.sh
cd apps\acme-assist
./preprocess.sh data/bikes.json,data/accessories.json src/main/resources/vector_store.json
```


## Build and deploy to Azure Spring Apps

1. Prepare the new sample data and images:
```bash
cd ai && ./prepare_data.sh
cd ..
./apps/acme-assist/prepare_data.sh
```.
1. Redeploy `catalog-service` with the new resources:
```bash
Expand All @@ -76,15 +76,14 @@ cd acme-assist
```
1. Deploy the new ai service `assist-service` :
```bash
cd ai
source ./setup-ai-env-variables.sh
source ./azure/setup-ai-env-variables.sh
az spring app create --name ${AI_APP} --instance-count 1 --memory 1Gi
az spring gateway route-config create \
--name ${AI_APP} \
--app-name ${AI_APP} \
--routes-file assist-service.json
--routes-file azure/routes/assist-service.json
az spring app deploy --name ${AI_APP} \
--source-path acme-assist \
--source-path apps/acme-assist \
--build-env BP_JVM_VERSION=17 \
--env AZURE_OPENAI_ENDPOINT=${AZURE_OPENAI_ENDPOINT} AZURE_OPENAI_APIKEY=${AZURE_OPENAI_APIKEY} AZURE_OPENAI_CHATDEPLOYMENTID=${AZURE_OPENAI_CHATDEPLOYMENTID} AZURE_OPENAI_EMBEDDINGDEPLOYMENTID=${AZURE_OPENAI_EMBEDDINGDEPLOYMENTID}
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
6 changes: 3 additions & 3 deletions ai/generate_db_migration.py → apps/acme-assist/generate_db_migration.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def single_quote(raw):
return "'" + raw.replace("'", "''") + "'"

def generate_sql(category):
data=json.load(open('data/' + category + '.json','r+'))
data=json.load(open(category,'r+'))

sql = 'INSERT INTO CATALOG (id, description, image_url1, image_url2, image_url3, name, price, short_description, tags)\nVALUES'

Expand All @@ -34,5 +34,5 @@ def generate_sql(category):
print(sql)

if __name__ == '__main__':
generate_sql('bikes')
generate_sql('accessories')
generate_sql('data/bikes.json')
generate_sql('data/accessories.json')
File renamed without changes.
7 changes: 7 additions & 0 deletions apps/acme-assist/prepare_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
INITIAL_WORKING_DIRECTORY=$(pwd)
cd "$(dirname "$0")"
python ./generate_db_migration.py > ./V1_1__insert_products.sql
mv ./*.sql ../acme-catalog/src/main/resources/db/migration
cp ./data/images/* ../acme-catalog/src/main/resources/static/
cd $INITIAL_WORKING_DIRECTORY
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a147d83

Please sign in to comment.