Skip to content

Commit

Permalink
added different useEffect for each case
Browse files Browse the repository at this point in the history
  • Loading branch information
ChoudharyHarish committed Nov 18, 2024
1 parent db78ae2 commit a0c0f55
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions frontend/src/screens/dashboard/docsqa/main/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,24 @@ export const DocsQAProvider: React.FC<DocsQAProviderProps> = ({ children }) => {

useEffect(() => {
if (collections && collections.length) setSelectedCollection(collections[0])
}, [collections])

useEffect(() => {
if (allQueryControllers && allQueryControllers.length)
setSelectedQueryController(allQueryControllers[0])
}, [allQueryControllers])

if (allEnabledModels && allEnabledModels.length)
setSelectedQueryModel(allEnabledModels[0].name)

useEffect(() => {
if (allRetrieverOptions && allRetrieverOptions.length) {
setSelectedRetriever(allRetrieverOptions[0])
setPromptTemplate(allRetrieverOptions[0].promptTemplate)
}
}, [allRetrieverOptions])

useEffect(() => {
if (selectedRetriever)
setRetrieverConfig(JSON.stringify(selectedRetriever.config, null, 2))
}, [
collections,
allQueryControllers,
allEnabledModels,
allRetrieverOptions,
selectedRetriever,
])
}, [selectedRetriever])

const value = {
selectedQueryModel,
Expand Down

0 comments on commit a0c0f55

Please sign in to comment.