chore: refactor - clean out useEngines - mutate swr to update #4476
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe Your Changes
Refactor the engine state management to solely utilize the SWR hook. Deprecate the useEngines and installed engine atom functions to establish a consistent state management and data fetching mechanism.
Added a minor model settings where anthropic remote models should support stream by default.
Self Checklist
This pull request includes several important changes focused on streamlining engine management and updating how engines are handled across various components. The changes involve replacing the
installedEnginesAtom
with theuseGetEngines
hook and making corresponding updates in multiple files.Engine Management Updates:
web/containers/Layout/BottomPanel/SystemMonitor/TableActiveModel/index.tsx
: Replaced the use ofinstalledEnginesAtom
withuseGetEngines
to fetch engine data.web/containers/ModelDropdown/index.tsx
: Updated engine fetching logic to use theuseGetEngines
hook instead ofinstalledEnginesAtom
and added conditions to handle engine type and API key validation. [1] [2] [3] [4]web/containers/Providers/DataLoader.tsx
: Removed theuseEngines
hook and replaced it withuseGetEngines
, adding a debounced callback to handle engine updates. [1] [2] [3]web/containers/Providers/ModelHandler.tsx
: ReplacedinstalledEnginesAtom
withuseGetEngines
and updated the logic to handle engine types correctly. [1] [2] [3] [4] [5]web/hooks/useRecommendedModel.ts
: Updated to use theuseGetEngines
hook and added filtering logic to ensure only valid engines are considered. [1] [2] [3] [4] [5]Removal of Deprecated Code:
web/hooks/useEngines.ts
: Removed the entireuseEngines
hook as it has been replaced byuseGetEngines
.Configuration and Utility Updates:
web/hooks/useConfigurations.ts
: Added a comment to disable the eslint rule for exhaustive dependencies in theuseEffect
hook.web/hooks/useStarterScreen.ts
: Updated to use theuseGetEngines
hook and disabled eslint for unused variables.Other Minor Changes:
web/screens/Hub/ModelList/index.tsx
: Updated to use theuseGetEngines
hook and adjusted logic for sorting models based on engine type. [1] [2] [3] [4]web/screens/LocalServer/LocalServerLeftPanel/index.tsx
: Updated engine fetching logic to useInferenceEngine.cortex
. [1] [2]web/screens/Settings/Engines/RemoteEngineSettings.tsx
: Disabled eslint for unused variables.These changes collectively improve the consistency and reliability of engine management across the codebase.