[PR #417] [MERGED] Centralize text routing policy; set premium HF default to openai/gpt-oss-120b:groq #726

Closed
opened 2026-03-13 21:05:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AJaySi/ALwrity/pull/417
Author: @AJaySi
Created: 3/12/2026
Status: Merged
Merged: 3/12/2026
Merged by: @AJaySi

Base: mainHead: codex/create-policy-module-for-model-routing


📝 Commits (1)

  • d4528fb Add centralized text routing policy and premium HF defaults

📊 Changes

3 files changed (+62 additions, -21 deletions)

View changed files

📝 backend/services/llm_providers/huggingface_provider.py (+8 -7)
📝 backend/services/llm_providers/main_text_generation.py (+24 -14)
backend/services/llm_providers/routing_policy.py (+30 -0)

📄 Description

Motivation

  • Replace scattered hardcoded Hugging Face model/provider strings with a single routing policy to make text-routing behavior explicit and easier to maintain.
  • Ensure the premium text path defaults to openai/gpt-oss-120b:groq and support a low-cost SIF default model for the SIF flow.
  • Allow GPT_PROVIDER=wavespeed to route to the premium Hugging Face text path only, without changing existing WaveSpeed image/video behavior.

Description

  • Add backend/services/llm_providers/routing_policy.py which defines PREMIUM_DEFAULT_PROVIDER, PREMIUM_DEFAULT_MODEL (openai/gpt-oss-120b:groq), SIF_LOW_COST_MODEL_DEFAULTS, provider alias mapping (including "wavespeed": "huggingface" for text), and resolve_text_provider_alias().
  • Update backend/services/llm_providers/main_text_generation.py to use resolve_text_provider_alias() and the routing constants instead of hardcoded HF model strings, to prefer the SIF low-cost model when preferred_hf_models flow is used, and to use policy-aware fallback selection.
  • Update backend/services/llm_providers/huggingface_provider.py to consume the centralized constants for default model args, fallback model sequence (HF_FALLBACK_MODELS), and get_available_models().
  • Make API key resolution and provider checks policy-aware by resolving aliases (text-only mapping for wavespeed), while leaving WaveSpeed image/video modules unchanged.

Testing

  • python -m py_compile backend/services/llm_providers/routing_policy.py backend/services/llm_providers/main_text_generation.py backend/services/llm_providers/huggingface_provider.py succeeded.
  • A smoke import executed as PYTHONPATH=backend python - <<'PY' ... validated alias resolution and constants and confirmed resolve_text_provider_alias('wavespeed') => huggingface and the configured premium/low-cost model values (succeeded under PYTHONPATH=backend).
  • An initial direct import without setting PYTHONPATH failed due to module path context (expected in a local dev environment) and did not block the changes.

Codex Task


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AJaySi/ALwrity/pull/417 **Author:** [@AJaySi](https://github.com/AJaySi) **Created:** 3/12/2026 **Status:** ✅ Merged **Merged:** 3/12/2026 **Merged by:** [@AJaySi](https://github.com/AJaySi) **Base:** `main` ← **Head:** `codex/create-policy-module-for-model-routing` --- ### 📝 Commits (1) - [`d4528fb`](https://github.com/AJaySi/ALwrity/commit/d4528fbc74171f9a89d1972b5ea36c0845641bb3) Add centralized text routing policy and premium HF defaults ### 📊 Changes **3 files changed** (+62 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `backend/services/llm_providers/huggingface_provider.py` (+8 -7) 📝 `backend/services/llm_providers/main_text_generation.py` (+24 -14) ➕ `backend/services/llm_providers/routing_policy.py` (+30 -0) </details> ### 📄 Description ### Motivation - Replace scattered hardcoded Hugging Face model/provider strings with a single routing policy to make text-routing behavior explicit and easier to maintain. - Ensure the premium text path defaults to `openai/gpt-oss-120b:groq` and support a low-cost SIF default model for the SIF flow. - Allow `GPT_PROVIDER=wavespeed` to route to the premium Hugging Face text path only, without changing existing WaveSpeed image/video behavior. ### Description - Add `backend/services/llm_providers/routing_policy.py` which defines `PREMIUM_DEFAULT_PROVIDER`, `PREMIUM_DEFAULT_MODEL` (`openai/gpt-oss-120b:groq`), `SIF_LOW_COST_MODEL_DEFAULTS`, provider alias mapping (including `"wavespeed": "huggingface"` for text), and `resolve_text_provider_alias()`. - Update `backend/services/llm_providers/main_text_generation.py` to use `resolve_text_provider_alias()` and the routing constants instead of hardcoded HF model strings, to prefer the SIF low-cost model when `preferred_hf_models` flow is used, and to use policy-aware fallback selection. - Update `backend/services/llm_providers/huggingface_provider.py` to consume the centralized constants for default `model` args, fallback model sequence (`HF_FALLBACK_MODELS`), and `get_available_models()`. - Make API key resolution and provider checks policy-aware by resolving aliases (text-only mapping for `wavespeed`), while leaving WaveSpeed image/video modules unchanged. ### Testing - `python -m py_compile backend/services/llm_providers/routing_policy.py backend/services/llm_providers/main_text_generation.py backend/services/llm_providers/huggingface_provider.py` succeeded. - A smoke import executed as `PYTHONPATH=backend python - <<'PY' ...` validated alias resolution and constants and confirmed `resolve_text_provider_alias('wavespeed')` => `huggingface` and the configured premium/low-cost model values (succeeded under `PYTHONPATH=backend`). - An initial direct import without setting `PYTHONPATH` failed due to module path context (expected in a local dev environment) and did not block the changes. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69b0db52849083288fac2b59f7032d6e) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-13 21:05:53 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ALwrity#726
No description provided.