mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 09:46:25 +02:00
refactor: improve content extraction and encoding handling
- Enhanced Azure Document Intelligence parser to raise an error for empty or whitespace-only content. - Updated LLMRouterService to log premium model strings more clearly. - Added automatic encoding detection for file reading in document processors. - Improved error handling for empty markdown content extraction in file processors. - Refactored DocumentUploadTab component for better accessibility and user interaction.
This commit is contained in:
parent
4a51ccdc2c
commit
2f793e7a69
5 changed files with 91 additions and 33 deletions
|
|
@ -186,8 +186,12 @@ class LLMRouterService:
|
|||
if deployment:
|
||||
model_list.append(deployment)
|
||||
if config.get("billing_tier") == "premium":
|
||||
model_string = deployment["litellm_params"]["model"]
|
||||
params = deployment["litellm_params"]
|
||||
model_string = params["model"]
|
||||
premium_models.add(model_string)
|
||||
base = params.get("base_model") or config.get("model_name", "")
|
||||
if base and base != model_string:
|
||||
premium_models.add(base)
|
||||
|
||||
if not model_list:
|
||||
logger.warning("No valid LLM configs found for router initialization")
|
||||
|
|
@ -197,9 +201,9 @@ class LLMRouterService:
|
|||
instance._premium_model_strings = premium_models
|
||||
instance._router_settings = router_settings or {}
|
||||
logger.info(
|
||||
"Router pool: %d deployments (%d premium)",
|
||||
"Router pool: %d deployments, premium model strings: %s",
|
||||
len(model_list),
|
||||
len(premium_models),
|
||||
sorted(premium_models),
|
||||
)
|
||||
|
||||
# Default router settings optimized for rate limit handling
|
||||
|
|
@ -258,9 +262,18 @@ class LLMRouterService:
|
|||
def compute_premium_tokens(cls, calls: list) -> int:
|
||||
"""Sum ``total_tokens`` for calls whose model is premium."""
|
||||
instance = cls.get_instance()
|
||||
return sum(
|
||||
total = sum(
|
||||
c.total_tokens for c in calls if c.model in instance._premium_model_strings
|
||||
)
|
||||
if calls:
|
||||
call_models = [c.model for c in calls]
|
||||
logger.info(
|
||||
"[premium_tokens] call models=%s, premium_set=%s, result=%d",
|
||||
call_models,
|
||||
sorted(instance._premium_model_strings),
|
||||
total,
|
||||
)
|
||||
return total
|
||||
|
||||
@classmethod
|
||||
def _build_context_fallback_groups(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue