mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-18 08:44:57 +02:00
handle dsv4 tool call bug
This commit is contained in:
@@ -5176,12 +5176,18 @@ std::string gpttype_parse_chat_tool_calls(const std::string & generated_text,
|
||||
inputs.tool_choice = common_chat_tool_choice_parse_oaicompat(tool_choice.empty() ? "auto" : tool_choice);
|
||||
inputs.parallel_tool_calls = parallel_tool_calls;
|
||||
inputs.add_generation_prompt = true;
|
||||
// Consume reasoning (including a <think> in the generation prompt) before tools.
|
||||
inputs.reasoning_format = COMMON_REASONING_FORMAT_AUTO;
|
||||
|
||||
if(!chat_template_kwargs_json.empty())
|
||||
{
|
||||
common_json kwargs = common_json::parse(chat_template_kwargs_json);
|
||||
if(kwargs.is_object())
|
||||
{
|
||||
if(kwargs.contains("enable_thinking") && kwargs["enable_thinking"].is_boolean())
|
||||
{
|
||||
inputs.enable_thinking = kwargs["enable_thinking"].get<bool>();
|
||||
}
|
||||
for(const auto & item : kwargs.items())
|
||||
{
|
||||
inputs.chat_template_kwargs[item.key()] = item.value().dump();
|
||||
|
||||
+3
-1
@@ -5643,6 +5643,8 @@ class KcppServerRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
|
||||
utfprint("\nOutput: " + recvtxt,1)
|
||||
|
||||
# The native parser needs the full output to match reasoning in the generation prompt.
|
||||
native_toolcall_text = recvtxt
|
||||
#handle potential think tags, but only chat completions will return them. the others just drop them
|
||||
reasoningtxt = ""
|
||||
if api_format==4 or api_format==8 or api_format==9: #chat completions, responses and anthropic messages, but only chat has reasoning returned
|
||||
@@ -5668,7 +5670,7 @@ class KcppServerRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
using_openai_tools = genparams.get('using_openai_tools', False)
|
||||
if using_openai_tools:
|
||||
# first, let llama.cpp's chat parser handle known template-specific tool formats
|
||||
tool_calls = native_parse_toolcall_tags(recvtxt, genparams)
|
||||
tool_calls = native_parse_toolcall_tags(native_toolcall_text, genparams)
|
||||
# fallback: check and potentially segment multiple tags for multi-tool calls
|
||||
if not tool_calls:
|
||||
tool_calls = repack_toolcall_tags(recvtxt,genparams.get('tools', []))
|
||||
|
||||
Reference in New Issue
Block a user