Skip to content

Commit

Permalink
Upload tools to Shinkai Store
Browse files Browse the repository at this point in the history
  • Loading branch information
guillevalin committed Jan 27, 2025
1 parent a54d9d3 commit d94ab5c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 58 deletions.
60 changes: 5 additions & 55 deletions .github/workflows/build_tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,14 @@ on:
required: true
type: boolean
default: true
have_run_tests:
description: 'Have you run tests successfully?'
required: true
type: boolean
default: false

jobs:
run_tests:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal

- name: Install b3sum
run: cargo install b3sum

- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl jq zip unzip coreutils
- name: Run node in background
id: run_node
env:
INITIAL_AGENT_NAMES: ${{ secrets.INITIAL_AGENT_NAMES }}
INITIAL_AGENT_URLS: ${{ secrets.INITIAL_AGENT_URLS }}
INITIAL_AGENT_MODELS: ${{ secrets.INITIAL_AGENT_MODELS }}
INITIAL_AGENT_API_KEYS: ${{ secrets.INITIAL_AGENT_API_KEYS }}
API_V2_KEY: ${{ secrets.API_V2_KEY }}
EMBEDDINGS_SERVER_URL: ${{ secrets.EMBEDDINGS_SERVER_URL }}
SHINKAI_NODE_ADDR: "http://localhost:9550"
BEARER_TOKEN: ${{ secrets.API_V2_KEY }}
INITIALIZATION_DATA: ${{ secrets.INITIALIZATION_DATA }}
DOWNLOAD_PREFIX: ${{ inputs.use_dev_prefix && 'https://download.shinkai.com/dev-tools-' || 'https://download.shinkai.com/tools-' }}${{ inputs.node_version }}
SKIP_IMPORT_FROM_DIRECTORY: true
SHINKAI_STORE_ADDR: "https://shinkai-store-302883622007.us-central1.run.app"
SHINKAI_STORE_TOKEN: ${{ secrets.SHINKAI_STORE_TOKEN }}
USE_DOCKER: true
SHINKAI_NODE_IMAGE: "dcsparkdevops/shinkai-node:${{ inputs.node_version }}"
run: |
./scripts/run_node.sh &
timeout 60 bash -c 'until curl -s --location "$SHINKAI_NODE_ADDR/v2/health_check" | jq -e ".status == \"ok\"" > /dev/null; do sleep 1; done'
curl --location "$SHINKAI_NODE_ADDR/v2/initial_registration" \
--header 'Content-Type: application/json; charset=utf-8' \
--data "$INITIALIZATION_DATA"
rm -rf ./packages && mkdir ./packages
deno test --allow-read --allow-write --allow-env --allow-net --allow-run scripts/
rm -rf ./shinkai-node/storage
build_tools:
needs: run_tests
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
1 change: 0 additions & 1 deletion scripts/build_tools/save_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ export async function processToolsDirectory(): Promise<DirectoryEntry[]> {
toolFile,
file: `${Deno.env.get("DOWNLOAD_PREFIX")}/${toolName.toLowerCase().replace(/[^a-z0-9_.-]/g, '_')}.zip`,
price_usd: metadata.price_usd || 0.00,
stripeProductId: "prod_P000000000000",
// categoryId: "cat_P000000000000", // to-do: categories not implemented yet.
dependencies,
});
Expand Down
22 changes: 20 additions & 2 deletions scripts/build_tools/upload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DirectoryEntry } from "./interfaces.ts";

// Upload tools to Shinkai Store
export async function uploadTools(tools: DirectoryEntry[]) {
const store_addr = Deno.env.get("SHINKAI_STORE_ADDR");
const store_token = Deno.env.get("SHINKAI_STORE_TOKEN");
Expand Down Expand Up @@ -45,8 +46,25 @@ export async function uploadTools(tools: DirectoryEntry[]) {
}
}

console.log(`Upload to Store Response (${response.status}): ${await response.text()}`);
if (response.status !== 200) console.log(`Request body failed: ${JSON.stringify(store_entry, null, 2)}`);
if (response.status !== 200) {
console.log(`Upload to Store Response (${response.status}): ${await response.text()}`);
console.log(`Request body failed: ${JSON.stringify(store_entry, null, 2)}`);
}
if (response.status === 200) {
console.log(`Created/Updated ${entry.routerKey} to Shinkai Store`);
if (entry.isDefault) {
const default_tool = await fetch(`${store_addr}/store/defaults/${entry.routerKey}`, {
method: "POST",
headers: {
"Authorization": `Bearer ${store_token}`,
},
});
if (default_tool.status !== 200) {
console.log(`Set default tool for ${entry.routerKey}: ${default_tool.status}`);
console.log(await default_tool.text());
}
}
}
}
}

0 comments on commit d94ab5c

Please sign in to comment.