Skip to content

Commit

Permalink
add providers to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 2, 2024
1 parent 0da01a6 commit 863f644
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,32 @@ const runtime = new BgentRuntime({
evaluators: [fact],
});

// You can also register actions and evaluators after the runtime has been created
// OR you can register actions and evaluators after the runtime has been created
bgentRuntime.registerAction(wait);
bgentRuntime.registerEvaluator(fact);
```

## Custom Data Sources
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.

```typescript
import { type BgentRuntime, type Message, type Provider, type State } from "bgent";

const time: Provider = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
get: async (_runtime: BgentRuntime, _message: Message, _state?: State) => {
const currentTime = new Date().toLocaleTimeString("en-US");
return "The current time is: " + currentTime;
},
};

const runtime = new BgentRuntime({
// ... other options
providers: [time],
});
```


## Handling User Input

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.
Expand Down

0 comments on commit 863f644

Please sign in to comment.