From 8b740d4426f75ea7f806baf632b44abd76439b67 Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Sat, 7 Dec 2024 10:36:30 +0100 Subject: [PATCH] feat(agents): base updates Signed-off-by: Tomas Dvorak --- src/agents/base.ts | 15 +++++++++++++-- src/agents/bee/agent.ts | 4 ---- src/agents/experimental/streamlit/agent.ts | 4 ---- src/llms/chat.ts | 2 ++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/agents/base.ts b/src/agents/base.ts index 0d7a7605..ad3361b2 100644 --- a/src/agents/base.ts +++ b/src/agents/base.ts @@ -19,10 +19,10 @@ import { AgentMeta } from "@/agents/types.js"; import { Serializable } from "@/internals/serializable.js"; import { GetRunContext, RunContext } from "@/context.js"; import { Emitter } from "@/emitter/emitter.js"; -import { BaseMemory } from "@/memory/base.js"; import { createTelemetryMiddleware } from "@/instrumentation/create-telemetry-middleware.js"; import { INSTRUMENTATION_ENABLED } from "@/instrumentation/config.js"; import { doNothing } from "remeda"; +import { BaseMemory } from "@/memory/base.js"; export class AgentError extends FrameworkError {} @@ -79,9 +79,20 @@ export abstract class BaseAgent< } public abstract get memory(): BaseMemory; - public abstract get meta(): AgentMeta; + + public get meta(): AgentMeta { + return { + name: this.constructor.name ?? "BaseAgent", + description: "", + tools: [], + }; + } createSnapshot() { return { isRunning: false }; } + + loadSnapshot(snapshot: ReturnType) { + Object.assign(this, snapshot); + } } diff --git a/src/agents/bee/agent.ts b/src/agents/bee/agent.ts index 3cbe0c1c..7572bd3d 100644 --- a/src/agents/bee/agent.ts +++ b/src/agents/bee/agent.ts @@ -192,8 +192,4 @@ export class BeeAgent extends BaseAgent) { - Object.assign(this, snapshot); - } } diff --git a/src/agents/experimental/streamlit/agent.ts b/src/agents/experimental/streamlit/agent.ts index 3a2061c4..13dc8aa9 100644 --- a/src/agents/experimental/streamlit/agent.ts +++ b/src/agents/experimental/streamlit/agent.ts @@ -205,8 +205,4 @@ export class StreamlitAgent extends BaseAgent) { - Object.assign(this, snapshot); - } } diff --git a/src/llms/chat.ts b/src/llms/chat.ts index bf4a96c8..6116bc84 100644 --- a/src/llms/chat.ts +++ b/src/llms/chat.ts @@ -33,3 +33,5 @@ export abstract class ChatLLM< > extends BaseLLM { public abstract readonly emitter: Emitter>; } + +export type AnyChatLLM = ChatLLM;