diff --git a/enhanced/vlm.py b/enhanced/vlm.py index f945d588..d31e8044 100644 --- a/enhanced/vlm.py +++ b/enhanced/vlm.py @@ -251,7 +251,7 @@ def _extract_openai_compatible_text(response): return "" message = choices[0].get("message") if isinstance(choices[0], dict) else {} content = message.get("content") if isinstance(message, dict) else "" - if isinstance(content, str): + if isinstance(content, str) and content.strip(): return content if isinstance(content, list): parts = [] @@ -262,7 +262,15 @@ def _extract_openai_compatible_text(response): parts.append(str(item.get("text") or "")) elif isinstance(item.get("content"), str): parts.append(item.get("content")) - return "\n".join([part for part in parts if part]) + text = "\n".join([part for part in parts if part]) + if text.strip(): + return text + reasoning = message.get("reasoning_content") if isinstance(message, dict) else "" + if isinstance(reasoning, str) and reasoning.strip() and reasoning.strip() != "None": + return reasoning + reasoning = message.get("reasoning") if isinstance(message, dict) else "" + if isinstance(reasoning, str) and reasoning.strip() and reasoning.strip() != "None": + return reasoning return str(content or "") @@ -756,6 +764,7 @@ def inference_custom(self, image, prompt, max_tokens=2048, temperature=0.7, top_ "top_p": float(top_p), "max_tokens": int(max_tokens), "stream": False, + "chat_template_kwargs": {"enable_thinking": False}, } try: seed_value = int(seed) diff --git a/javascript/describe_vlm_chat.js b/javascript/describe_vlm_chat.js index ec14220e..135948e0 100644 --- a/javascript/describe_vlm_chat.js +++ b/javascript/describe_vlm_chat.js @@ -611,6 +611,8 @@ const version = cleanVlmVersion(raw); const customPanel = componentHost('describe_vlm_custom_panel'); if (version === 'Custom' || isVisible(customPanel)) return 'Custom'; + const customModel = String(readComponentValue('describe_vlm_custom_model') || '').trim(); + if (customModel && version === customModel) return 'Custom'; return version; } diff --git a/webui.py b/webui.py index c2a284c4..82318942 100644 --- a/webui.py +++ b/webui.py @@ -360,7 +360,7 @@ def _main_vlm_save_admin_version(version, state, request=None): def _main_vlm_save_selected_version(version, state, persist_admin=False, request=None): version = _vlm_resolve_version(version) _main_vlm_write_local_settings({"version": version}) - if persist_admin and version != VLM.CUSTOM_VERSION: + if persist_admin: _main_vlm_save_admin_version(version, state, request=request) return version