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({ ...@@ -45,7 +45,7 @@ export function LlamaCloudSelector({
setRequestData, setRequestData,
onSelect, onSelect,
defaultPipeline, defaultPipeline,
shouldCheckValid = true, shouldCheckValid = false,
}: LlamaCloudSelectorProps) { }: LlamaCloudSelectorProps) {
const { backend } = useClientConfig(); const { backend } = useClientConfig();
const [config, setConfig] = useState<LlamaCloudConfig>(); const [config, setConfig] = useState<LlamaCloudConfig>();
...@@ -95,7 +95,8 @@ export function LlamaCloudSelector({ ...@@ -95,7 +95,8 @@ export function LlamaCloudSelector({
</div> </div>
); );
} }
if (!isValid(config) && shouldCheckValid) {
if (shouldCheckValid && !isValid(config.projects, config.pipeline)) {
return ( return (
<p className="text-red-500"> <p className="text-red-500">
Invalid LlamaCloud configuration. Check console logs. Invalid LlamaCloud configuration. Check console logs.
...@@ -107,7 +108,11 @@ export function LlamaCloudSelector({ ...@@ -107,7 +108,11 @@ export function LlamaCloudSelector({
return ( return (
<Select <Select
onValueChange={handlePipelineSelect} onValueChange={handlePipelineSelect}
defaultValue={JSON.stringify(pipeline)} defaultValue={
isValid(projects, pipeline, false)
? JSON.stringify(pipeline)
: undefined
}
> >
<SelectTrigger className="w-[200px]"> <SelectTrigger className="w-[200px]">
<SelectValue placeholder="Select a pipeline" /> <SelectValue placeholder="Select a pipeline" />
...@@ -137,26 +142,33 @@ export function LlamaCloudSelector({ ...@@ -137,26 +142,33 @@ export function LlamaCloudSelector({
); );
} }
function isValid(config: LlamaCloudConfig): boolean { function isValid(
const { projects, pipeline } = config; projects: LLamaCloudProject[] | undefined,
pipeline: PipelineConfig | undefined,
logErrors: boolean = true,
): boolean {
if (!projects?.length) return false; if (!projects?.length) return false;
if (!pipeline) return false; if (!pipeline) return false;
const matchedProject = projects.find( const matchedProject = projects.find(
(project: LLamaCloudProject) => project.name === pipeline.project, (project: LLamaCloudProject) => project.name === pipeline.project,
); );
if (!matchedProject) { if (!matchedProject) {
console.error( if (logErrors) {
`LlamaCloud project ${pipeline.project} not found. Check LLAMA_CLOUD_PROJECT_NAME variable`, console.error(
); `LlamaCloud project ${pipeline.project} not found. Check LLAMA_CLOUD_PROJECT_NAME variable`,
);
}
return false; return false;
} }
const pipelineExists = matchedProject.pipelines.some( const pipelineExists = matchedProject.pipelines.some(
(p) => p.name === pipeline.pipeline, (p) => p.name === pipeline.pipeline,
); );
if (!pipelineExists) { if (!pipelineExists) {
console.error( if (logErrors) {
`LlamaCloud pipeline ${pipeline.pipeline} not found. Check LLAMA_CLOUD_INDEX_NAME variable`, console.error(
); `LlamaCloud pipeline ${pipeline.pipeline} not found. Check LLAMA_CLOUD_INDEX_NAME variable`,
);
}
return false; return false;
} }
return true; 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