Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.azure
next-steps.md
.env
.DS_Store
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This repository showcases the power of agentic flow with llama index leveraging
- [Architecture Diagram](#architecture-Diagram)
- [Solution Accelerator Deployment](#solution-accelerator-deployment)
- [Tear Down](#tear-down)
- [Development Methods](#development-methods)

## Key Features
Retail solution accelerator provides the following features:
Expand All @@ -15,11 +14,13 @@ Retail solution accelerator provides the following features:
- Debug panel using Arize Phoenix tracing for agent triggers and tracking

## Architecture Diagram
![AZURE ARCHITECTURE](https://github.com/user-attachments/assets/f3ca0e0d-0c93-4c0f-be5d-958eace3a138)
![AZURE ARCHITECTURE](./docs/images/arch-diagram.png)

## Solution Accelerator Deployment

### CloudShell
This solution is designed to be deployable via CloudShell. If you prefer to deploy from your local development machine, please follow the steps below.

## Solution Accelerator Deployment
### Prerequisites
The following serve as prerequisites for deployment of this solution:
1. [Azure Developer Cli](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd?tabs=winget-windows%2Cbrew-mac%2Cscript-linux&pivots=os-linux)
Expand All @@ -36,8 +37,8 @@ These modules and best practices will be finalized and implemented soon.
### Clone Repository
Clone the repository. Once done, navigate to the repository
```sh
git clone https://github.com/EmumbaOrg/retail-solution-accelerator.git
cd retail-solution-accelerator
git clone https://github.com/Azure-Samples/postgres-agentic-shop.git
cd postgres-agentic-shop
```

### Login to your Azure account
Expand All @@ -61,11 +62,6 @@ azd init
```

### Grant permissions to azd hooks scripts
If you are deploying the solution on linux OS, grant the following permissions to `predeploy.sh`
```sh
cd azd-hooks
sudo chmod +x predeploy.sh
```
If you are deploying the solution on Windows OS, grant the following permissions to the current session to execute `pwsh` scripts
```sh
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Expand All @@ -76,15 +72,15 @@ pwsh -NoProfile -Command "Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolic
```

### Solution Deployment
Run the following command to provision the resources.
Run the following command to provision the resources.
```sh
azd up
```

Once this command is executed, the prompt asks for subscription for deployment, two locations i.e. one for location of solution accelerator resources and other for location of Azure OpenAI models and the resource group to create.
Once this command is executed, the prompt asks for subscription for deployment, two locations i.e. one for location of solution accelerator resources and other for location of Azure OpenAI models and the resource group to create.
Make sure that you have enough Azure OpenAI model quota in the region of deployment. The Azure OpenAI quota required for this solution is listed below. This configuration can be changed from `main.parameters.json` file in `infra` directory using following parameters. The deployment might take some time and will provide progress of deployment in terminal as well as on Azure Portal.
- **GPT-4o:** 150K TPM - `AZURE_OPENAI_CHAT_DEPLOYMENT_CAPACITY`
- **text-embedding-ada-002:** 120K TPM - `AZURE_OPENAI_EMBED_DEPLOYMENT_CAPACITY`
- **GPT-4o:** 140K TPM - `AZURE_OPENAI_CHAT_DEPLOYMENT_CAPACITY`
- **text-embedding-ada-002:** 60K TPM - `AZURE_OPENAI_EMBED_DEPLOYMENT_CAPACITY`

### Troubleshooting
1. Troubleshooting guide for `azd cli` is [here](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/troubleshoot?tabs=Browser).
Expand All @@ -93,7 +89,7 @@ Make sure that you have enough Azure OpenAI model quota in the region of deploym
4. When `The resource entity provisioning state is not terminal` error occurs, restart the deployment using `azd up` command.

## Tear Down
To destroy all the resources that have been created in the step above as well as remove any accounts deployed by the solution accelerator, use the following command:
To destroy all the resources that have been created in the step above as well as remove any accounts deployed by the solution accelerator, use the following command:
```sh
azd down --purge
```
Expand Down
102 changes: 102 additions & 0 deletions README_ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# AgenticShop:AIエージェント時代の刷新されたショッピング体験
このリポジトリは、マルチエージェントワークフローの機能を活用して、エージェントフローの力をLlamaindexで示しています。このソリューションは、電子ガジェットの購入に興味がある個々の強化されたショッピングを体験するために開発されました。これは、`azure cli` を使用した、テストとデプロイが簡単なワンクリックソリューションです。完全なレイアウトについては、アーキテクチャ図を参照してください:

- [主要な機能](#key-features)
- [アーキテクチャ図](#architecture-Diagram)
- [ソリューションアクセラレータのデプロイメント](#solution-accelerator-deployment)
- [削除](#tear-down)

## Key Features
小売ソリューションアクセラレータは、以下の機能を提供します:
- ユーザープロファイルに基づいたパーソナライズされた製品詳細
- ユーザーエクスペリエンスの向上
- マルチエージェントワークフローにより、複数のタスクをシームレスに処理
- エージェントトリガーとトラッキングのためのArize Phoenixトレーシングを使用したデバッグパネル

## Architecture Diagram
![AZURE ARCHITECTURE](./docs/images/arch-diagram.png)

## Solution Accelerator Deployment

### CloudShell
このソリューションは、CloudShell経由でデプロイ可能に設計されています。ローカルの開発マシンからデプロイすることを希望する場合は、以下の手順に従ってください。

### 前提条件
このソリューションのデプロイメントには、以下が前提条件となります:
1. [Azure Developer Cli](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd?tabs=winget-windows%2Cbrew-mac%2Cscript-linux&pivots=os-linux)
2. [Azure Cli](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli)
3. [Azure Cli extension](https://learn.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview) `rdbms-connect`
4. アクティブなサブスクリプションを持つAzureアカウント。
5. [Python 3.8+](https://www.python.org/downloads/)
6. [Powershell Core](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5) (Windowsユーザーのみ)

### デプロイメント手順
注:このインフラストラクチャのバージョンは、動作するソリューションを正常にデプロイします。ただし、Azure Key Vault、Azure App Configなどの一部のモジュールやベストプラクティスはまだ進行中です。
これらのモジュールとベストプラクティスは近日中に最終化され、実装される予定です。

### リポジトリのクローン
リポジトリをクローンします。完了したら、リポジトリに移動します
```sh
git clone https://github.com/Azure-Samples/postgres-agentic-shop.git
cd postgres-agentic-shop
```

### Azureアカウントへのログイン
`azure cli`にログインするには、次のコマンドを使用します:
```sh
az login
```

`azure developer cli`にログインするには、このコマンドを使用します:
```sh
azd auth login
```

上記のコマンドが失敗した場合は、次のフラグを使用します:
```sh
azd auth login --use-device-code
```

### 新しいazure開発者環境の作成
新しい`azd`環境を初期化し、作成します。`azd`環境に名前を付けてください
```sh
azd init
```

### azdフックスクリプトへの権限付与
Windows OSでソリューションをデプロイする場合は、現在のセッションに`pwsh`スクリプトを実行するための次の権限を付与します
```sh
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
```

Windows OS上のunix-like環境(例:cygwin、minGW)をデプロイする場合は、現在のセッションに`pwsh`スクリプトを実行するための次の権限を付与します
```sh
pwsh -NoProfile -Command "Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass"
```

### ソリューションのデプロイメント
リソースをプロビジョニングするために、次のコマンドを実行します。
```sh
azd up
```

このコマンドを実行すると、プロンプトがデプロイメントのサブスクリプション、ソリューションアクセラレータリソースの場所とAzure OpenAIモデルの場所、および作成するリソースグループを尋ねます。デプロイメントの地域で十分なAzure OpenAIモデルのクォータがあることを確認してください。このソリューションに必要なAzure OpenAIのクォータは以下に記載されています。この設定は、`infra`ディレクトリの`main.parameters.json`ファイルを使用して以下のパラメータで変更できます。デプロイメントには時間がかかる場合があり、進行状況はターミナルとAzure Portalの両方で提供されます。
- **GPT-4o:** 140K TPM - `AZURE_OPENAI_CHAT_DEPLOYMENT_CAPACITY`
- **text-embedding-ada-002:** 60K TPM - `AZURE_OPENAI_EMBED_DEPLOYMENT_CAPACITY`

### トラブルシューティング
1. `azd cli`のトラブルシューティングガイドは[こちら](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/troubleshoot?tabs=Browser)です。
2. 初期化または新しいenvの作成時にサポートされていない文字が使用されると、検証エラーが発生します。
3. ユーザーが`azd cli`を実行する際に適切な権限を持っていないと、スコープエラーが発生します。ユーザーの権限をサブスクリプションレベルに更新してください。
4. `リソースエンティティのプロビジョニング状態が端末ではない`エラーが発生した場合、`azd up`コマンドを使用してデプロイメントを再起動します。

## Tear Down
上記のステップで作成されたすべてのリソースを破棄し、ソリューションアクセラレータによってデプロイされたアカウントを削除するには、以下のコマンドを使用します:
```sh
azd down --purge
```
purgeフラグはすべてのアカウントを永久に削除します。

### パーソナライゼーションワークフロー
以下は、その可視化ツールを介して生成されたLlamaIndexワークフローです:
![スクリーンショット](./workflow.png)
11 changes: 6 additions & 5 deletions azd-hooks/predeploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/sh

RESOURCE_GROUP=$(azd env get-value AZURE_RESOURCE_GROUP)
POSTGRES_NAME=$(azd env get-value POSTGRES_NAME)
POSTGRES_USERNAME=$(azd env get-value POSTGRES_USERNAME)
POSTGRES_DATABASE=$(azd env get-value POSTGRES_DATABASE)
POSTGRES_PASSWORD=$(azd env get-value POSTGRES_PASSWORD)

az postgres flexible-server execute \
--admin-user "$POSTGRES_USERNAME" \
--admin-password "$POSTGRES_PASSWORD" \
--name "$POSTGRES_NAME" \
--database-name "$POSTGRES_DATABASE" \
--file-path "../scripts/create-extension.sql"
--admin-user "$POSTGRES_USERNAME" \
--admin-password "$POSTGRES_PASSWORD" \
--name "$POSTGRES_NAME" \
--database-name "$POSTGRES_DATABASE" \
--file-path "../scripts/create-extension.sql"
120 changes: 60 additions & 60 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,72 @@
name: retail-solution-accelerator
description: Agentic Shop
metadata:
template: retail-solution-accelerator@0.0.1
template: retail-solution-accelerator@0.0.1
requiredVersions:
azd: ">= 1.15.0"
azd: ">= 1.14.0"

workflows:
up:
steps:
- azd: provision
- azd: deploy
- azd: deploy

infra:
bicep: ./infra/main.bicep
infra:
bicep: ./infra/main.bicep

services:
backend:
project: ./backend
language: py
module: backend
host: containerapp
docker:
remoteBuild: true
hooks:
predeploy:
posix:
# linux/macOS hook
shell: sh
interactive: true
continueOnError: false
run: ../azd-hooks/predeploy.sh
windows:
# Windows hook
shell: pwsh
interactive: true
continueOnError: false
run: ../azd-hooks/predeploy.ps1
frontend:
project: ./frontend
language: ts
module: frontend
host: containerapp
docker:
context: ./
registry: ${AZURE_CONTAINER_REGISTRY_ENDPOINT}
path: ./Dockerfile
remoteBuild: true
hooks:
prebuild:
posix: # run on linux/macOS
shell: sh
interactive: true
continueOnError: false
run: |
BE_APP_ENDPOINT=$(azd env get-value SERVICE_BACKEND_URI)
echo VITE_BE_APP_ENDPOINT=\"$BE_APP_ENDPOINT/\" >> ./.env.local
windows:
shell: pwsh # run on Windows
interactive: true
continueOnError: false
run: |
$beAppEndpoint = azd env get-value SERVICE_BACKEND_URI
$envLine = "VITE_BE_APP_ENDPOINT=`"$beAppEndpoint/`""
Add-Content -Path ".\.env.local" -Value $envLine
arize:
project: ./arize-phoenix
language: py
module: arize
host: containerapp
docker:
remoteBuild: true
backend:
project: ./backend
language: py
module: backend
host: containerapp
docker:
remoteBuild: true
hooks:
predeploy:
posix:
# linux/macOS hook
shell: sh
interactive: true
continueOnError: false
run: chmod +x ../azd-hooks/predeploy.sh && ../azd-hooks/predeploy.sh
windows:
# Windows hook
shell: pwsh
interactive: true
continueOnError: false
run: ../azd-hooks/predeploy.ps1
frontend:
project: ./frontend
language: ts
module: frontend
host: containerapp
docker:
context: ./
registry: ${AZURE_CONTAINER_REGISTRY_ENDPOINT}
path: ./Dockerfile
remoteBuild: true
hooks:
prebuild:
posix: # run on linux/macOS
shell: sh
interactive: true
continueOnError: false
run: |
BE_APP_ENDPOINT=$(azd env get-value SERVICE_BACKEND_URI)
echo VITE_BE_APP_ENDPOINT=\"$BE_APP_ENDPOINT/\" >> ./.env.local
windows:
shell: pwsh # run on Windows
interactive: true
continueOnError: false
run: |
$beAppEndpoint = azd env get-value SERVICE_BACKEND_URI
$envLine = "VITE_BE_APP_ENDPOINT=`"$beAppEndpoint/`""
Add-Content -Path ".\.env.local" -Value $envLine
arize:
project: ./arize-phoenix
language: py
module: arize
host: containerapp
docker:
remoteBuild: true
2 changes: 1 addition & 1 deletion backend/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ COPY poetry.lock pyproject.toml ./
RUN poetry install --no-interaction --no-ansi
ADD . ./

EXPOSE 8000
EXPOSE 80
2 changes: 1 addition & 1 deletion backend/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
// "postCreateCommand": "./.devcontainer/setupPreCommit.sh",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8000],
"forwardPorts": [80],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
Expand Down
2 changes: 1 addition & 1 deletion backend/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"args": [
"src.main:app",
"--port",
"8000",
"80",
"--log-config",
"logging_config.yaml",
"--reload"
Expand Down
3 changes: 2 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ COPY poetry.lock pyproject.toml ./
RUN poetry install --no-interaction --no-ansi
ADD . ./

EXPOSE 8000
EXPOSE 80

RUN chmod +x ./startup.sh
CMD ["./startup.sh"]

4 changes: 2 additions & 2 deletions backend/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ if [ "$ENV" = "prod" ]; then
echo "Starting in production mode..."
uvicorn src.main:app \
--host 0.0.0.0 \
--port 8000 \
--port 80 \
--access-log \
--log-config logging_config.yaml \
--workers 8
else
echo "Starting in development mode..."
uvicorn src.main:app \
--host 0.0.0.0 \
--port 8000 \
--port 80 \
--reload \
--access-log \
--log-config logging_config.yaml
Expand Down
Binary file added docs/images/arch-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading