mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
refac
This commit is contained in:
1 parent
924e9885fc
commit
0481ad7c2e
77 files changed
+816
-1067
No files matched your search
@@ -14,27 +14,27 @@ log = logging.getLogger(__name__)
|
||||
|
||||
# Let the right tool be given for the work at hand,
|
||||
# not the one that flatters, but the one that serves.
|
||||
def get_task_model_id(default_model_id: str, task_model: str, task_model_external: str, models) -> str:
|
||||
def get_system_model_id(default_model_id: str, system_model: str, system_model_external: str, models) -> str:
|
||||
if default_model_id.startswith('agent:'):
|
||||
# Agent sessions cannot serve ordinary completion requests for background tasks.
|
||||
return next(
|
||||
(
|
||||
model
|
||||
for model in (task_model_external, task_model)
|
||||
for model in (system_model_external, system_model)
|
||||
if model and model in models and not model.startswith('agent:')
|
||||
),
|
||||
default_model_id,
|
||||
)
|
||||
task_model_id = default_model_id
|
||||
# Use an available task model override for the local or external connection.
|
||||
if models.get(task_model_id, {}).get('connection_type') == 'local':
|
||||
if task_model and task_model in models:
|
||||
task_model_id = task_model
|
||||
system_model_id = default_model_id
|
||||
# Use an available system model override for the local or external connection.
|
||||
if models.get(system_model_id, {}).get('connection_type') == 'local':
|
||||
if system_model and system_model in models:
|
||||
system_model_id = system_model
|
||||
else:
|
||||
if task_model_external and task_model_external in models:
|
||||
task_model_id = task_model_external
|
||||
if system_model_external and system_model_external in models:
|
||||
system_model_id = system_model_external
|
||||
|
||||
return task_model_id
|
||||
return system_model_id
|
||||
|
||||
|
||||
def prompt_variables_template(template: str, variables: dict[str, str]) -> str:
|
||||
|
||||
Reference in new issue
Block a user