Skip to content

Commit

Permalink
feat: ability to publish tools as a library (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamwhiteuk authored Sep 20, 2024
1 parent 802407a commit 67b6664
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ yarn install

### Run an example agent with tools

We provide an example agent in `src/index.ts` that you can use to test tools.
We provide example agents for tool usage in `examples/agents/` that you can use to test tools.

```shell
yarn start
```

The example agent is configured to use a BAM or OpenAI hosted LLM, or a local Ollama LLM.
The `allToolsAgent` example agent is configured to use a BAM, Watsonx, OpenAI hosted LLM, or a local Ollama LLM.
If you are using a hosted LLM make sure to create .env (from .env.template) and fill in the necessary API_KEY.

> [!NOTE]
> The Hello World example tool is not enabled by default.
> [!TIP]
> Tools can be enabled/disabled in `src/index.ts`
> Tools can be enabled/disabled in `examples/agents/allToolsAgent.ts`
## Contribution guidelines

Expand Down
8 changes: 3 additions & 5 deletions src/index.ts → examples/agents/allToolsAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import "dotenv/config.js";
import { BAMChatLLM } from "bee-agent-framework/adapters/bam/chat";
import { BeeAgent } from "bee-agent-framework/agents/bee/agent";
import { createConsoleReader } from "./helpers/io.js";
import { createConsoleReader } from "../helpers/io.js";
import { FrameworkError } from "bee-agent-framework/errors";
import { TokenMemory } from "bee-agent-framework/memory/tokenMemory";
import { Logger } from "bee-agent-framework/logger/logger";
Expand All @@ -41,8 +41,8 @@ import { WikipediaTool } from "bee-agent-framework/tools/search/wikipedia";

// contrib tools
// import { HelloWorldTool } from "@/tools/helloWorld.js";
import { OpenLibraryTool } from "@/tools/openLibrary.js";
import { ImageDescriptionTool } from "@/tools/imageDescription.js";
import { OpenLibraryTool } from "../../src/tools/openLibrary.js";
import { ImageDescriptionTool } from "../../src/tools/imageDescription.js";

Logger.root.level = "silent"; // disable internal logs
const logger = new Logger({ name: "app", level: "trace" });
Expand Down Expand Up @@ -159,5 +159,3 @@ async function runBeeAgent() {
}

void runBeeAgent();

export * from "./version.js";
File renamed without changes.
13 changes: 13 additions & 0 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "..",
"rootDir": "..",
"paths": {
"bee-community-tools/*": ["./src/*.js"],
"@/*": ["./src/*"]
}
},
"references": [{ "path": "./src" }],
"exclude": ["../tests", "../**/*.test.ts"]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"scripts": {
"clean": "rimraf dist",
"build": "yarn clean && yarn ts:check && tsup",
"ts:check": "tsc --noEmit",
"start": "tsx src/index.ts",
"ts:check": "tsc --noEmit && tsc -p tsconfig.examples.json --noEmit",
"start": "tsx --tsconfig tsconfig.examples.json examples/agents/allToolsAgent.ts",
"lint": "yarn eslint",
"lint:fix": "yarn eslint --fix",
"format": "yarn prettier --check .",
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./examples/tsconfig.json"
}

0 comments on commit 67b6664

Please sign in to comment.