Add centralized text routing policy and premium HF defaults
This commit is contained in:
@@ -70,6 +70,7 @@ else:
|
||||
|
||||
from loguru import logger
|
||||
from utils.logger_utils import get_service_logger
|
||||
from .routing_policy import PREMIUM_DEFAULT_MODEL, SIF_LOW_COST_MODEL_DEFAULTS
|
||||
|
||||
# Use service-specific logger to avoid conflicts
|
||||
logger = get_service_logger("huggingface_provider")
|
||||
@@ -90,10 +91,10 @@ except ImportError:
|
||||
logger.warn("OpenAI library not available. Install with: pip install openai")
|
||||
|
||||
HF_FALLBACK_MODELS = [
|
||||
"openai/gpt-oss-120b:groq",
|
||||
PREMIUM_DEFAULT_MODEL,
|
||||
"moonshotai/Kimi-K2-Instruct-0905:groq",
|
||||
"meta-llama/Llama-3.1-8B-Instruct:groq",
|
||||
"mistralai/Mistral-7B-Instruct-v0.3:groq",
|
||||
SIF_LOW_COST_MODEL_DEFAULTS[0],
|
||||
]
|
||||
|
||||
|
||||
@@ -140,7 +141,7 @@ def get_huggingface_api_key() -> str:
|
||||
@retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(6))
|
||||
def huggingface_text_response(
|
||||
prompt: str,
|
||||
model: str = "openai/gpt-oss-120b:groq",
|
||||
model: str = PREMIUM_DEFAULT_MODEL,
|
||||
temperature: float = 0.7,
|
||||
max_tokens: int = 2048,
|
||||
top_p: float = 0.9,
|
||||
@@ -175,7 +176,7 @@ def huggingface_text_response(
|
||||
Example:
|
||||
result = huggingface_text_response(
|
||||
prompt="Write a blog post about AI",
|
||||
model="openai/gpt-oss-120b:groq",
|
||||
model=PREMIUM_DEFAULT_MODEL,
|
||||
temperature=0.7,
|
||||
max_tokens=2048,
|
||||
system_prompt="You are a professional content writer."
|
||||
@@ -274,7 +275,7 @@ def huggingface_text_response(
|
||||
def huggingface_structured_json_response(
|
||||
prompt: str,
|
||||
schema: Dict[str, Any],
|
||||
model: str = "openai/gpt-oss-120b:groq",
|
||||
model: str = PREMIUM_DEFAULT_MODEL,
|
||||
temperature: float = 0.7,
|
||||
max_tokens: int = 8192,
|
||||
system_prompt: Optional[str] = None
|
||||
@@ -491,12 +492,12 @@ def get_available_models() -> list:
|
||||
list: List of available model identifiers
|
||||
"""
|
||||
return [
|
||||
"openai/gpt-oss-120b:groq",
|
||||
PREMIUM_DEFAULT_MODEL,
|
||||
"moonshotai/Kimi-K2-Instruct-0905:groq",
|
||||
"Qwen/Qwen2.5-VL-7B-Instruct",
|
||||
"meta-llama/Llama-3.1-8B-Instruct:groq",
|
||||
"microsoft/Phi-3-medium-4k-instruct:groq",
|
||||
"mistralai/Mistral-7B-Instruct-v0.3:groq"
|
||||
SIF_LOW_COST_MODEL_DEFAULTS[0]
|
||||
]
|
||||
|
||||
def validate_model(model: str) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user