diff --git a/kcpp_adapters/AutoGuess.json b/kcpp_adapters/AutoGuess.json index d9a96004b..92a85a26f 100644 --- a/kcpp_adapters/AutoGuess.json +++ b/kcpp_adapters/AutoGuess.json @@ -300,6 +300,18 @@ "assistant_start": "<|im_start|>assistant\n", "assistant_end": "<|im_end|>\n" } +}, { + "search": ["[BEGIN FINAL RESPONSE]", "<|begin_user|>"], + "name": "Apriel 1.6", + "adapter": { + "system_start": "<|begin_system|>\n", + "system_end": "\n", + "user_start": "<|begin_user|>\n", + "user_end": "\n", + "assistant_start": "<|begin_assistant|>\n", + "assistant_end": "\n", + "assistant_gen": "<|begin_assistant|>\nWe can respond now.\n[BEGIN FINAL RESPONSE]\n" + } }, { "search": ["[e~[","]~b]user"], "name": "MiniMax", diff --git a/koboldcpp.py b/koboldcpp.py index cbf44780b..e99e160fc 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -185,14 +185,15 @@ thinkformats = [{"start":"<|channel|>analysis<|message|>","end":"<|start|>assist {"start":"<|START_THINKING|>","end":"<|END_THINKING|>"}, {"start":"<|channel>thought","end":""}] tool_call_pairs = [ #third element is optional str to match in chat template before we use this pair, fourth element is whether its stream-handleable - ("", "", None, True), - ("", "", None, True), - ("<|tool_call_begin|>", "<|tool_call_end|>", None, True), - ("<|tool▁call▁begin|>", "<|tool▁call▁end|>", None, True), - ("", "", None, True), - ("<|tool_call>", "", None, True), - ("<|end|><|start|>assistant<|channel|>commentary to=", "", None, False), - ("<|tool_call_start|>", "<|tool_call_end|>", None, True), + ("", "", None, True), #qwen, glm + ("", "", None, True), #seed oss + ("<|tool_call_begin|>", "<|tool_call_end|>", None, True), #kimi + ("<|tool▁call▁begin|>", "<|tool▁call▁end|>", None, True), #deepseek + ("", "", None, True), #minimax + ("<|tool_call>", "", None, True), #gemma4 + ("<|end|><|start|>assistant<|channel|>commentary to=", "", None, False), #gpt-oss + ("<|tool_call_start|>", "<|tool_call_end|>", "CONTINUE_FINAL_MESSAGE_TAG", True), #lfm2.5 + ("", "", "[BEGIN FINAL RESPONSE]", True), #apriel ] deprecated_keys = { "hordeconfig", @@ -3442,7 +3443,7 @@ def coerce_tool_argtypes(tool_calls: list, tool_list: list) -> list: return result -def toolcall_to_normalized_json(text,start_tag,end_tag): #convert weird formats into standard tool call json +def toolcall_to_normalized_json(text,start_tag,end_tag,required_match_txt): #convert weird formats into standard tool call json global cached_chat_template text = text.strip() def parse_qwen35(text: str) -> str: @@ -3586,9 +3587,12 @@ def toolcall_to_normalized_json(text,start_tag,end_tag): #convert weird formats if check_ok and len(check_ok)>0: return text #is valid JSON or parsable - if start_tag=="<|tool_call_start|>" and end_tag=="<|tool_call_end|>" and cached_chat_template and "CONTINUE_FINAL_MESSAGE_TAG" in cached_chat_template: + if start_tag=="<|tool_call_start|>" and end_tag=="<|tool_call_end|>" and cached_chat_template and (required_match_txt is None or required_match_txt in cached_chat_template): return parse_lfm25(text) + if start_tag=="" and end_tag=="" and cached_chat_template and (required_match_txt is None or required_match_txt in cached_chat_template): + return extract_json_from_string(text, True) #apriel is json + if "" in text and "" in text: # handle glm with args return parse_glm(text) @@ -3631,7 +3635,7 @@ def repack_toolcall_tags(text: str, original_tools:list): if matches: found = True for match in matches: - normalizedtc = toolcall_to_normalized_json(match.strip(),start,end) + normalizedtc = toolcall_to_normalized_json(match.strip(),start,end,required_match_txt) sub_tool_calls = extract_json_from_string(normalizedtc) tool_calls.extend(sub_tool_calls) break