mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-27 06:12:21 +00:00
fix: misleading ask_user error when questions are not sent as a list (#32727)
When a model sent the ask_user questions as anything other than a list, for example a JSON-encoded string, the tool answered "ask_user requires 1-3 questions." The model had sent the right number of questions, so it did not understand the error and often repeated the same call in a loop. It now gets a separate error saying the questions must be an array of question objects, and the count error only appears when the count is actually wrong. Fixes #32662
This commit is contained in:
parent
1d0b782719
commit
794e57cf7e
2 changed files with 6 additions and 2 deletions
|
|
@ -539,7 +539,9 @@ async def ask_user(
|
|||
:return: JSON with status and answers keyed by question id
|
||||
"""
|
||||
try:
|
||||
if not isinstance(questions, list) or not 1 <= len(questions) <= 3:
|
||||
if not isinstance(questions, list):
|
||||
raise ValueError('ask_user questions must be an array of question objects.')
|
||||
if not 1 <= len(questions) <= 3:
|
||||
raise ValueError('ask_user requires 1-3 questions.')
|
||||
|
||||
normalized_questions = []
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ def get_ask_user_tool_calls(tool_calls: list[dict]) -> tuple[list[dict], str | N
|
|||
|
||||
def normalize_ask_user_request(arguments: dict) -> dict:
|
||||
questions = arguments.get('questions')
|
||||
if not isinstance(questions, list) or not 1 <= len(questions) <= 3:
|
||||
if not isinstance(questions, list):
|
||||
raise ValueError('ask_user questions must be an array of question objects.')
|
||||
if not 1 <= len(questions) <= 3:
|
||||
raise ValueError('ask_user requires 1-3 questions.')
|
||||
|
||||
normalized_questions = []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue