88 downloadJSON ,
99 buildEvidenceBundle ,
1010 extractSubjectsFromFiles ,
11+ buildIngestInfo ,
1112} from "./utils/llmHelpers" ;
1213import {
1314 getDatasetDescriptionPrompt ,
@@ -32,6 +33,7 @@ import {
3233 Alert ,
3334} from "@mui/material" ;
3435import { Colors } from "design/theme" ;
36+ import JSZip from "jszip" ;
3537import React , { useState , useEffect } from "react" ;
3638import { FileItem } from "redux/projects/types/projects.interface" ;
3739
@@ -214,7 +216,7 @@ const LLMPanel: React.FC<LLMPanelProps> = ({
214216 // Call 1: Generate dataset_description.json
215217 // ==========================================
216218 setStatus ( "1/3 Generating dataset_description.json..." ) ;
217- const ddPrompt = getDatasetDescriptionPrompt ( userText ) ;
219+ const ddPrompt = getDatasetDescriptionPrompt ( userText , evidenceBundle ) ;
218220
219221 let ddResponse ;
220222 if ( currentProvider . isAnthropic ) {
@@ -795,6 +797,43 @@ const LLMPanel: React.FC<LLMPanelProps> = ({
795797 URL . revokeObjectURL ( url ) ;
796798 } ;
797799
800+ const handleDownloadPackage = async ( ) => {
801+ const zip = new JSZip ( ) ;
802+ const outputDir = "bids-output" ;
803+
804+ // _staging/ files
805+ const ingestInfo = buildIngestInfo ( baseDirectoryPath , outputDir ) ;
806+ zip . file ( "_staging/ingest_info.json" , JSON . stringify ( ingestInfo , null , 2 ) ) ;
807+ zip . file ( "_staging/BIDSPlan.yaml" , bidsPlan ) ; // your already-generated YAML
808+ zip . file (
809+ "_staging/evidence_bundle.json" ,
810+ JSON . stringify ( evidenceBundle , null , 2 )
811+ ) ;
812+ // trio files (get content from the AI-generated FileItems)
813+ const dd = files . find (
814+ ( f ) => f . source === "ai" && f . name === "dataset_description.json"
815+ ) ;
816+ const readme = files . find (
817+ ( f ) => f . source === "ai" && f . name === "README.md"
818+ ) ;
819+ const participants = files . find (
820+ ( f ) => f . source === "ai" && f . name === "participants.tsv"
821+ ) ;
822+
823+ if ( dd ?. content ) zip . file ( "dataset_description.json" , dd . content ) ;
824+ if ( readme ?. content ) zip . file ( "README.md" , readme . content ) ;
825+ if ( participants ?. content )
826+ zip . file ( "participants.tsv" , participants . content ) ;
827+
828+ const blob = await zip . generateAsync ( { type : "blob" } ) ;
829+ const url = URL . createObjectURL ( blob ) ;
830+ const a = document . createElement ( "a" ) ;
831+ a . href = url ;
832+ a . download = "bids-output.zip" ;
833+ a . click ( ) ;
834+ URL . revokeObjectURL ( url ) ;
835+ } ;
836+
798837 return (
799838 < Paper
800839 sx = { {
@@ -1130,6 +1169,15 @@ const LLMPanel: React.FC<LLMPanelProps> = ({
11301169 { /* Download */ }
11311170 { bidsPlan ? "Download BIDSPlan.yaml" : "Download Script" }
11321171 </ Button >
1172+ < Button
1173+ size = "small"
1174+ startIcon = { < Download /> }
1175+ onClick = { handleDownloadPackage }
1176+ disabled = { ! bidsPlan && ! generatingTrio }
1177+ >
1178+ { /* Download */ }
1179+ Download zip file for convert
1180+ </ Button >
11331181 </ Box >
11341182
11351183 < Paper
0 commit comments