fix(reranker): support nested llm config in LLMReranker for non-OpenAI providers#4405
Merged
whysosaket merged 2 commits intomainfrom Mar 19, 2026
Merged
Conversation
Member
|
Please add tests. |
whysosaket
approved these changes
Mar 19, 2026
This was referenced Mar 19, 2026
jamebobob
pushed a commit
to jamebobob/mem0-vigil-recall
that referenced
this pull request
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
LLMRerankerConfigto accept a nestedllmdict configLLMRerankerto forward provider-specific settings (e.g.ollama_base_url) from nested config toLlmFactoryFixes #3768
Problem
When configuring
llm_rerankerwith a nested LLM provider like Ollama:The nested provider/model/URL were silently ignored because:
LLMRerankerConfighad nollmfield — Pydantic silently dropped the dictLLMReranker.__init__hardcoded only 4 fields (model,temperature,max_tokens,api_key)ollama_base_urlwere never forwardedprovider="openai"/model="gpt-4o-mini", causing 401 errorsChanges
mem0/configs/rerankers/llm.py— Addedllm: Optional[Dict[str, Any]]field to accept nested LLM configmem0/reranker/llm_reranker.py— Whenconfig.llmis provided, use nested provider and config dict (includingollama_base_url,model, etc.) to create the LLM viaLlmFactory.create(). Falls back to original flat-field behavior when no nested dict is present.Test plan
llm_rerankerwith nested Ollama config — reranker uses Ollama instead of OpenAIllm_rerankerwith flat config (no nestedllm) — backward compatibility preservedollama_base_urlforwarded correctlymodel,temperature,max_tokens,api_keydefaults applied symmetrically in both paths