Skip to content

Commit 863f644

Browse files
committed
add providers to readme
1 parent 0da01a6 commit 863f644

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,32 @@ const runtime = new BgentRuntime({
148148
evaluators: [fact],
149149
});
150150

151-
// You can also register actions and evaluators after the runtime has been created
151+
// OR you can register actions and evaluators after the runtime has been created
152152
bgentRuntime.registerAction(wait);
153153
bgentRuntime.registerEvaluator(fact);
154154
```
155155

156+
## Custom Data Sources
157+
If you want to add custom data into the context that is sent to the LLM, you can create a `Provider` and add it to the runtime.
158+
159+
```typescript
160+
import { type BgentRuntime, type Message, type Provider, type State } from "bgent";
161+
162+
const time: Provider = {
163+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
164+
get: async (_runtime: BgentRuntime, _message: Message, _state?: State) => {
165+
const currentTime = new Date().toLocaleTimeString("en-US");
166+
return "The current time is: " + currentTime;
167+
},
168+
};
169+
170+
const runtime = new BgentRuntime({
171+
// ... other options
172+
providers: [time],
173+
});
174+
```
175+
176+
156177
## Handling User Input
157178

158179
The BgentRuntime instance has a `handleMessage` method that can be used to handle user input. The method returns a promise that resolves to the agent's response.

0 commit comments

Comments
 (0)