jeffreymeetkai commited on
Commit
b0b4938
·
verified ·
1 Parent(s): 38f413c

Update modeling_functionary.py

Browse files
Files changed (1) hide show
  1. 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 = "<|reserved_special_token_249|>"
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.strip[:-len("<|eot_id|>")] if chunk.endswith("<|eot_id|>") else chunk
85
  else:
86
  tool_calls.append(
87
  {
88
- "name": chunk[: chunk.index("\n{")],
89
- "arguments": chunk[chunk.index("\n{") + 1: -len("<|eot_id|>")] if chunk.endswith("<|eot_id|>") else chunk[chunk.index("\n{") + 1:]
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: