Skip to content

Commit 8192cd6

Browse files
committed
handle multi tool calls
1 parent f25339c commit 8192cd6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

koboldcpp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ def transform_genparams(genparams, api_format):
23902390
attachedaudid += 1
23912391
messages_string += f"\n(Attached Audio {attachedaudid})\n"
23922392
# If last message, add any tools calls after message content and before message end token if any
2393-
if message['role'] == "user" and message_index == len(messages_array):
2393+
if (message['role'] == "user" or message['role'] == "tool") and message_index == len(messages_array):
23942394
# tools handling: Check if user is passing a openai tools array, if so add to end of prompt before assistant prompt unless tool_choice has been set to None
23952395
tools_array = genparams.get('tools', [])
23962396
chosen_tool = genparams.get('tool_choice', "auto")
@@ -2402,6 +2402,8 @@ def transform_genparams(genparams, api_format):
24022402
if chosen_tool=="auto":
24032403
# if you want a different template, you can set 'custom_tools_prompt' in the chat completions adapter as follows
24042404
custom_tools_prompt = adapter_obj.get("custom_tools_prompt", "Can the user query be answered by a listed tool above? (One word response: yes or no):")
2405+
if message['role'] == "tool":
2406+
custom_tools_prompt = adapter_obj.get("custom_tools_prompt", "Can the user query be further answered by another listed tool above? (If response is already complete, reply NO) (One word response: yes or no):")
24052407
# note: message string already contains the instruct start tag!
24062408
pollgrammar = r'root ::= "yes" | "no" | "Yes" | "No" | "YES" | "NO"'
24072409
temp_poll = {

0 commit comments

Comments
 (0)