fix: sync model picker search terms with selected models

Added useEffect hooks to GlamaModelPicker, OpenAiModelPicker, and OpenRouterModelPicker components to ensure the search term stays synchronized with the selected model ID from apiConfiguration. This prevents the search term from getting out of sync when the model is changed.
This commit is contained in:
sam hoang
2025-01-08 07:53:56 +07:00
committed by Matt Rubens
parent 921f8844eb
commit f39eaa14ff
3 changed files with 25 additions and 0 deletions

View File

@@ -28,6 +28,14 @@ const OpenAiModelPicker: React.FC = () => {
setSearchTerm(newModelId)
}
useEffect(() => {
if (apiConfiguration?.openAiModelId) {
if (apiConfiguration?.openAiModelId !== searchTerm) {
setSearchTerm(apiConfiguration?.openAiModelId)
}
}
}, [apiConfiguration, searchTerm])
useEffect(() => {
if (!apiConfiguration?.openAiBaseUrl || !apiConfiguration?.openAiApiKey) {
return