Skip to content

Don't need to run generate script for LlamaCloud #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-onions-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-llama": patch
---

Don't need to run generate script for LlamaCloud
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function LlamaCloudSelector({
setRequestData,
onSelect,
defaultPipeline,
shouldCheckValid = true,
shouldCheckValid = false,
}: LlamaCloudSelectorProps) {
const { backend } = useClientConfig();
const [config, setConfig] = useState<LlamaCloudConfig>();
Expand Down Expand Up @@ -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.
Expand All @@ -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" />
Expand Down Expand Up @@ -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;
Expand Down
Loading