Skip to content

Commit

Permalink
override default actions and agents in cj, make default overridable
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Feb 21, 2024
1 parent 436cc0b commit 75b63fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/agents/cj/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
});

Expand Down
17 changes: 6 additions & 11 deletions src/lib/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type SupabaseClient } from "@supabase/supabase-js";
import { defaultActions } from "./actions";
import { composeContext } from "./context";
import {
defaultEvaluators,
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions src/test/createRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 75b63fc

Please sign in to comment.