feat: Add LM Studio support and improve configuration handling #2890
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.
Description
This pull request introduces support for LM Studio as a new provider for both LLM and embedder configurations. It also refactors the code to improve configuration handling and UI consistency. The key changes include adding LM Studio-specific fields, updating configuration methods, and enhancing the UI to accommodate the new provider.
Support for LM Studio:
openmemory/api/app/routers/config.py
: Addedlmstudio_base_url
field toLLMConfig
andEmbedderConfig
models to support LM Studio server configurations. [1] [2]openmemory/api/app/utils/categorization.py
: Introduced environment variables (LM_STUDIO_API_KEY
,LM_STUDIO_BASE_URL
,LM_STUDIO_MODEL
) to configure LM Studio and updated theget_categories_for_memory
function to use the appropriate model based on the environment. [1] [2]openmemory/api/app/utils/memory.py
: Added_fix_lmstudio_urls
function to handle LM Studio URLs for Docker environments and integrated it intoget_memory_client
for LLM and embedder configurations. [1] [2] [3]Configuration Refactoring:
openmemory/api/app/routers/config.py
: Replaceddict(exclude_none=True)
withmodel_dump(exclude_none=True)
in various update methods to improve serialization consistency. [1] [2] [3] [4]UI Enhancements:
openmemory/ui/components/form-view.tsx
: Converted LLM and embedder providers from arrays to objects for better mapping and added fields for configuringlmstudio_base_url
andollama_base_url
directly in the form. [1] [2] [3] [4]openmemory/ui/store/configSlice.ts
: Updated initial state to include default values forlmstudio_base_url
andollama_base_url
in both LLM and embedder configurations. [1] [2] [3]lmstudio_base_url
toLLMConfig
andEmbedderConfig
models for LM Studio integration.model_dump
for better handling of optional fields.FormView
component to include input fields for LM Studio base URL.lmstudio_base_url
with a default value.