mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-06 02:48:04 +00:00
Update builtin.py (#20705)
This commit is contained in:
parent
1d343aeae4
commit
1c1f72f05c
1 changed files with 19 additions and 0 deletions
|
|
@ -1599,6 +1599,25 @@ async def query_knowledge_files(
|
|||
if not __user__:
|
||||
return json.dumps({"error": "User context not available"})
|
||||
|
||||
# Coerce parameters from LLM tool calls (may come as strings)
|
||||
if isinstance(count, str):
|
||||
try:
|
||||
count = int(count)
|
||||
except ValueError:
|
||||
count = 5 # Default fallback
|
||||
|
||||
# Handle knowledge_ids being string "None", "null", or empty
|
||||
if isinstance(knowledge_ids, str):
|
||||
if knowledge_ids.lower() in ("none", "null", ""):
|
||||
knowledge_ids = None
|
||||
else:
|
||||
# Try to parse as JSON array if it looks like one
|
||||
try:
|
||||
knowledge_ids = json.loads(knowledge_ids)
|
||||
except json.JSONDecodeError:
|
||||
# Treat as single ID
|
||||
knowledge_ids = [knowledge_ids]
|
||||
|
||||
try:
|
||||
from open_webui.models.knowledge import Knowledges
|
||||
from open_webui.models.files import Files
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue