-
Notifications
You must be signed in to change notification settings - Fork 139
/
agent.ts
29 lines (24 loc) · 960 Bytes
/
agent.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { BeeAgent } from "bee-agent-framework/agents/bee/agent";
import { OllamaChatLLM } from "bee-agent-framework/adapters/ollama/chat";
import { UnconstrainedMemory } from "bee-agent-framework/memory/unconstrainedMemory";
import { Logger } from "bee-agent-framework/logger/logger";
import { Emitter } from "bee-agent-framework/emitter/emitter";
// Set up logging
Logger.defaults.pretty = true;
const logger = Logger.root.child({
level: "trace",
name: "app",
});
// Log events emitted during agent execution
Emitter.root.match("*.*", (data, event) => {
const logLevel = event.path.includes(".run.") ? "trace" : "info";
logger[logLevel](`Event '${event.path}' triggered by '${event.creator.constructor.name}'.`);
});
// Create and run an agent
const agent = new BeeAgent({
llm: new OllamaChatLLM(),
memory: new UnconstrainedMemory(),
tools: [],
});
const response = await agent.run({ prompt: "Hello!" });
logger.info(response.result.text);