diff --git a/.github/workflows/ci-hypermode-functions.yml b/.github/workflows/ci-hypermode-functions.yml index 9aca7c4..6f65367 100644 --- a/.github/workflows/ci-hypermode-functions.yml +++ b/.github/workflows/ci-hypermode-functions.yml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: npm install - name: Build the project - run: npm run build:release + run: npm run build release - name: Publish GitHub artifact uses: actions/upload-artifact@v4 with: diff --git a/functions/assembly/index.ts b/functions/assembly/index.ts index bbcd458..023e565 100644 --- a/functions/assembly/index.ts +++ b/functions/assembly/index.ts @@ -1,8 +1,6 @@ -import { JSON } from "json-as"; -import { model } from "@hypermode/functions-as"; +import { model, ClassificationResult } from "@hypermode/functions-as"; -export function testClassifier(text: string): string { +export function testClassifier(text: string): ClassificationResult { const modelName = "sentiment-classifier"; - const results = model.classifyText(modelName, text); - return JSON.stringify(results); + return model.classifyText(modelName, text); } diff --git a/functions/package-lock.json b/functions/package-lock.json index c67d022..8c55694 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -1,22 +1,22 @@ { "name": "sample", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sample", - "version": "1.1.0", + "version": "1.2.0", "license": "MIT", "dependencies": { - "@hypermode/functions-as": "^0.4.0", - "json-as": "^0.8.1" + "@hypermode/functions-as": "^0.5.0", + "json-as": "^0.8.2" }, "devDependencies": { "@assemblyscript/wasi-shim": "^0.1.0", - "@typescript-eslint/eslint-plugin": "^7.4.0", - "@typescript-eslint/parser": "^7.4.0", - "assemblyscript": "^0.27.25", + "@typescript-eslint/eslint-plugin": "^7.7.0", + "@typescript-eslint/parser": "^7.7.0", + "assemblyscript": "^0.27.27", "assemblyscript-prettier": "^3.0.1", "eslint": "^8.57.0", "prettier": "^3.2.5", @@ -177,22 +177,13 @@ "dev": true }, "node_modules/@hypermode/functions-as": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@hypermode/functions-as/-/functions-as-0.4.0.tgz", - "integrity": "sha512-z5yDq3qFttZ2A5dJJLnTsxx+wAqpJlz+b4EYVQW0N+bi+I8/j2CqhxxPRxncygHRkUqDEk8T+7BkhSJue9mocA==", - "dependencies": { - "json-as": "^0.7.3", - "xid-ts": "^1.1.0" - } - }, - "node_modules/@hypermode/functions-as/node_modules/json-as": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/json-as/-/json-as-0.7.3.tgz", - "integrity": "sha512-tTM4Ehp0k6h6BIpCuMvItQxVq0SZQ5nGPrYlzwSJ9xquu2bKYPshJKKcWQsH2pGTcMe24bKUGHi0I3ZqhODQOw==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@hypermode/functions-as/-/functions-as-0.5.0.tgz", + "integrity": "sha512-huIL+lRRsDKAQR2zoEQWmyp3a/FaFrIzc1YVrs3kJxZaAEO5xSMEIAcOlkGPTf9wyV2i/uGKPd3AJ1BSseagog==", "dependencies": { - "as-string-sink": "^0.5.3", "as-variant": "^0.4.1", - "as-virtual": "^0.1.9" + "json-as": "^0.8.2", + "xid-ts": "^1.1.0" } }, "node_modules/@nodelib/fs.scandir": { @@ -243,22 +234,22 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.4.0.tgz", - "integrity": "sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.0.tgz", + "integrity": "sha512-GJWR0YnfrKnsRoluVO3PRb9r5aMZriiMMM/RHj5nnTrBy1/wIgk76XCtCKcnXGjpZQJQRFtGV9/0JJ6n30uwpQ==", "dev": true, "dependencies": { - "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/type-utils": "7.4.0", - "@typescript-eslint/utils": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/type-utils": "7.7.0", + "@typescript-eslint/utils": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4", "graphemer": "^1.4.0", - "ignore": "^5.2.4", + "ignore": "^5.3.1", "natural-compare": "^1.4.0", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -278,15 +269,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.4.0.tgz", - "integrity": "sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.7.0.tgz", + "integrity": "sha512-fNcDm3wSwVM8QYL4HKVBggdIPAy9Q41vcvC/GtDobw3c4ndVT3K6cqudUmjHPw8EAp4ufax0o58/xvWaP2FmTg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/typescript-estree": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/typescript-estree": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4" }, "engines": { @@ -306,13 +297,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.4.0.tgz", - "integrity": "sha512-68VqENG5HK27ypafqLVs8qO+RkNc7TezCduYrx8YJpXq2QGZ30vmNZGJJJC48+MVn4G2dCV8m5ZTVnzRexTVtw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.7.0.tgz", + "integrity": "sha512-/8INDn0YLInbe9Wt7dK4cXLDYp0fNHP5xKLHvZl3mOT5X17rK/YShXaiNmorl+/U4VKCVIjJnx4Ri5b0y+HClw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0" + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -323,15 +314,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.4.0.tgz", - "integrity": "sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.7.0.tgz", + "integrity": "sha512-bOp3ejoRYrhAlnT/bozNQi3nio9tIgv3U5C0mVDdZC7cpcQEDZXvq8inrHYghLVwuNABRqrMW5tzAv88Vy77Sg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.4.0", - "@typescript-eslint/utils": "7.4.0", + "@typescript-eslint/typescript-estree": "7.7.0", + "@typescript-eslint/utils": "7.7.0", "debug": "^4.3.4", - "ts-api-utils": "^1.0.1" + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -350,9 +341,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.4.0.tgz", - "integrity": "sha512-mjQopsbffzJskos5B4HmbsadSJQWaRK0UxqQ7GuNA9Ga4bEKeiO6b2DnB6cM6bpc8lemaPseh0H9B/wyg+J7rw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.7.0.tgz", + "integrity": "sha512-G01YPZ1Bd2hn+KPpIbrAhEWOn5lQBrjxkzHkWvP6NucMXFtfXoevK82hzQdpfuQYuhkvFDeQYbzXCjR1z9Z03w==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -363,19 +354,19 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.4.0.tgz", - "integrity": "sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.0.tgz", + "integrity": "sha512-8p71HQPE6CbxIBy2kWHqM1KGrC07pk6RJn40n0DSc6bMOBBREZxSDJ+BmRzc8B5OdaMh1ty3mkuWRg4sCFiDQQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "minimatch": "9.0.3", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -391,18 +382,18 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.4.0.tgz", - "integrity": "sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.7.0.tgz", + "integrity": "sha512-LKGAXMPQs8U/zMRFXDZOzmMKgFv3COlxUQ+2NMPhbqgVm6R1w+nU1i4836Pmxu9jZAuIeyySNrN/6Rc657ggig==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@types/json-schema": "^7.0.12", - "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/typescript-estree": "7.4.0", - "semver": "^7.5.4" + "@types/json-schema": "^7.0.15", + "@types/semver": "^7.5.8", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/typescript-estree": "7.7.0", + "semver": "^7.6.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -416,13 +407,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.4.0.tgz", - "integrity": "sha512-0zkC7YM0iX5Y41homUUeW1CHtZR01K3ybjM1l6QczoMuay0XKtrb93kv95AxUGwdjGr64nNqnOCwmEl616N8CA==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.0.tgz", + "integrity": "sha512-h0WHOj8MhdhY8YWkzIF30R379y0NqyOHExI9N9KCzvmu05EgG4FumeYa3ccfKUSphyWkWQE1ybVrgz/Pbam6YA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", - "eslint-visitor-keys": "^3.4.1" + "@typescript-eslint/types": "7.7.0", + "eslint-visitor-keys": "^3.4.3" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -530,9 +521,9 @@ "integrity": "sha512-R1nR7TT0KcROL/TxSXmiX2Q+7CgUMrjT/y9IP07StStqWs32KT2mpadJNF//yHWRaIJWe6atqTqO0JzsdhkPcQ==" }, "node_modules/assemblyscript": { - "version": "0.27.25", - "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.27.25.tgz", - "integrity": "sha512-hkx6Vz+EFVA2hqFfnTWfO14892scFIkJzdXyqfXUoBS76cLbar0PFJQ7yZuL9m/i5xpjFk9Bz2094uHLh7W5UA==", + "version": "0.27.27", + "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.27.27.tgz", + "integrity": "sha512-z4ijXsjjk3uespEeCWpO1K2GQySc6bn+LL5dL0tsC2VXNYKFnKDmAh3wefcKazxXHFVhYlxqNfyv96ajaQyINQ==", "dev": true, "dependencies": { "binaryen": "116.0.0-nightly.20240114", @@ -1219,9 +1210,9 @@ } }, "node_modules/json-as": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/json-as/-/json-as-0.8.1.tgz", - "integrity": "sha512-L9LLHz0JxjYWY+pFfDzD7La0AKQevvHIkvQT69cVNrl4ADCnGlHdZ2JTBRldTfw9JB6UXc38fWHE+hwes4vSDw==", + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/json-as/-/json-as-0.8.2.tgz", + "integrity": "sha512-/wCq7u0I5BlLb0dbgJQlv2k7jfc7qyNUgCsadarjeWe85Zc8bAvItrkCP0CJM3kxrVga2g/3sgeEd1QJDb6PJw==", "dependencies": { "as-string-sink": "^0.5.3", "as-variant": "^0.4.1", @@ -1336,9 +1327,9 @@ } }, "node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -1698,9 +1689,9 @@ } }, "node_modules/ts-api-utils": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.2.1.tgz", - "integrity": "sha512-RIYA36cJn2WiH9Hy77hdF9r7oEwxAtB/TS9/S4Qd90Ap4z5FSiin5zEiTL44OII1Y3IIlEvxwxFUVgrHSZ/UpA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", + "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "dev": true, "engines": { "node": ">=16" @@ -1740,9 +1731,9 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, "peer": true, "bin": { diff --git a/functions/package.json b/functions/package.json index 2283676..a514297 100644 --- a/functions/package.json +++ b/functions/package.json @@ -1,30 +1,27 @@ { "name": "sample", "private": true, - "version": "1.1.0", + "version": "1.2.0", "description": "Hypermode Functions Sample", "author": "Hypermode, Inc.", "license": "MIT", "type": "module", "scripts": { - "build": "run-script-os", - "build:windows": "asc assembly\\index.ts -o build\\%npm_package_name%.wasm --target debug", - "build:default": "asc assembly/index.ts -o build/$npm_package_name.wasm --target debug", - "build:release": "asc assembly/index.ts -o build/$npm_package_name.wasm --target release", + "build": "node ./node_modules/@hypermode/functions-as/bin/build-plugin.js", "pretty": "prettier --write .", "pretty:check": "prettier --check .", "lint": "eslint --ext .ts .", "lint:fix": "eslint --ext .ts --fix ." }, "dependencies": { - "@hypermode/functions-as": "^0.4.0", - "json-as": "^0.8.1" + "@hypermode/functions-as": "^0.5.0", + "json-as": "^0.8.2" }, "devDependencies": { "@assemblyscript/wasi-shim": "^0.1.0", - "@typescript-eslint/eslint-plugin": "^7.4.0", - "@typescript-eslint/parser": "^7.4.0", - "assemblyscript": "^0.27.25", + "@typescript-eslint/eslint-plugin": "^7.7.0", + "@typescript-eslint/parser": "^7.7.0", + "assemblyscript": "^0.27.27", "assemblyscript-prettier": "^3.0.1", "eslint": "^8.57.0", "prettier": "^3.2.5", diff --git a/hypermode.json b/hypermode.json index 0777895..c04d1be 100644 --- a/hypermode.json +++ b/hypermode.json @@ -10,8 +10,9 @@ ], "hosts": [ { - "name": "openai" - "endpoint": "https://api.openai.com/v1" + "name": "openai", + "endpoint": "https://api.openai.com/v1", + "authHeader": "x-api-key" } ] } diff --git a/schema.graphql b/schema.graphql deleted file mode 100644 index 9a0e7d2..0000000 --- a/schema.graphql +++ /dev/null @@ -1,5 +0,0 @@ -directive @hm_function on FIELD_DEFINITION - -type Query { - testClassifier(text: String!): String! @lambda @hm_function -}