mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
refac
This commit is contained in:
1 parent
9c54711cc6
commit
705d1aeaf2
1 file changed
+13
-1
+13
-1
@@ -505,6 +505,11 @@ _UTILITY_PATTERNS = [
|
||||
"tags_generation",
|
||||
]
|
||||
|
||||
_UTILITY_MODEL_CONFIG_KEYS = {
|
||||
"summary_generation": "chat.context_compaction.model",
|
||||
"title_generation": "chat.title_generation.model",
|
||||
}
|
||||
|
||||
|
||||
async def _intercept_task(
|
||||
request: Request,
|
||||
@@ -694,6 +699,13 @@ async def _resolve_utility_model(request: Request, workspace: str, app_state=Non
|
||||
)
|
||||
|
||||
candidates: list[str] = []
|
||||
task_header = request.headers.get(OWUI_TASK_HEADER, "").strip()
|
||||
preferred_config_key = _UTILITY_MODEL_CONFIG_KEYS.get(task_header)
|
||||
if preferred_config_key:
|
||||
preferred_model = await Config.get(preferred_config_key)
|
||||
if isinstance(preferred_model, str) and preferred_model.strip():
|
||||
candidates.append(preferred_model.strip())
|
||||
|
||||
gateway_model = await Config.get("gateway.model")
|
||||
if isinstance(gateway_model, str) and gateway_model.strip():
|
||||
candidates.append(gateway_model.strip())
|
||||
@@ -710,7 +722,7 @@ async def _resolve_utility_model(request: Request, workspace: str, app_state=Non
|
||||
if isinstance(default_model, str) and default_model.strip():
|
||||
candidates.append(default_model.strip())
|
||||
|
||||
for model_id in candidates:
|
||||
for model_id in dict.fromkeys(candidates):
|
||||
try:
|
||||
target = await resolve_model_target(model_id, app_state)
|
||||
if isinstance(target, ApiModelTarget):
|
||||
|
||||
Reference in new issue
Block a user