Skip to content

Commit

Permalink
pass state down, make state optional
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 9, 2024
1 parent 2fdfa2c commit da24de2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bgent",
"version": "0.0.40",
"version": "0.0.41",
"private": false,
"description": "bgent. because agent was taken.",
"type": "module",
Expand Down
11 changes: 8 additions & 3 deletions src/lib/providers.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import time from "./providers/time";
import { BgentRuntime } from "./runtime";
import { type Message, type Provider } from "./types";
import { State, type Message, type Provider } from "./types";

export const defaultProviders: Provider[] = [time];

/**
* Formats provider outputs into a string which can be injected into the context.
* @param runtime The Bgent runtime object.
* @param message The incoming message object.
* @param state The current state object.
* @returns A string that concatenates the outputs of each provider.
*/
export async function getProviders(runtime: BgentRuntime, message: Message) {
export async function getProviders(
runtime: BgentRuntime,
message: Message,
state?: State,
) {
const providerResults = await Promise.all(
runtime.providers.map(async (provider) => {
return await provider.get(runtime, message);
return await provider.get(runtime, message, state);
}),
);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export class BgentRuntime {
* @param state The state of the agent.
* @returns The results of the evaluation.
*/
async evaluate(message: Message, state: State) {
async evaluate(message: Message, state?: State) {
const evaluatorPromises = this.evaluators.map(
async (evaluator: Evaluator) => {
if (!evaluator.handler) {
Expand Down

0 comments on commit da24de2

Please sign in to comment.