mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-28 16:11:43 -05:00
fix: saving a router model strips the trailing space from a pattern (#34957)
A pattern like "```|def |function " (the example in the docs) lost its trailing space when the router model was saved, from the dialog or through the API. "function" without a space after it then matched as well, so a message about "functionality" went to the model meant for code. Patterns are now saved exactly as typed, and a pattern saved before this needs its space typed again. Conditions saved through the API now keep their spaces as sent too. Fixes #34898
This commit is contained in:
1 parent
bb98273f9e
commit
179991fc1a
2 files changed
+2
-2
No files matched your search
@@ -733,7 +733,7 @@ class RouterModelRoute(BaseModel):
|
||||
@field_validator('condition', 'pattern', mode='before')
|
||||
@classmethod
|
||||
def normalize_empty(cls, value):
|
||||
return (value or '').strip() or None
|
||||
return value if (value or '').strip() else None
|
||||
|
||||
@model_validator(mode='after')
|
||||
def validate_match(self):
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
const routes = [
|
||||
...patternRoutes
|
||||
.filter((route) => route.model_id && route.pattern.trim())
|
||||
.map((route) => ({ model_id: route.model_id, pattern: route.pattern.trim() })),
|
||||
.map((route) => ({ model_id: route.model_id, pattern: route.pattern })),
|
||||
...conditions.map((route) => ({
|
||||
model_id: route.model_id,
|
||||
condition: route.condition.trim()
|
||||
|
||||
Reference in new issue
Block a user