mirror of
https://github.com/AJaySi/ALwrity.git
synced 2026-04-25 17:05:56 +03:00
[PR #418] [MERGED] Add explicit HF fallback policy controls and route SIF to low-cost HF models #722
Labels
No labels
AI Content Agents
AI Content Strategy
AI Content planning
AI Marketing Tools
AI SEO
AI personalization
AI writer
ALwrity Copi-lot
Alwrity web search
Anthropic
DeepSeek
Gemini AI
Integration
LLM
OnBoarding
OnBoarding
RAG knowledgebase Memory
bug
documentation
enhancement
good first issue
help wanted
invalid
openai
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ALwrity#722
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/AJaySi/ALwrity/pull/418
Author: @AJaySi
Created: 3/12/2026
Status: ✅ Merged
Merged: 3/12/2026
Merged by: @AJaySi
Base:
main← Head:codex/refactor-huggingface-response-functions📝 Commits (1)
bf19137Refine HF fallback policy controls and SIF low-cost routing📊 Changes
3 files changed (+85 additions, -20 deletions)
View changed files
📝
backend/services/intelligence/sif_agents.py(+12 -1)📝
backend/services/llm_providers/huggingface_provider.py(+41 -11)📝
backend/services/llm_providers/main_text_generation.py(+32 -8)📄 Description
Motivation
[]) to mean “only try the requested model” while preserving optional variant-stripping behavior.llm_text_gencan provide sensible, minimal premium fallbacks while allowing SIF/low-cost callers to route to cheaper HF models.Description
fallback_models: Optional[List[str]] = Noneandallow_model_variant_fallback: bool = Truetohuggingface_text_responseandhuggingface_structured_json_responseand thread those args into all model-attempt loops (including the structured no-response_formatretry path)._candidate_model_variantsto respectallow_model_variant_fallbackand update_fallback_model_sequenceto use the caller-providedfallback_modelsexactly when provided, otherwise fall back to the globalHF_FALLBACK_MODELSas a safe default.llm_text_gento acceptpreferred_hf_modelsas a caller-owned policy (first entry = requested model, remainder = fallback sequence), introducePREMIUM_HF_MINIMAL_FALLBACK_MODELSas the premium default, and passfallback_models+allow_model_variant_fallbackinto HF calls; also ensure HF fallback branch uses the minimal premium policy.SharedLLMWrapperto callllm_text_gen(..., preferred_hf_models=REMOTE_LOW_COST_HF_MODELS)and addREMOTE_LOW_COST_HF_MODELSto provide an explicit low-cost HF sequence.Testing
python -m py_compile backend/services/llm_providers/huggingface_provider.py backend/services/llm_providers/main_text_generation.py backend/services/intelligence/sif_agents.py, which completed successfully.llm_text_genandSharedLLMWrapperare passing the new HF fallback parameters and that the new constants (PREMIUM_HF_MINIMAL_FALLBACK_MODELS,REMOTE_LOW_COST_HF_MODELS) are present.Codex Task
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.