mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 02:27:10 +00:00
Dynamically update added files when upload in agent creation
This commit is contained in:
parent
e10a0571ff
commit
c7638a783e
1 changed files with 4 additions and 4 deletions
|
@ -246,7 +246,6 @@ function AgentCard(props: AgentCardProps) {
|
||||||
body: JSON.stringify(values),
|
body: JSON.stringify(values),
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(response);
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
form.reset();
|
form.reset();
|
||||||
setShowModal(false);
|
setShowModal(false);
|
||||||
|
@ -660,6 +659,8 @@ function AgentModificationForm(props: AgentModificationFormProps) {
|
||||||
const [uploading, setUploading] = useState(false);
|
const [uploading, setUploading] = useState(false);
|
||||||
const [progressValue, setProgressValue] = useState(0);
|
const [progressValue, setProgressValue] = useState(0);
|
||||||
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
||||||
|
const [allFileOptions, setAllFileOptions] = useState<string[]>(props.filesOptions);
|
||||||
|
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -682,6 +683,7 @@ function AgentModificationForm(props: AgentModificationFormProps) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (uploadedFiles.length > 0) {
|
if (uploadedFiles.length > 0) {
|
||||||
handleAgentFileChange(uploadedFiles);
|
handleAgentFileChange(uploadedFiles);
|
||||||
|
setAllFileOptions((prev) => [...prev, ...uploadedFiles]);
|
||||||
}
|
}
|
||||||
}, [uploadedFiles]);
|
}, [uploadedFiles]);
|
||||||
|
|
||||||
|
@ -1028,7 +1030,7 @@ function AgentModificationForm(props: AgentModificationFormProps) {
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>No files found.</CommandEmpty>
|
<CommandEmpty>No files found.</CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
{props.filesOptions.map((file) => (
|
{allFileOptions.map((file) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
value={file}
|
value={file}
|
||||||
key={file}
|
key={file}
|
||||||
|
@ -1284,8 +1286,6 @@ function CreateAgentCard(props: CreateAgentCardProps) {
|
||||||
}, [props.selectedChatModelOption, props.data]);
|
}, [props.selectedChatModelOption, props.data]);
|
||||||
|
|
||||||
const onSubmit = (values: z.infer<typeof EditAgentSchema>) => {
|
const onSubmit = (values: z.infer<typeof EditAgentSchema>) => {
|
||||||
console.log(JSON.stringify(values));
|
|
||||||
|
|
||||||
let agentsApiUrl = `/api/agents`;
|
let agentsApiUrl = `/api/agents`;
|
||||||
|
|
||||||
fetch(agentsApiUrl, {
|
fetch(agentsApiUrl, {
|
||||||
|
|
Loading…
Reference in a new issue