Skip to content

Commit

Permalink
fix(code-interpreter): avoid crash when no files supplied (#97)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Pokorný <[email protected]>
  • Loading branch information
JanPokorny authored Oct 16, 2024
1 parent 75bead8 commit 60c3317
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/tools/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ export class PythonTool extends Tool<PythonToolOutput, PythonToolOptions> {
): asserts rawInput is ToolInput<this> {
super.validateInput(schema, rawInput);

const fileNames = (rawInput.inputFiles as { filename: string }[])
?.map(({ filename }) => filename)
.filter(Boolean) as string[];
const fileNames: string[] =
(rawInput.inputFiles as { filename: string }[])
?.map(({ filename }) => filename)
.filter(Boolean) ?? [];
const diff = differenceWith(fileNames, unique(fileNames), isShallowEqual);
if (diff.length > 0) {
throw new ToolInputValidationError(
Expand Down

0 comments on commit 60c3317

Please sign in to comment.