Skip to content

Commit 44dd8c1

Browse files
fix: Don't need to run generate script for LlamaCloud
1 parent 407fa7b commit 44dd8c1

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

.changeset/polite-onions-return.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-llama": patch
3+
---
4+
5+
Don't need to run generate script for LlamaCloud

templates/types/streaming/nextjs/app/components/ui/chat/widgets/LlamaCloudSelector.tsx

+23-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function LlamaCloudSelector({
4545
setRequestData,
4646
onSelect,
4747
defaultPipeline,
48-
shouldCheckValid = true,
48+
shouldCheckValid = false,
4949
}: LlamaCloudSelectorProps) {
5050
const { backend } = useClientConfig();
5151
const [config, setConfig] = useState<LlamaCloudConfig>();
@@ -95,7 +95,8 @@ export function LlamaCloudSelector({
9595
</div>
9696
);
9797
}
98-
if (!isValid(config) && shouldCheckValid) {
98+
99+
if (shouldCheckValid && !isValid(config.projects, config.pipeline)) {
99100
return (
100101
<p className="text-red-500">
101102
Invalid LlamaCloud configuration. Check console logs.
@@ -107,7 +108,11 @@ export function LlamaCloudSelector({
107108
return (
108109
<Select
109110
onValueChange={handlePipelineSelect}
110-
defaultValue={JSON.stringify(pipeline)}
111+
defaultValue={
112+
isValid(projects, pipeline, false)
113+
? JSON.stringify(pipeline)
114+
: undefined
115+
}
111116
>
112117
<SelectTrigger className="w-[200px]">
113118
<SelectValue placeholder="Select a pipeline" />
@@ -137,26 +142,33 @@ export function LlamaCloudSelector({
137142
);
138143
}
139144

140-
function isValid(config: LlamaCloudConfig): boolean {
141-
const { projects, pipeline } = config;
145+
function isValid(
146+
projects: LLamaCloudProject[] | undefined,
147+
pipeline: PipelineConfig | undefined,
148+
logErrors: boolean = true,
149+
): boolean {
142150
if (!projects?.length) return false;
143151
if (!pipeline) return false;
144152
const matchedProject = projects.find(
145153
(project: LLamaCloudProject) => project.name === pipeline.project,
146154
);
147155
if (!matchedProject) {
148-
console.error(
149-
`LlamaCloud project ${pipeline.project} not found. Check LLAMA_CLOUD_PROJECT_NAME variable`,
150-
);
156+
if (logErrors) {
157+
console.error(
158+
`LlamaCloud project ${pipeline.project} not found. Check LLAMA_CLOUD_PROJECT_NAME variable`,
159+
);
160+
}
151161
return false;
152162
}
153163
const pipelineExists = matchedProject.pipelines.some(
154164
(p) => p.name === pipeline.pipeline,
155165
);
156166
if (!pipelineExists) {
157-
console.error(
158-
`LlamaCloud pipeline ${pipeline.pipeline} not found. Check LLAMA_CLOUD_INDEX_NAME variable`,
159-
);
167+
if (logErrors) {
168+
console.error(
169+
`LlamaCloud pipeline ${pipeline.pipeline} not found. Check LLAMA_CLOUD_INDEX_NAME variable`,
170+
);
171+
}
160172
return false;
161173
}
162174
return true;

0 commit comments

Comments
 (0)