Skip to content
Snippets Groups Projects
Unverified Commit 7f4ac228 authored by Marcus Schiesser's avatar Marcus Schiesser Committed by GitHub
Browse files

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

parent 5263bde8
No related branches found
No related tags found
No related merge requests found
---
"create-llama": patch
---
Don't need to run generate script for LlamaCloud
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment