mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-12 23:02:35 +00:00
refac
This commit is contained in:
parent
b04de83c20
commit
7cdff6b1e2
1 changed files with 9 additions and 0 deletions
|
|
@ -173,6 +173,9 @@ def get_citation_source_from_tool_result(
|
|||
|
||||
Returns a list of sources (usually one, but query_knowledge_files may return multiple).
|
||||
"""
|
||||
_EXPECTS_LIST = {"search_web", "query_knowledge_files"}
|
||||
_EXPECTS_DICT = {"view_knowledge_file"}
|
||||
|
||||
try:
|
||||
try:
|
||||
tool_result = json.loads(tool_result)
|
||||
|
|
@ -181,6 +184,12 @@ def get_citation_source_from_tool_result(
|
|||
if isinstance(tool_result, dict) and "error" in tool_result:
|
||||
return []
|
||||
|
||||
# Validate tool_result type based on what the branch expects
|
||||
if tool_name in _EXPECTS_LIST and not isinstance(tool_result, list):
|
||||
return []
|
||||
elif tool_name in _EXPECTS_DICT and not isinstance(tool_result, dict):
|
||||
return []
|
||||
|
||||
if tool_name == "search_web":
|
||||
# Parse JSON array: [{"title": "...", "link": "...", "snippet": "..."}]
|
||||
results = tool_result
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue