Skip to content

Commit

Permalink
fix(agent): ignore newlines for a tool name
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <[email protected]>
  • Loading branch information
Tomas2D committed Oct 15, 2024
1 parent ed6405d commit a2c6202
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/agents/bee/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ export class BeeAgentRunner {
prefix: "Function Name:",
next: ["tool_input"],
field: new ZodParserField(
z.enum(tools.map((tool) => tool.name) as [string, ...string[]]),
z.pipeline(
z.string().trim(),
z.enum(tools.map((tool) => tool.name) as [string, ...string[]]),
),
),
},
tool_input: {
Expand Down
10 changes: 10 additions & 0 deletions src/agents/parsers/field.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ describe("Parser Fields", () => {
});

describe("Zod", () => {
it("Enum", async () => {
const values = {
apple: "apple",
};
const field = new ZodParserField(z.pipeline(z.string().trim(), z.nativeEnum(values)));
field.write(" apple\n");
await field.end();
expect(field.get()).toBe(values.apple);
});

it("Number", async () => {
const field = new ZodParserField(z.coerce.number().int());
expect(field.getPartial()).toBe("");
Expand Down

0 comments on commit a2c6202

Please sign in to comment.