@@ -45,7 +45,7 @@ export function LlamaCloudSelector({
45
45
setRequestData,
46
46
onSelect,
47
47
defaultPipeline,
48
- shouldCheckValid = true ,
48
+ shouldCheckValid = false ,
49
49
} : LlamaCloudSelectorProps ) {
50
50
const { backend } = useClientConfig ( ) ;
51
51
const [ config , setConfig ] = useState < LlamaCloudConfig > ( ) ;
@@ -95,7 +95,8 @@ export function LlamaCloudSelector({
95
95
</ div >
96
96
) ;
97
97
}
98
- if ( ! isValid ( config ) && shouldCheckValid ) {
98
+
99
+ if ( shouldCheckValid && ! isValid ( config . projects , config . pipeline ) ) {
99
100
return (
100
101
< p className = "text-red-500" >
101
102
Invalid LlamaCloud configuration. Check console logs.
@@ -107,7 +108,11 @@ export function LlamaCloudSelector({
107
108
return (
108
109
< Select
109
110
onValueChange = { handlePipelineSelect }
110
- defaultValue = { JSON . stringify ( pipeline ) }
111
+ defaultValue = {
112
+ isValid ( projects , pipeline , false )
113
+ ? JSON . stringify ( pipeline )
114
+ : undefined
115
+ }
111
116
>
112
117
< SelectTrigger className = "w-[200px]" >
113
118
< SelectValue placeholder = "Select a pipeline" />
@@ -137,26 +142,33 @@ export function LlamaCloudSelector({
137
142
) ;
138
143
}
139
144
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 {
142
150
if ( ! projects ?. length ) return false ;
143
151
if ( ! pipeline ) return false ;
144
152
const matchedProject = projects . find (
145
153
( project : LLamaCloudProject ) => project . name === pipeline . project ,
146
154
) ;
147
155
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
+ }
151
161
return false ;
152
162
}
153
163
const pipelineExists = matchedProject . pipelines . some (
154
164
( p ) => p . name === pipeline . pipeline ,
155
165
) ;
156
166
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
+ }
160
172
return false ;
161
173
}
162
174
return true ;
0 commit comments