diff --git a/.changeset/polite-onions-return.md b/.changeset/polite-onions-return.md new file mode 100644 index 0000000000000000000000000000000000000000..f12ad89b75c48e9d8de240d34acaf7119e909183 --- /dev/null +++ b/.changeset/polite-onions-return.md @@ -0,0 +1,5 @@ +--- +"create-llama": patch +--- + +Don't need to run generate script for LlamaCloud diff --git a/templates/types/streaming/nextjs/app/components/ui/chat/widgets/LlamaCloudSelector.tsx b/templates/types/streaming/nextjs/app/components/ui/chat/widgets/LlamaCloudSelector.tsx index 49fff2609807ad4cb3134c37b6b12ee7327ecf2c..c9ed7ecb5058e6dea90ad6ed86ea3af51f807ee7 100644 --- a/templates/types/streaming/nextjs/app/components/ui/chat/widgets/LlamaCloudSelector.tsx +++ b/templates/types/streaming/nextjs/app/components/ui/chat/widgets/LlamaCloudSelector.tsx @@ -45,7 +45,7 @@ export function LlamaCloudSelector({ setRequestData, onSelect, defaultPipeline, - shouldCheckValid = true, + shouldCheckValid = false, }: LlamaCloudSelectorProps) { const { backend } = useClientConfig(); const [config, setConfig] = useState<LlamaCloudConfig>(); @@ -95,7 +95,8 @@ export function LlamaCloudSelector({ </div> ); } - if (!isValid(config) && shouldCheckValid) { + + if (shouldCheckValid && !isValid(config.projects, config.pipeline)) { return ( <p className="text-red-500"> Invalid LlamaCloud configuration. Check console logs. @@ -107,7 +108,11 @@ export function LlamaCloudSelector({ return ( <Select onValueChange={handlePipelineSelect} - defaultValue={JSON.stringify(pipeline)} + defaultValue={ + isValid(projects, pipeline, false) + ? JSON.stringify(pipeline) + : undefined + } > <SelectTrigger className="w-[200px]"> <SelectValue placeholder="Select a pipeline" /> @@ -137,26 +142,33 @@ export function LlamaCloudSelector({ ); } -function isValid(config: LlamaCloudConfig): boolean { - const { projects, pipeline } = config; +function isValid( + projects: LLamaCloudProject[] | undefined, + pipeline: PipelineConfig | undefined, + logErrors: boolean = true, +): boolean { if (!projects?.length) return false; if (!pipeline) return false; const matchedProject = projects.find( (project: LLamaCloudProject) => project.name === pipeline.project, ); if (!matchedProject) { - console.error( - `LlamaCloud project ${pipeline.project} not found. Check LLAMA_CLOUD_PROJECT_NAME variable`, - ); + if (logErrors) { + console.error( + `LlamaCloud project ${pipeline.project} not found. Check LLAMA_CLOUD_PROJECT_NAME variable`, + ); + } return false; } const pipelineExists = matchedProject.pipelines.some( (p) => p.name === pipeline.pipeline, ); if (!pipelineExists) { - console.error( - `LlamaCloud pipeline ${pipeline.pipeline} not found. Check LLAMA_CLOUD_INDEX_NAME variable`, - ); + if (logErrors) { + console.error( + `LlamaCloud pipeline ${pipeline.pipeline} not found. Check LLAMA_CLOUD_INDEX_NAME variable`, + ); + } return false; } return true;