Skip to content

Commit

Permalink
style(tools): fix code formatting in human and IO examples
Browse files Browse the repository at this point in the history
Ref: i-am-bee#121
Signed-off-by: Matias Molinas <[email protected]>
  • Loading branch information
matiasmolinas committed Jan 7, 2025
1 parent b4b6b68 commit fe5c723
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/agents/experimental/human.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const agent = new BeeAgent({
llm,
memory: new TokenMemory({ llm }),
tools: [
new OpenMeteoTool(),
new OpenMeteoTool(),
new HumanTool({
reader: reader,
})
}),
],
});

Expand Down
8 changes: 4 additions & 4 deletions examples/helpers/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { stdin, stdout } from "node:process";
import picocolors from "picocolors";
import * as R from "remeda";
import stripAnsi from "strip-ansi";
import type { Abortable } from 'node:events';
import type { Abortable } from "node:events";

interface ReadFromConsoleInput {
fallback?: string;
Expand Down Expand Up @@ -39,7 +39,7 @@ export function createConsoleReader({
async askSingleQuestion(queryMessage: string, options?: Abortable): Promise<string> {
const answer = await rl.question(
R.piped(picocolors.cyan, picocolors.bold)(queryMessage),
options ?? { signal: undefined }
options ?? { signal: undefined },
);
return stripAnsi(answer.trim());
},
Expand All @@ -58,11 +58,11 @@ export function createConsoleReader({
rl.write(
`${picocolors.dim(`Interactive session has started. To escape, input 'q' and submit.\n`)}`,
);

for (let iteration = 1, prompt = ""; isActive; iteration++) {
prompt = await rl.question(R.piped(picocolors.cyan, picocolors.bold)(input));
prompt = stripAnsi(prompt);

if (prompt === "q") {
break;
}
Expand Down
14 changes: 8 additions & 6 deletions examples/tools/experimental/human.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@ export class HumanTool extends Tool<JSONToolOutput<HumanToolOutput>, HumanToolIn
async _run(
input: ToolInput<this>,
_options: Partial<BaseToolRunOptions>,
run: RunContext<this>
run: RunContext<this>,
): Promise<JSONToolOutput<HumanToolOutput>> {
// Use the reader from input
this.input.reader.write("HumanTool", input.message);

// Use askSingleQuestion with the signal
const userInput = await this.input.reader.askSingleQuestion("User 👤 : ", { signal: run.signal });

const userInput = await this.input.reader.askSingleQuestion("User 👤 : ", {
signal: run.signal,
});

// Return JSONToolOutput with the clarification
return new JSONToolOutput({
clarification: userInput.trim()
clarification: userInput.trim(),
});
}
}
}

0 comments on commit fe5c723

Please sign in to comment.