diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py index 6798d43145..b0746a55a9 100644 --- a/studio/backend/core/inference/llama_cpp.py +++ b/studio/backend/core/inference/llama_cpp.py @@ -2493,7 +2493,7 @@ class LlamaCppBackend: # iterations so they are not silently dropped. yield {"type": "status", "text": ""} if content_accum: - _safe = _strip_tool_markup(content_accum, final=True) + _safe = _strip_tool_markup(content_accum, final = True) if _safe.strip(): yield {"type": "content", "text": _safe} _fu = _iter_usage or {} diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py index 0c0f0929cf..99910808f8 100644 --- a/studio/backend/routes/inference.py +++ b/studio/backend/routes/inference.py @@ -1055,8 +1055,8 @@ async def openai_chat_completions( # No format instructions -- each model's chat template handles # that. Keeps tool use optional ("prefer", not "must"). tool_names = {t["function"]["name"] for t in tools_to_use} - has_web = "web_search" in tool_names - has_code = "python" in tool_names or "terminal" in tool_names + has_web = "web_search" in tool_names + has_code = "python" in tool_names or "terminal" in tool_names nudge_parts = ["You are a helpful assistant with access to tools."] if has_code and has_web: @@ -1092,6 +1092,7 @@ async def openai_chat_completions( # (the frontend may include prior assistant text # in follow-up user messages). import re as _re + _tool_xml_strip = [ _re.compile(r".*?", _re.DOTALL), _re.compile(r".*$", _re.DOTALL), @@ -1117,6 +1118,7 @@ async def openai_chat_completions( created = int(time.time()) if use_tools: + def gguf_generate_with_tools(): return llama_backend.generate_chat_completion_with_tools( messages = gguf_messages,