diff --git a/koboldcpp.py b/koboldcpp.py index afc756862..405fa5b47 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -2477,8 +2477,9 @@ def determine_tool_json_to_use(genparams, curr_ctx, assistant_message_start, is_ for name in toolnames: pollgrammar += ("" if pollgrammar=="" else " | ") pollgrammar += "\"" + name + "\"" + pollgrammar += " | \"no_tool\"" pollgrammar = r'root ::= ' + pollgrammar - decide_tool_prompt = "Which of the listed tools should be used next? Pick exactly one. (Reply directly with the selected tool's name):" + decide_tool_prompt = "Which of the listed tools should be used next? Pick exactly one. If no tool is suitable, reply no_tool. (Reply directly with the selected tool's name):" temp_poll = { "prompt": f"{curr_ctx}\n\nTool List:\n{tools_string}\n\n{decide_tool_prompt}{assistant_message_start}", "max_length":16, @@ -2491,12 +2492,15 @@ def determine_tool_json_to_use(genparams, curr_ctx, assistant_message_start, is_ temp_poll_result = generate(genparams=temp_poll) if temp_poll_result: raw = temp_poll_result['text'].lower() - for name in toolnames: - if name.lower() in raw: - used_tool_json = extract_tool_info_from_tool_array(name, tools_array) - if not args.quiet: - print(f"\nAttempting to use tool: {name}") - break + if "no_tool" in raw: + print(f"\nNo suitable tool found.") + else: + for name in toolnames: + if name.lower() in raw: + used_tool_json = extract_tool_info_from_tool_array(name, tools_array) + if not args.quiet: + print(f"\nAttempting to use tool: {name}") + break return used_tool_json