Update modeling_functionary.py
Browse files- modeling_functionary.py +5 -4
modeling_functionary.py
CHANGED
|
@@ -66,7 +66,7 @@ class FunctionaryForCausalLM(LlamaForCausalLM):
|
|
| 66 |
)
|
| 67 |
|
| 68 |
input_ids = kwargs.pop("input_ids")
|
| 69 |
-
function_call_token = "
|
| 70 |
|
| 71 |
correct_results = []
|
| 72 |
for input_id, result in zip(input_ids, results):
|
|
@@ -80,13 +80,14 @@ class FunctionaryForCausalLM(LlamaForCausalLM):
|
|
| 80 |
continue
|
| 81 |
|
| 82 |
chunk = chunk.replace(tokenizer.pad_token, "")
|
|
|
|
| 83 |
if i == 0 and has_text is not False:
|
| 84 |
-
final_output_json["content"] = chunk.
|
| 85 |
else:
|
| 86 |
tool_calls.append(
|
| 87 |
{
|
| 88 |
-
"name": chunk[: chunk.index("
|
| 89 |
-
"arguments": chunk[chunk.index("
|
| 90 |
}
|
| 91 |
)
|
| 92 |
if len(tool_calls) > 0:
|
|
|
|
| 66 |
)
|
| 67 |
|
| 68 |
input_ids = kwargs.pop("input_ids")
|
| 69 |
+
function_call_token = "<function="
|
| 70 |
|
| 71 |
correct_results = []
|
| 72 |
for input_id, result in zip(input_ids, results):
|
|
|
|
| 80 |
continue
|
| 81 |
|
| 82 |
chunk = chunk.replace(tokenizer.pad_token, "")
|
| 83 |
+
|
| 84 |
if i == 0 and has_text is not False:
|
| 85 |
+
final_output_json["content"] = chunk.removesuffix("<|eom_id|>").removesuffix("<|eot_id|>")
|
| 86 |
else:
|
| 87 |
tool_calls.append(
|
| 88 |
{
|
| 89 |
+
"name": chunk[: chunk.index(">{")],
|
| 90 |
+
"arguments": chunk[chunk.index(">{") + 1: ].removesuffix("<|eom_id|>").removesuffix("</function>")
|
| 91 |
}
|
| 92 |
)
|
| 93 |
if len(tool_calls) > 0:
|