Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve models and threads caching #3744

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

louis-jan
Copy link
Contributor

@louis-jan louis-jan commented Sep 30, 2024

Describe Your Changes

This PR introduces caching mechanisms for Models and Threads to enhance application performance and reduce potential risks when communicating with extensions. This would improve the app load experience a bit since it doesn't wait for the extensions function to complete its operation.

This is a very small step of Jan path to Cortex epic. Aim to apply minimal changes and add missing tests to app's state management and hook queries.

This PR also provides additional comments and clarification on using Atom for clearer state management stores.

Notes
Most of the code changes involve adding missing tests.
Next action item is to asynchronously import models from cortex.cpp.

flowchart LR
    subgraph "Chat Shell"
        direction LR
        ChatShell[Chat Shell]
    end

    subgraph "Models Cache"
        direction LR
        ModelsCache[Models Cache]
    end

    subgraph "Model Extension"
        direction LR
        ModelExt[Model Extension]
    end

    ChatShell --"Retrieve Models List"--> ModelsCache
    ModelExt --"Persists Models List"--> ModelsCache
Loading
graph LR;
    Chat_Shell  -->| Request | Threads_Cache
    Threads_Cache -->| Fetch Data | Conversation_Extension
    Conversation_Extension -->| Return Data | Threads_Cache
    Threads_Cache -->| Return Data | Chat_Shell
Loading

Related Issues

Screenshots

App still functions normally when Models and Threads fail to load from extensions
11677

Changes Made

  1. Refactoring and reorganizing model-related atoms:

    • Moved model-related atoms from Thread.atom.ts to Model.atom.ts
    • Created new ModelStorageAtomKeys enum for storage keys
    • Added new atoms like downloadedModelsAtom, configuredModelsAtom, etc.
  2. Added new test files for various hooks:

    • useAssistant.test.ts
    • useClipboard.test.ts
    • useDeleteModel.test.ts
    • useDeleteThread.test.ts
    • useDownloadModel.test.ts
    • useDropModelBinaries.test.ts
    • useFactoryReset.test.ts
    • useGetHFRepoData.test.ts
    • useGetSystemResources.test.ts
    • useGpuSetting.test.ts
    • useImportModel.test.ts
    • useLoadTheme.test.ts
    • useLogs.test.ts
    • useModels.test.ts
    • useThread.test.ts
  3. Updated existing hooks and components:

    • Modified useModels.ts to use new atom structure
    • Updated useSetActiveThread.ts and useUpdateModelParameters.ts to use ModelParams from new location
  4. Added new types:

    • Created model.d.ts to define ModelParams type
  5. Minor fixes and improvements:

    • Fixed typo in ModelDropdown component (isdDownloaded -> isDownloaded)
    • Removed unused BottomPanel.atom.ts file

Overall, this diff focuses on reorganizing model-related state management, adding extensive test coverage for hooks, and making minor improvements to existing components and types.

@github-actions github-actions bot added the type: chore Maintenance, operational label Sep 30, 2024
Copy link
Contributor

@louis-jan louis-jan merged commit 87e1754 into dev Oct 1, 2024
11 checks passed
@louis-jan louis-jan deleted the feat/models-and-threads-cache-on-storage branch October 1, 2024 03:15
@github-actions github-actions bot added this to the v0.5.5 milestone Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore Maintenance, operational
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants