Skip to content

Commit

Permalink
docs: fix markdown block type and updating the modules in main README
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelfaro committed Dec 3, 2024
1 parent 71e47c3 commit 144d7d2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 41 deletions.
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,24 @@ console.log(`Agent 🤖 : `, response.result.text);

➡️ To run an arbitrary example, use the following command `yarn start examples/agents/bee.ts` (just pass the appropriate path to the desired example).

### 📦 Modules
### 📦 Bee Framework Modules

The source directory (`src`) provides numerous modules that one can use.

| Name | Description |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------- |
| [**agents**](/docs/agents.md) | Base classes defining the common interface for agent. |
| [**llms**](/docs/llms.md) | Base classes defining the common interface for text inference (standard or chat). |
| [**template**](/docs/templates.md) | Prompt Templating system based on `Mustache` with various improvements. |
| [**memory**](/docs/memory.md) | Various types of memories to use with agent. |
| [**tools**](/docs/tools.md) | Tools that an agent can use. |
| [**cache**](/docs/cache.md) | Preset of different caching approaches that can be used together with tools. |
| [**errors**](/docs/errors.md) | Error classes and helpers to catch errors fast. |
| [**adapters**](/docs/llms.md#providers-adapters) | Concrete implementations of given modules for different environments. |
| [**logger**](/docs/logger.md) | Core component for logging all actions within the framework. |
| [**serializer**](/docs/serialization.md) | Core component for the ability to serialize/deserialize modules into the serialized format. |
| [**version**](/docs/version.md) | Constants representing the framework (e.g., latest version) |
| [**emitter**](/docs/emitter.md) | Bringing visibility to the system by emitting events. |
| **internals** | Modules used by other modules within the framework. |
- [**Agents**](/docs/agents.md) : Base classes defining the common interface for agent.
- [**LLM**](/docs/llms.md) : Base classes defining the common interface for text inference (standard or chat)
- [**Template Prompt**](/docs/templates.md): Templating system based on Mustache with various improvements.
- [**Adapters**](/docs/llms.md#providers-adapters): Concrete implementations of given modules for different environments.
- [**Memory**](/docs/memory.md) : Various types of memories to use with agent.
- [**Cache**](/docs/cache.md): Preset of different caching approaches that can be used together with tools.
- [**Tools**](/docs/tools.md) : Tools that an agent can use.
- Dev tool:
- [**emitter**](/docs/emitter.md) : Bringing visibility to the system by emitting events.
- [**logger**](/docs/logger.md) : Core component for logging all actions within the framework.
- [**serializer**](/docs/serialization.md) : Core component for the ability to serialize/deserialize modules.
- [**errors**](/docs/errors.md) : Error classes and helpers to catch errors fast.
- [**version**](/docs/version.md) : Constants representing the framework (e.g., latest version)
- **internals** : Modules used by other modules within the framework. |

To see more in-depth explanation see [overview](/docs/overview.md).

Expand Down
10 changes: 5 additions & 5 deletions docs/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ Persists cache data to the filesystem.

```ts
import { FileCache } from "bee-agent-framework/cache/fileCache";
import * as os from "node:os";

const cache = new FileCache<UserData>({
fullPath: "/path/to/cache.json",
const cache = new FileCache({
fullPath: `${os.tmpdir()}/bee_file_cache_${Date.now()}.json`,
});

await cache.set("user:123", userData);
// Data is automatically persisted to disk
console.log(`Saving cache to "${cache.source}"`);
await cache.set("abc", { firstName: "John", lastName: "Doe" });
```

_Source: [examples/cache/fileCache.ts](/examples/cache/fileCache.ts)_
Expand Down
2 changes: 1 addition & 1 deletion docs/dev_tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Key features:

The development tools can be configured through environment variables:

```bash
```shell
# Logging
export BEE_FRAMEWORK_LOG_LEVEL=debug
export BEE_FRAMEWORK_LOG_PRETTY=true
Expand Down
35 changes: 21 additions & 14 deletions docs/emitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,34 @@ Registers a listener with advanced matching capabilities.
<!-- embedme examples/emitter/matchers.ts -->

```ts
import { Emitter } from "bee-agent-framework/emitter/emitter";
import { Callback, Emitter } from "bee-agent-framework/emitter/emitter";
import { BaseLLM } from "bee-agent-framework/llms/base";

const emitter = new Emitter({ namespace: ["app"] });
interface Events {
update: Callback<{ data: string }>;
}

// Match all events in namespace
emitter.match("*.*", (data, event) => {
console.log(`${event.path}: ${JSON.stringify(data)}`);
const emitter = new Emitter<Events>({
namespace: ["app"],
});

// Match with regular expression
emitter.match(/error/, (data, event) => {
console.log(`Error event: ${event.name}`);
});
// Match events by a concrete name (strictly typed)
emitter.on("update", async (data, event) => {});

// Match all events emitted directly on the instance (not nested)
emitter.match("*", async (data, event) => {});

// Match with custom function
// Match all events (included nested)
emitter.match("*.*", async (data, event) => {});

// Match events by providing a filter function
emitter.match(
(event) => event.context.priority === "high",
(data, event) => {
console.log(`High priority event: ${event.name}`);
},
(event) => event.creator instanceof BaseLLM,
async (data, event) => {},
);

// Match events by regex
emitter.match(/watsonx/, async (data, event) => {});
```

_Source: [examples/emitter/matchers.ts](/examples/emitter/matchers.ts)_
Expand Down
3 changes: 3 additions & 0 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ const error = new FrameworkError(
console.log("Message", error.message); // Main error message
console.log("Meta", { fatal: error.isFatal, retryable: error.isRetryable }); // Is the error fatal/retryable?
console.log("Context", error.context); // Context in which the error occurred
console.log(error.explain()); // Human-readable format without stack traces (ideal for LLMs)
console.log(error.dump()); // Full error dump, including sub-errors
console.log(error.getCause()); // Retrieve the initial cause of the error
```

_Source: [examples/errors/base.ts](/examples/errors/base.ts)_
Expand Down
15 changes: 10 additions & 5 deletions docs/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,16 @@ Logger.defaults.level = LoggerLevel.TRACE; // Set log level to trace (default: T
Logger.defaults.name = undefined; // Optional name for logger (default: undefined)
Logger.defaults.bindings = {}; // Optional bindings for structured logging (default: empty)

const parentLogger = Logger.root.child({ name: "app" });
const moduleLogger = parentLogger.child({
name: "module",
level: "debug",
});
// Create a child logger for your app
const logger = Logger.root.child({ name: "app" });

// Log at different levels
logger.trace("Trace!");
logger.debug("Debug!");
logger.info("Info!");
logger.warn("Warning!");
logger.error("Error!");
logger.fatal("Fatal!");
```

#### Logging Methods
Expand Down

0 comments on commit 144d7d2

Please sign in to comment.