From 436cc0b52a403e3c09875432ae0674ca9e928061 Mon Sep 17 00:00:00 2001 From: moon Date: Tue, 20 Feb 2024 11:04:13 -0800 Subject: [PATCH 1/2] 0.0.12 --- package.json | 5 ++--- src/lib/utils.ts | 2 -- src/test/populateMemories.ts | 2 +- tsconfig.json | 8 ++++---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 389e0bf..337e5fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bgent", - "version": "0.0.11", + "version": "0.0.12", "private": false, "description": "bgent. because agent was taken.", "type": "module", @@ -9,8 +9,7 @@ "jsnext:main": "dist/index.esm.js", "types": "dist/index.d.ts", "scripts": { - "build": "rollup -c && npm run build:types", - "build:types": "tsc --declaration --emitDeclarationOnly --declarationDir dist", + "build": "rm -r ./dist && rollup -c && tsc", "lint": "eslint --ext .ts --ext .js . --fix", "dev": "wrangler dev -- --dev", "shell:dev": "node --no-warnings scripts/shell.mjs --dev", diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 5badf78..0d25bd5 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -23,8 +23,6 @@ export function parseJsonArrayFromText(text: string) { } } - console.log("jsonData", jsonData); - if (Array.isArray(jsonData)) { return jsonData; } else { diff --git a/src/test/populateMemories.ts b/src/test/populateMemories.ts index 3d14593..aa688e7 100644 --- a/src/test/populateMemories.ts +++ b/src/test/populateMemories.ts @@ -3,7 +3,7 @@ import { type UUID } from "crypto"; import { zeroUuid } from "../lib/actions/__tests__/ignore.test"; import { type BgentRuntime } from "../lib/runtime"; import { getCachedEmbedding, writeCachedEmbedding } from "./cache"; -import { ContentExample } from "lib/types"; +import { ContentExample } from "../lib/types"; export async function populateMemories( runtime: BgentRuntime, diff --git a/tsconfig.json b/tsconfig.json index 1df308d..8ffd4fd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,13 +26,13 @@ "noFallthroughCasesInSwitch": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "baseUrl": "src" + "outDir": "./dist", + "declaration": true, + "declarationDir": "./dist", + "rootDir": "./src", }, "include": [ "src", - "__tests__", - "jest.config.js", - "rollup.config.js", ], "exclude": [ "node_modules", From 75b63fcdff9b39287a5d341393b0e36374dce070 Mon Sep 17 00:00:00 2001 From: moon Date: Tue, 20 Feb 2024 17:20:06 -0800 Subject: [PATCH 2/2] override default actions and agents in cj, make default overridable --- src/agents/cj/index.ts | 5 +++-- src/lib/runtime.ts | 17 ++++++----------- src/test/createRuntime.ts | 2 -- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/agents/cj/index.ts b/src/agents/cj/index.ts index 7007650..f95dd93 100644 --- a/src/agents/cj/index.ts +++ b/src/agents/cj/index.ts @@ -12,6 +12,7 @@ import { import actions from "./actions"; import evaluators from "./evaluators"; import flavor from "./flavor"; +import { defaultActions, defaultEvaluators } from "../../lib"; export function shouldSkipMessage(state: State, agentId: string): boolean { if (state.recentMessagesData && state.recentMessagesData.length > 2) { @@ -102,8 +103,8 @@ const routes: Route[] = [ serverUrl: "https://api.openai.com/v1", supabase, token: env.OPENAI_API_KEY, - actions, - evaluators, + actions: [...actions, ...defaultActions], + evaluators: [...evaluators, ...defaultEvaluators], flavor, }); diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts index ab56b84..1003c8d 100644 --- a/src/lib/runtime.ts +++ b/src/lib/runtime.ts @@ -1,5 +1,4 @@ import { type SupabaseClient } from "@supabase/supabase-js"; -import { defaultActions } from "./actions"; import { composeContext } from "./context"; import { defaultEvaluators, @@ -86,17 +85,13 @@ export class BgentRuntime { this.token = opts.token; - [...defaultActions, ...((opts.actions ?? []) as Action[])].forEach( - (action) => { - this.registerAction(action); - }, - ); + (opts.actions ?? []).forEach((action) => { + this.registerAction(action); + }); - [...defaultEvaluators, ...((opts.evaluators ?? []) as Evaluator[])].forEach( - (evaluator) => { - this.registerEvaluator(evaluator); - }, - ); + (opts.evaluators ?? defaultEvaluators).forEach((evaluator) => { + this.registerEvaluator(evaluator); + }); } getRecentMessageCount() { diff --git a/src/test/createRuntime.ts b/src/test/createRuntime.ts index feec5d8..1fdafdf 100644 --- a/src/test/createRuntime.ts +++ b/src/test/createRuntime.ts @@ -32,8 +32,6 @@ export async function createRuntime({ throw new Error("Session not found"); } - console.log('*** creating runtime with action', actions, 'and evaluators', evaluators) - const runtime = new BgentRuntime({ debugMode: false, serverUrl: "https://api.openai.com/v1",