Skip to content

Commit

Permalink
Merge pull request #33 from arcmindai/dev
Browse files Browse the repository at this point in the history
dfx upgrade and refactoring
  • Loading branch information
kinwo committed May 5, 2024
2 parents 292dfa1 + f6c13a3 commit 4965ffe
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/assign-owner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install DFX
uses: dfinity/setup-dfx@main
with:
dfx-version: '0.15.2'
dfx-version: '0.19.0'
- name: Add DFX identity and wallets
run: ./scripts/add-ic-identity.sh
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install DFX
uses: dfinity/setup-dfx@main
with:
dfx-version: '0.15.2'
dfx-version: '0.19.0'
- name: Fetch git submodule arcmindvector
run: git submodule update --init --recursive
- name: Add DFX identity and wallets
Expand All @@ -42,7 +42,7 @@ jobs:
BEAMFI_PRINCIPAL: ${{ secrets.BEAMFI_PRINCIPAL }}
BILLING_KEY: ${{ secrets.BILLING_KEY }}
BATTERY_API_KEY: ${{ secrets.BATTERY_API_KEY }}
BATTERY_PRINCIAL: ${{ secrets.BATTERY_PRINCIAL }}
BATTERY_PRINCIPAL: ${{ secrets.BATTERY_PRINCIPAL }}
- name: Debug URL
run: echo https://completedeploy-4gbndkvjta-uc.a.run.app?apiKey=${{ secrets.FB_API_KEY }}&canisterId=${{ steps.provision.outputs.controller_principal }}
- name: Call Firebase Function /complete_deploy and assert HTTP status 200
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/local-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install DFX
uses: dfinity/setup-dfx@main
with:
dfx-version: '0.15.2'
dfx-version: '0.19.0'
- name: Add DFX identity and wallets
run: ./scripts/add-ic-identity.sh
env:
Expand All @@ -45,6 +45,6 @@ jobs:
BEAMFI_PRINCIPAL: ${{ secrets.BEAMFI_PRINCIPAL }}
BILLING_KEY: ${{ secrets.BILLING_KEY }}
BATTERY_API_KEY: ${{ secrets.BATTERY_API_KEY }}
BATTERY_PRINCIAL: ${{ secrets.BATTERY_PRINCIAL }}
BATTERY_PRINCIPAL: ${{ secrets.BATTERY_PRINCIPAL }}
- name: Show Controller Principal
run: echo ${{ steps.provision.outputs.controller_principal }}
37 changes: 0 additions & 37 deletions .github/workflows/old-prod-update.yml

This file was deleted.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"src/arcmindai_tools",
"src/cycles_battery"
]
resolver = "1"

[profile.release]
lto = true
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ awk 'NF {sub(/\r/, ""); printf "%s\\r\\n",$0;}' ~/.config/dfx/identity/default/i
cat ~/.config/dfx/identity/default/wallets.json
```

### Update arcmindvector Git submodule to the latest

- make sure arcmindvector Git project has the latest changes pushed to the main branch
- update the submodule in the parent project `arcmindai`:

```
git submodule update --remote
```

## License

See the [License](LICENSE) file for license rights and limitations (MIT).
Expand Down
6 changes: 3 additions & 3 deletions scripts/deploy_brain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GPT_MODEL=gpt-4

# Deploy brain canister
CONTROLLER_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_controller)
BATTERY_PRINCIAL=$(dfx canister --network $IC_NETWORK id cycles_battery)
BATTERY_PRINCIPAL=$(dfx canister --network $IC_NETWORK id cycles_battery)

echo Deploying brain canister with owner=$CONTROLLER_PRINCIPAL, GPT model=$GPT_MODEL and OPENAI_API_KEY=$OPENAI_API_KEY, BATTERY_PRINCIAL=$BATTERY_PRINCIAL, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_brain --argument "(opt principal \"$CONTROLLER_PRINCIPAL\", \"$OPENAI_API_KEY\", \"$GPT_MODEL\", opt \"$BATTERY_API_KEY\", opt principal \"$BATTERY_PRINCIAL\")"
echo Deploying brain canister with owner=$CONTROLLER_PRINCIPAL, GPT model=$GPT_MODEL and OPENAI_API_KEY=$OPENAI_API_KEY, BATTERY_PRINCIPAL=$BATTERY_PRINCIPAL, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_brain --argument "(opt principal \"$CONTROLLER_PRINCIPAL\", \"$OPENAI_API_KEY\", \"$GPT_MODEL\", opt \"$BATTERY_API_KEY\", opt principal \"$BATTERY_PRINCIPAL\")"
8 changes: 3 additions & 5 deletions scripts/deploy_controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ IC_NETWORK=${IC_NETWORK:-local}

BRAIN_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_brain)
TOOLS_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_tools)
BATTERY_PRINCIAL=$(dfx canister --network $IC_NETWORK id cycles_battery)
BATTERY_PRINCIPAL=$(dfx canister --network $IC_NETWORK id cycles_battery)

BROWSE_WEBSITE_GPT_MODEL=gpt-3.5-turbo-1106

# Deploy controller canister
# echo Deploying controller canister with owner=$OWNER_PRINCIPAL, brain=$BRAIN_PRINCIPAL, browse_website_gpt_model=$BROWSE_WEBSITE_GPT_MODEL, tools=$TOOLS_PRINCIPAL, VECTOR_PRINCIPAL=$VECTOR_PRINCIPAL, BEAMFI_PRINCIPAL=$BEAMFI_PRINCIPAL, BATTERY_PRINCIAL=$BATTERY_PRINCIAL, BILLING_KEY=$BILLING_KEY, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
# dfx deploy --network $IC_NETWORK --mode reinstall arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt principal \"$BATTERY_PRINCIAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\", opt \"$BATTERY_API_KEY\")"
echo Deploying controller canister BATTERY_PRINCIAL=$BATTERY_PRINCIAL, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt principal \"$BATTERY_PRINCIAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\", opt \"$BATTERY_API_KEY\")"
echo Deploying controller canister BATTERY_PRINCIPAL=$BATTERY_PRINCIPAL, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt principal \"$BATTERY_PRINCIPAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\", opt \"$BATTERY_API_KEY\")"
6 changes: 3 additions & 3 deletions scripts/deploy_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ fi
IC_NETWORK=${IC_NETWORK:-local}

CONTROLLER_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_controller)
BATTERY_PRINCIAL=$(dfx canister --network $IC_NETWORK id cycles_battery)
BATTERY_PRINCIPAL=$(dfx canister --network $IC_NETWORK id cycles_battery)

# Deploy tools canister
echo Deploying tools canister with owner=$CONTROLLER_PRINCIPAL on $IC_NETWORK, GOOGLE_API_KEY=$GOOGLE_API_KEY, GOOGLE_SEARCH_ENGINE_ID=$GOOGLE_SEARCH_ENGINE_ID, BATTERY_PRINCIAL=$BATTERY_PRINCIAL, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_tools --argument "(opt principal \"$CONTROLLER_PRINCIPAL\", \"$GOOGLE_API_KEY\", \"$GOOGLE_SEARCH_ENGINE_ID\", opt \"$BATTERY_API_KEY\", opt principal \"$BATTERY_PRINCIAL\" )"
echo Deploying tools canister with owner=$CONTROLLER_PRINCIPAL on $IC_NETWORK, GOOGLE_API_KEY=$GOOGLE_API_KEY, GOOGLE_SEARCH_ENGINE_ID=$GOOGLE_SEARCH_ENGINE_ID, BATTERY_PRINCIPAL=$BATTERY_PRINCIPAL, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_tools --argument "(opt principal \"$CONTROLLER_PRINCIPAL\", \"$GOOGLE_API_KEY\", \"$GOOGLE_SEARCH_ENGINE_ID\", opt \"$BATTERY_API_KEY\", opt principal \"$BATTERY_PRINCIPAL\" )"

echo Tools Owner:
dfx canister --network $IC_NETWORK call arcmindai_tools get_owner
16 changes: 8 additions & 8 deletions scripts/provision-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ if [[ -z "${BATTERY_API_KEY}" ]]; then
exit 1
fi

if [[ -z "${BATTERY_PRINCIAL}" ]]; then
echo "BATTERY_PRINCIAL is unset."
if [[ -z "${BATTERY_PRINCIPAL}" ]]; then
echo "BATTERY_PRINCIPAL is unset."
exit 1
fi

Expand All @@ -64,26 +64,26 @@ cd ../
pwd

# Deploy brain canister
echo Deploying brain canister with owner $CONTROLLER_PRINCIPAL, GPT model $GPT_MODEL, openai_api_key $OPENAI_API_KEY, BATTERY_API_KEY=$BATTERY_API_KEY, BATTERY_PRINCIAL=$BATTERY_PRINCIAL on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_brain --argument "(opt principal \"$CONTROLLER_PRINCIPAL\", \"$OPENAI_API_KEY\", \"$GPT_MODEL\", opt \"$BATTERY_API_KEY\", opt principal \"$BATTERY_PRINCIAL\")"
echo Deploying brain canister with owner $CONTROLLER_PRINCIPAL, GPT model $GPT_MODEL, openai_api_key $OPENAI_API_KEY, BATTERY_API_KEY=$BATTERY_API_KEY, BATTERY_PRINCIPAL=$BATTERY_PRINCIPAL on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_brain --argument "(opt principal \"$CONTROLLER_PRINCIPAL\", \"$OPENAI_API_KEY\", \"$GPT_MODEL\", opt \"$BATTERY_API_KEY\", opt principal \"$BATTERY_PRINCIPAL\")"

echo Brain Owner:
dfx canister --network $IC_NETWORK call arcmindai_brain get_owner

BRAIN_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_brain)

# Deploy tools canister
echo Deploying tools canister with owner $CONTROLLER_PRINCIPAL on $IC_NETWORK with GOOGLE_API_KEY=$GOOGLE_API_KEY, GOOGLE_SEARCH_ENGINE_ID=$GOOGLE_SEARCH_ENGINE_ID, BATTERY_API_KEY=$BATTERY_API_KEY, BATTERY_PRINCIAL=$BATTERY_PRINCIAL on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_tools --argument "(opt principal \"$CONTROLLER_PRINCIPAL\", \"$GOOGLE_API_KEY\", \"$GOOGLE_SEARCH_ENGINE_ID\", opt \"$BATTERY_API_KEY\", opt principal \"$BATTERY_PRINCIAL\")"
echo Deploying tools canister with owner $CONTROLLER_PRINCIPAL on $IC_NETWORK with GOOGLE_API_KEY=$GOOGLE_API_KEY, GOOGLE_SEARCH_ENGINE_ID=$GOOGLE_SEARCH_ENGINE_ID, BATTERY_API_KEY=$BATTERY_API_KEY, BATTERY_PRINCIPAL=$BATTERY_PRINCIPAL on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_tools --argument "(opt principal \"$CONTROLLER_PRINCIPAL\", \"$GOOGLE_API_KEY\", \"$GOOGLE_SEARCH_ENGINE_ID\", opt \"$BATTERY_API_KEY\", opt principal \"$BATTERY_PRINCIPAL\")"

echo Tools Owner:
dfx canister --network $IC_NETWORK call arcmindai_tools get_owner

TOOLS_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_tools)

# Deploy controller canister
echo Deploying controller canister with owner=$OWNER_PRINCIPAL, brain=$BRAIN_PRINCIPAL, browse_website_gpt_model=$BROWSE_WEBSITE_GPT_MODEL, tools=$TOOLS_PRINCIPAL, VECTOR_PRINCIPAL=$VECTOR_PRINCIPAL, BEAMFI_PRINCIPAL=$BEAMFI_PRINCIPAL, BATTERY_PRINCIAL=$BATTERY_PRINCIAL, BILLING_KEY=$BILLING_KEY, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt principal \"$BATTERY_PRINCIAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\", opt \"$BATTERY_API_KEY\")"
echo Deploying controller canister with owner=$OWNER_PRINCIPAL, brain=$BRAIN_PRINCIPAL, browse_website_gpt_model=$BROWSE_WEBSITE_GPT_MODEL, tools=$TOOLS_PRINCIPAL, VECTOR_PRINCIPAL=$VECTOR_PRINCIPAL, BEAMFI_PRINCIPAL=$BEAMFI_PRINCIPAL, BATTERY_PRINCIPAL=$BATTERY_PRINCIPAL, BILLING_KEY=$BILLING_KEY, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt principal \"$BATTERY_PRINCIPAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\", opt \"$BATTERY_API_KEY\")"

echo Controller Owner:
dfx canister --network $IC_NETWORK call arcmindai_controller get_owner
Expand Down
2 changes: 2 additions & 0 deletions src/arcmindai_brain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ fn post_upgrade(
s.borrow_mut().battery_canister = battery_canister;
s.borrow_mut().battery_api_key = battery_api_key.clone();
});

start_cycles_check_timer(CYCLES_BALANCE_CHECK_MIN_INTERVAL_SECS);
}

// ---------------------- Candid declarations did file generator ----------------------
Expand Down
2 changes: 2 additions & 0 deletions src/arcmindai_tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ fn post_upgrade(
s.borrow_mut().battery_canister = battery_canister;
s.borrow_mut().battery_api_key = battery_api_key.clone();
});

start_cycles_check_timer(CYCLES_BALANCE_CHECK_MIN_INTERVAL_SECS);
}

// ---------------------- Candid declarations did file generator ----------------------
Expand Down

0 comments on commit 4965ffe

Please sign in to comment.