Skip to content

Commit

Permalink
Merge pull request #121 from langchain-ai/nc/28dec/fix-file-upload
Browse files Browse the repository at this point in the history
Fix 2 issues in file upload
  • Loading branch information
nfcampos authored Dec 28, 2023
2 parents 994b00b + f589bf9 commit adee73a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions frontend/src/components/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ function PublicLink(props: { assistantId: string }) {
);
}

function fileId(file: File) {
return `${file.name}-${file.size}-${file.lastModified}`;
}

export function Config(props: {
configSchema: Schemas["configSchema"];
configDefaults: Schemas["configDefaults"];
Expand Down Expand Up @@ -227,8 +231,9 @@ export function Config(props: {
],
},
}));
const acceptedFileIds = dropzone.acceptedFiles.map(fileId);
setFiles((files) => [
...files.filter((f) => !dropzone.acceptedFiles.includes(f)),
...files.filter((f) => !acceptedFileIds.includes(fileId(f))),
...dropzone.acceptedFiles,
]);
}
Expand Down Expand Up @@ -257,12 +262,7 @@ export function Config(props: {
const key = form.key.value;
if (!key) return;
setInflight(true);
await props.saveConfig(
key,
values!,
dropzone.acceptedFiles,
isPublic
);
await props.saveConfig(key, values!, files, isPublic);
setInflight(false);
}}
>
Expand Down

0 comments on commit adee73a

Please sign in to comment.