Skip to content

Commit

Permalink
docs: add role and tools to getting started cli experience
Browse files Browse the repository at this point in the history
Signed-off-by: Paul S. Schweigert <[email protected]>

Fixes #148

We have found that bees perform best when:
* they use fewer number of tools, and
* they are provided explicit instructions/role

Here we updated the getting started section of the README to
incorporate those recommendations into the simple example. We update
the system prompt to provide explicit instructions, and we remove the
search tool as it isn't needed for weather-related queries. It also
adds some tips related to these two points to the appropriate section.

Additionally, it adds a yarn helper method to run the simple example:
`yarn run quickstart`
  • Loading branch information
psschwei committed Dec 2, 2024
1 parent 226aaf5 commit 54d6446
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,24 @@ yarn add bee-agent-framework
import { BeeAgent } from "bee-agent-framework/agents/bee/agent";
import { OllamaChatLLM } from "bee-agent-framework/adapters/ollama/chat";
import { TokenMemory } from "bee-agent-framework/memory/tokenMemory";
import { DuckDuckGoSearchTool } from "bee-agent-framework/tools/search/duckDuckGoSearch";
import { BeeSystemPrompt } from "bee-agent-framework/agents/bee/prompts";
import { OpenMeteoTool } from "bee-agent-framework/tools/weather/openMeteo";

const llm = new OllamaChatLLM(); // default is llama3.1 (8B), it is recommended to use 70B model

const agent = new BeeAgent({
llm, // for more explore 'bee-agent-framework/adapters'
memory: new TokenMemory({ llm }), // for more explore 'bee-agent-framework/memory'
tools: [new DuckDuckGoSearchTool(), new OpenMeteoTool()], // for more explore 'bee-agent-framework/tools'
tools: [new OpenMeteoTool()], // for more explore 'bee-agent-framework/tools'
templates: {
system: BeeSystemPrompt.fork((old) => ({
...old,
defaults: {
instructions:
"You are a helpful assistant that uses tools to answer weather-related questions.",
},
})),
},
});

const response = await agent
Expand All @@ -74,9 +83,15 @@ const response = await agent
console.log(`Agent 🤖 : `, response.result.text);
```

➡️ See a more [advanced example](/examples/agents/bee.ts).
> [!TIP]
>
> Providing a bee with specific `instructions` on what their role should be will improve performance and is recommended.
> [!TIP]
>
> Bees work best when using a smaller number of `tools`, so it is recommended to only enable the minimum required tools.
➡️ you can run this example after local installation, using the command `yarn start examples/agents/simple.ts`
➡️ you can run this example after local installation, using the command `yarn run quickstart`

> [!TIP]
>
Expand All @@ -86,6 +101,8 @@ console.log(`Agent 🤖 : `, response.result.text);
>
> Documentation is available at https://i-am-bee.github.io/bee-agent-framework/
➡️ See a more [advanced example](/examples/agents/bee.ts)

### Local Installation

> [!NOTE]
Expand Down
13 changes: 11 additions & 2 deletions examples/agents/simple.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import "dotenv/config.js";
import { BeeAgent } from "bee-agent-framework/agents/bee/agent";
import { BeeSystemPrompt } from "bee-agent-framework/agents/bee/prompts";
import { TokenMemory } from "bee-agent-framework/memory/tokenMemory";
import { DuckDuckGoSearchTool } from "bee-agent-framework/tools/search/duckDuckGoSearch";
import { OllamaChatLLM } from "bee-agent-framework/adapters/ollama/chat";
import { OpenMeteoTool } from "bee-agent-framework/tools/weather/openMeteo";

const llm = new OllamaChatLLM();
const agent = new BeeAgent({
llm,
memory: new TokenMemory({ llm }),
tools: [new DuckDuckGoSearchTool(), new OpenMeteoTool()],
tools: [new OpenMeteoTool()],
templates: {
system: BeeSystemPrompt.fork((old) => ({
...old,
defaults: {
instructions:
"You are a helpful assistant that uses tools to answer weather-related questions.",
},
})),
},
});

const response = await agent
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"build": "yarn clean && yarn ts:check && NODE_OPTIONS='--max-old-space-size=8192' tsup && cp -r src/adapters/ibm-vllm/proto dist/adapters/ibm-vllm",
"ts:check": "tsc --noEmit && tsc -p tsconfig.examples.json --noEmit",
"start": "tsx --tsconfig tsconfig.examples.json",
"quickstart": "yarn start -- examples/agents/simple.ts",
"start:bee": "yarn start -- examples/agents/bee.ts",
"start:telemetry": "BEE_FRAMEWORK_INSTRUMENTATION_ENABLED=true yarn start --import ./examples/helpers/telemetry.ts",
"docs:build": "embedme --source-root=. docs/**/*.md && cp *.md docs/ && yarn lint:fix docs/ && yarn prettier --write docs/",
Expand Down

0 comments on commit 54d6446

Please sign in to comment.