diff --git a/JS/edgechains/examples/Test01/esbuild.build.js b/JS/edgechains/examples/Test01/esbuild.build.js deleted file mode 100644 index 8da795c0e..000000000 --- a/JS/edgechains/examples/Test01/esbuild.build.js +++ /dev/null @@ -1,45 +0,0 @@ -const esbuild = require("esbuild"); -const path = require("path"); -const fs = require("fs"); -const { execSync } = require("child_process"); - -const outputDir = path.resolve(__dirname, "dist"); - -if (!fs.existsSync(outputDir)) { - fs.mkdirSync(outputDir); -} - -const distPath = path.join(process.cwd(), "dist"); - -fs.promises.mkdir(distPath, { recursive: true }); - -esbuild - .build({ - entryPoints: ["./src/index.ts"], - bundle: true, - minify: true, - platform: "node", - outfile: "./dist/index.js", - tsconfig: "./tsconfig.json", - target: "node21.1.0", - external: [ - "express", - "tsx", - "typescript", - "typeorm", - "react", - "react-dom", - "pg", - "jsdom", - "hono", - "@hanazuki/node-jsonnet", - "readline/promises", - ], - format: "cjs", - loader: { - ".html": "text", - ".css": "css", - ".jsonnet": "text", - }, - }) - .catch(() => process.exit(1)); diff --git a/JS/edgechains/examples/Test01/package.json b/JS/edgechains/examples/Test01/package.json index cd24270f1..f1bc51783 100644 --- a/JS/edgechains/examples/Test01/package.json +++ b/JS/edgechains/examples/Test01/package.json @@ -3,17 +3,24 @@ "version": "1.0.0", "description": "", "main": "dist/index.js", + "type": "module", "scripts": { "build": "rm -rf dist && node esbuild.build.js", - "start": "node dist/index.js", + "start": "node --experimental-wasm-modules ./src/index.js", "lint": "eslint --ignore-path .eslintignore --ext .js,.ts", "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"", "test": "npx jest" }, + "jest": { + "setupFiles": [ + "/setupTests.js" + ] + }, "keywords": [], "author": "", "license": "ISC", "dependencies": { + "@arakoodev/jsonnet": "^0.1.2", "@hono/node-server": "^1.2.0", "@types/dotenv": "^8.2.0", "hono": "^3.9.2", @@ -23,7 +30,7 @@ "typescript": "^5.3.2" }, "devDependencies": { - "@hanazuki/node-jsonnet": "^2.1.0", + "@arakoodev/edgechains.js": "0.1.22", "@types/jest": "^29.5.8", "@types/node": "^20.9.4", "@typescript-eslint/eslint-plugin": "^6.11.0", @@ -40,10 +47,9 @@ "jest": "^29.7.0", "prettier": "^3.1.0", "react": "^18.2.0", - "@arakoodev/edgechains.js": "0.1.22", "ts-jest": "^29.1.1", "tsx": "^3.12.2", "typeorm": "^0.3.17", "typescript": "^5.0.2" } -} +} \ No newline at end of file diff --git a/JS/edgechains/examples/Test01/src/service/HydeSearchService.test.ts b/JS/edgechains/examples/Test01/src/service/HydeSearchService.test.ts deleted file mode 100644 index 463b3a1e7..000000000 --- a/JS/edgechains/examples/Test01/src/service/HydeSearchService.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { ArkRequest } from "@arakoodev/edgechains.js"; -import { hydeSearchAdaEmbedding } from "./HydeSearchService.js"; -import dotenv from "dotenv"; - -dotenv.config({ path: ".env" }); -describe("Hyde Search", () => { - it("should return a response", async () => { - const arkRequest: ArkRequest = { - topK: 5, - metadataTable: "title_metadata", - query: "tell me the top 5 programming languages currently", - textWeight: { - baseWeight: "1.0", - fineTuneWeight: "0.35", - }, - similarityWeight: { - baseWeight: "1.5", - fineTuneWeight: "0.40", - }, - dateWeight: { - baseWeight: "1.25", - fineTuneWeight: "0.75", - }, - orderRRF: "default", - }; - expect( - ( - await hydeSearchAdaEmbedding( - arkRequest, - process.env.OPENAI_API_KEY!, - process.env.OPENAI_ORG_ID! - ) - ).finalAnswer - ).toContain("Java"); - }, 30000); -}); diff --git a/JS/edgechains/examples/Test01/src/service/HydeSearchService.ts b/JS/edgechains/examples/Test01/src/service/HydeSearchService.ts index a351568fc..46996d364 100644 --- a/JS/edgechains/examples/Test01/src/service/HydeSearchService.ts +++ b/JS/edgechains/examples/Test01/src/service/HydeSearchService.ts @@ -1,4 +1,4 @@ -import { Jsonnet } from "@hanazuki/node-jsonnet"; +import Jsonnet from "@arakoodev/jsonnet"; import { OpenAiEndpoint } from "@arakoodev/edgechains.js"; import { PostgresClient } from "@arakoodev/edgechains.js"; import type { ArkRequest } from "@arakoodev/edgechains.js"; diff --git a/JS/edgechains/examples/Test01/src/testGeneration/TestGenerator.ts b/JS/edgechains/examples/Test01/src/testGeneration/TestGenerator.ts index 7c1ab5037..833f5a6f9 100644 --- a/JS/edgechains/examples/Test01/src/testGeneration/TestGenerator.ts +++ b/JS/edgechains/examples/Test01/src/testGeneration/TestGenerator.ts @@ -1,4 +1,4 @@ -import { Jsonnet } from "@hanazuki/node-jsonnet"; +import Jsonnet from "@arakoodev/jsonnet"; import * as path from "path"; import { OpenAiEndpoint } from "@arakoodev/edgechains.js"; diff --git a/JS/edgechains/examples/react-chain/jest.config.js b/JS/edgechains/examples/react-chain/jest.config.js deleted file mode 100644 index 32d105c45..000000000 --- a/JS/edgechains/examples/react-chain/jest.config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - preset: "ts-jest", - testEnvironment: "node", - transform: { - "^.+\\.tsx?$": "ts-jest", - }, - extensionsToTreatAsEsm: [".ts"], - globals: { - "ts-jest": { - useESM: true, - }, - }, -}; diff --git a/JS/edgechains/examples/react-chain/package.json b/JS/edgechains/examples/react-chain/package.json index 6bca47a44..2fd83be29 100644 --- a/JS/edgechains/examples/react-chain/package.json +++ b/JS/edgechains/examples/react-chain/package.json @@ -7,8 +7,7 @@ "build": "rm -rf dist/ && tsc", "start": "node --experimental-wasm-modules dist/index.js", "lint": "eslint --ignore-path .eslintignore --ext .js,.ts", - "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"", - "test": "npx jest" + "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"" }, "keywords": [], "author": "", @@ -26,7 +25,6 @@ "@arakoodev/edgechains.js": "0.1.22", "@babel/preset-env": "^7.23.8", "@babel/preset-typescript": "^7.23.3", - "@hanazuki/node-jsonnet": "^2.1.0", "@types/jest": "^29.5.8", "@types/node": "^20.9.4", "@typescript-eslint/eslint-plugin": "^6.11.0", diff --git a/JS/edgechains/examples/react-chain/src/ReactChain.test.ts b/JS/edgechains/examples/react-chain/src/ReactChain.test.ts deleted file mode 100644 index 1f9f7d6a2..000000000 --- a/JS/edgechains/examples/react-chain/src/ReactChain.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Import the reactChainCall function from the ReactChain module -import { reactChainCall } from "./ReactChain"; - -// Describe block for the ReAct Chain test suite -describe("ReAct Chain", () => { - // Test case: It should return a response - it("should return a response", async () => { - // Call the reactChainCall function with a sample question - const response = await reactChainCall( - "Author David Chanoff has collaborated with a U.S. Navy admiral who served as the ambassador to the United Kingdom under which President?" - ); - - // Assuming the response is an object with a property 'answer' - expect(response).toContain("Bill Clinton"); - }, 60000); // Increase the timeout to 60 seconds or as needed -}); diff --git a/JS/edgechains/examples/react-chain/src/ReactChain.ts b/JS/edgechains/examples/react-chain/src/ReactChain.ts index 89589850b..d250c0a0f 100644 --- a/JS/edgechains/examples/react-chain/src/ReactChain.ts +++ b/JS/edgechains/examples/react-chain/src/ReactChain.ts @@ -20,7 +20,7 @@ const gpt3Endpoint = new OpenAiEndpoint( "https://api.openai.com/v1/chat/completions", process.env.OPENAI_API_KEY!, "", - "gpt-4", + "gpt-3.5-turbo", "user", parseInt("0.7") ); diff --git a/JS/edgechains/examples/react-chain/tsconfig.json b/JS/edgechains/examples/react-chain/tsconfig.json index bf27ef6ea..d5511060c 100644 --- a/JS/edgechains/examples/react-chain/tsconfig.json +++ b/JS/edgechains/examples/react-chain/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "types": ["dotenv/config", "jest", "node"], + "types": ["dotenv/config", "node"], "outDir": "dist", "target": "ES2022", "module": "NodeNext", diff --git a/JS/edgechains/examples/wikiExample/package.json b/JS/edgechains/examples/wikiExample/package.json index f49d58308..0f8e4658a 100644 --- a/JS/edgechains/examples/wikiExample/package.json +++ b/JS/edgechains/examples/wikiExample/package.json @@ -25,7 +25,6 @@ }, "devDependencies": { "@arakoodev/edgechains.js": "0.1.22", - "@hanazuki/node-jsonnet": "^2.1.0", "@types/jest": "^29.5.8", "@types/node": "^20.9.4", "@typescript-eslint/eslint-plugin": "^6.11.0",