File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1599,6 +1599,25 @@ async def query_knowledge_files(
15991599 if not __user__ :
16001600 return json .dumps ({"error" : "User context not available" })
16011601
1602+ # Coerce parameters from LLM tool calls (may come as strings)
1603+ if isinstance (count , str ):
1604+ try :
1605+ count = int (count )
1606+ except ValueError :
1607+ count = 5 # Default fallback
1608+
1609+ # Handle knowledge_ids being string "None", "null", or empty
1610+ if isinstance (knowledge_ids , str ):
1611+ if knowledge_ids .lower () in ("none" , "null" , "" ):
1612+ knowledge_ids = None
1613+ else :
1614+ # Try to parse as JSON array if it looks like one
1615+ try :
1616+ knowledge_ids = json .loads (knowledge_ids )
1617+ except json .JSONDecodeError :
1618+ # Treat as single ID
1619+ knowledge_ids = [knowledge_ids ]
1620+
16021621 try :
16031622 from open_webui .models .knowledge import Knowledges
16041623 from open_webui .models .files import Files
You can’t perform that action at this time.
0 commit comments