-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools): propagate agent's runner memory to tools (#242)
Signed-off-by: Tomas Dvorak <toomas2d@gmail.com>
- Loading branch information
Showing
5 changed files
with
115 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import "dotenv/config"; | ||
import { LLMTool } from "bee-agent-framework/tools/llm"; | ||
import { OllamaChatLLM } from "bee-agent-framework/adapters/ollama/chat"; | ||
import { Tool } from "bee-agent-framework/tools/base"; | ||
import { UnconstrainedMemory } from "bee-agent-framework/memory/unconstrainedMemory"; | ||
import { BaseMessage } from "bee-agent-framework/llms/primitives/message"; | ||
|
||
const memory = new UnconstrainedMemory(); | ||
await memory.addMany([ | ||
BaseMessage.of({ role: "system", text: "You are a helpful assistant." }), | ||
BaseMessage.of({ role: "user", text: "Hello!" }), | ||
BaseMessage.of({ role: "assistant", text: "Hello user. I am here to help you." }), | ||
]); | ||
|
||
const tool = new LLMTool({ | ||
llm: new OllamaChatLLM(), | ||
}); | ||
|
||
const response = await tool | ||
.run({ | ||
task: "Classify whether the tone of text is POSITIVE/NEGATIVE/NEUTRAL.", | ||
}) | ||
.context({ | ||
// if the context is not passed, the tool will throw an error | ||
[Tool.contextKeys.Memory]: memory, | ||
}); | ||
|
||
console.info(response.getTextContent()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters