Squashed 'third_party/pi/' content from commit d981de122
git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
createBashToolDefinition,
|
||||
createEditToolDefinition,
|
||||
createPowerShellToolDefinition,
|
||||
createReadToolDefinition,
|
||||
createWriteToolDefinition,
|
||||
} from "../src/core/tools/index.ts";
|
||||
|
||||
function createBuiltInTools() {
|
||||
return [
|
||||
createReadToolDefinition(process.cwd()),
|
||||
createBashToolDefinition(process.cwd()),
|
||||
createPowerShellToolDefinition(process.cwd()),
|
||||
createEditToolDefinition(process.cwd()),
|
||||
createWriteToolDefinition(process.cwd()),
|
||||
];
|
||||
}
|
||||
|
||||
describe("experimental strict built-in tools", () => {
|
||||
const originalPiExperimental = process.env.PI_EXPERIMENTAL;
|
||||
|
||||
afterEach(() => {
|
||||
if (originalPiExperimental === undefined) delete process.env.PI_EXPERIMENTAL;
|
||||
else process.env.PI_EXPERIMENTAL = originalPiExperimental;
|
||||
});
|
||||
|
||||
it("only enables strict-prefer sampling in experimental mode", () => {
|
||||
delete process.env.PI_EXPERIMENTAL;
|
||||
const normalTools = createBuiltInTools();
|
||||
process.env.PI_EXPERIMENTAL = "1";
|
||||
const experimentalTools = createBuiltInTools();
|
||||
|
||||
for (const [index, tool] of experimentalTools.entries()) {
|
||||
expect(tool.constrainedSampling).toEqual({ type: "json_schema", strict: "prefer" });
|
||||
expect(tool.parameters).toEqual(normalTools[index]?.parameters);
|
||||
expect(normalTools[index]?.constrainedSampling).toBeUndefined();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user