Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit a5fa1cd

Browse files
authored
Merge pull request open-webui#10209 from i-infra/iinf/fix-for-openrouter
[fix] no unambiguous indexing on "owned_by" - fix OpenRouter.ai
2 parents 8218906 + 5e3742f commit a5fa1cd

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

backend/open_webui/routers/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ async def generate_title(
208208
"stream": False,
209209
**(
210210
{"max_tokens": 1000}
211-
if models[task_model_id]["owned_by"] == "ollama"
211+
if models[task_model_id].get("owned_by") == "ollama"
212212
else {
213213
"max_completion_tokens": 1000,
214214
}
@@ -571,7 +571,7 @@ async def generate_emoji(
571571
"stream": False,
572572
**(
573573
{"max_tokens": 4}
574-
if models[task_model_id]["owned_by"] == "ollama"
574+
if models[task_model_id].get("owned_by") == "ollama"
575575
else {
576576
"max_completion_tokens": 4,
577577
}

backend/open_webui/utils/chat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def generate_chat_completion(
200200
except Exception as e:
201201
raise e
202202

203-
if model["owned_by"] == "arena":
203+
if model.get("owned_by") == "arena":
204204
model_ids = model.get("info", {}).get("meta", {}).get("model_ids")
205205
filter_mode = model.get("info", {}).get("meta", {}).get("filter_mode")
206206
if model_ids and filter_mode == "exclude":
@@ -253,7 +253,7 @@ async def stream_wrapper(stream):
253253
return await generate_function_chat_completion(
254254
request, form_data, user=user, models=models
255255
)
256-
if model["owned_by"] == "ollama":
256+
if model.get("owned_by") == "ollama":
257257
# Using /ollama/api/chat endpoint
258258
form_data = convert_payload_openai_to_ollama(form_data)
259259
response = await generate_ollama_chat_completion(

backend/open_webui/utils/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ async def process_chat_payload(request, form_data, metadata, user, model):
800800

801801
# Workaround for Ollama 2.0+ system prompt issue
802802
# TODO: replace with add_or_update_system_message
803-
if model["owned_by"] == "ollama":
803+
if model.get("owned_by") == "ollama":
804804
form_data["messages"] = prepend_to_first_user_message_content(
805805
rag_template(
806806
request.app.state.config.RAG_TEMPLATE, context_string, prompt

backend/open_webui/utils/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async def get_all_models(request):
142142
custom_model.base_model_id == model["id"]
143143
or custom_model.base_model_id == model["id"].split(":")[0]
144144
):
145-
owned_by = model["owned_by"]
145+
owned_by = model.get("owned_by", "unknown owner")
146146
if "pipe" in model:
147147
pipe = model["pipe"]
148148
break

backend/open_webui/utils/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_task_model_id(
2222
# Set the task model
2323
task_model_id = default_model_id
2424
# Check if the user has a custom task model and use that model
25-
if models[task_model_id]["owned_by"] == "ollama":
25+
if models[task_model_id].get("owned_by") == "ollama":
2626
if task_model and task_model in models:
2727
task_model_id = task_model
2828
else:

0 commit comments

Comments
 (0)