@@ -25,6 +25,7 @@ import { ALERT_TYPE } from "@/utils/types"
25
25
import { Link , useNavigate } from "react-router-dom"
26
26
import { useQueryParams } from "@/utils/routing"
27
27
import { userStore , alertStore } from "@/store"
28
+ import { fetchEmbeddingTypes } from "@/utils/api"
28
29
29
30
interface IQueryEngineProps {
30
31
token : string
@@ -45,6 +46,9 @@ const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {
45
46
const [ queryEngines , setQueryEngines ] = useState < QueryEngine [ ] > ( [ ] )
46
47
const [ queryEngine , setQueryEngine ] = useState < QueryEngine | null > ( null )
47
48
49
+ const [ createEngineIsMultimodal , setCreateEngineIsMultimodal ] = useState ( false )
50
+ const [ createEngineEmbeddingOptions , setCreateEngineEmbeddingOptions ] = useState < { option : string ; value : string ; } [ ] > ( [ ] )
51
+
48
52
const { isLoading, data : engineList } = useQuery (
49
53
[ "QueryEngines" ] ,
50
54
fetchAllEngines ( token ) ,
@@ -166,6 +170,29 @@ const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {
166
170
return < Loading />
167
171
}
168
172
173
+ const updatedQueryEngineFormData = QUERY_ENGINE_FORM_DATA . map (
174
+ ( entry ) => {
175
+ switch ( entry . name ) {
176
+ case "is_multimodal" :
177
+ return { ...entry , onClick : ( ) => { setCreateEngineIsMultimodal ( ! createEngineIsMultimodal ) } }
178
+ case "embedding_type" :
179
+ return { ...entry , options : createEngineEmbeddingOptions }
180
+ default :
181
+ return entry
182
+ }
183
+ } )
184
+
185
+ useEffect ( ( ) => {
186
+ const updateEngineEmbeddings = async ( ) => {
187
+ const llmTypes = await ( await fetchEmbeddingTypes ( token , createEngineIsMultimodal ) ) ( )
188
+ console . log ( llmTypes )
189
+ if ( llmTypes === null || llmTypes === undefined ) console . error ( "Failed to retrieve embedding types" )
190
+ else setCreateEngineEmbeddingOptions ( llmTypes . map ( ( embedding ) => { return { option : embedding , value : embedding } } ) )
191
+ }
192
+ updateEngineEmbeddings ( )
193
+ } ,
194
+ [ createEngineIsMultimodal ] )
195
+
169
196
return (
170
197
< div className = "overflow-x-auto custom-scrollbar" >
171
198
< div className = "min-h-screen" >
@@ -204,7 +231,7 @@ const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {
204
231
onFailure = { onFailure }
205
232
handleFiles = { null }
206
233
queryEngine = { queryEngine }
207
- currentVarsData = { QUERY_ENGINE_FORM_DATA }
234
+ currentVarsData = { updatedQueryEngineFormData }
208
235
/>
209
236
</ div >
210
237
0 commit comments