Skip to content

Commit 6d671d2

Browse files
authored
Use apply_chat_template to calculate tokens (#309)
1 parent 6e8bf84 commit 6d671d2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

chatglm_cpp/openai_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def tool_call(**kwargs):
209209
temperature=body.temperature,
210210
)
211211
logging.info(f'prompt: "{messages[-1].content}", sync response: "{output.content}"')
212-
prompt_tokens = len(pipeline.tokenizer.encode_messages(messages, max_context_length))
212+
prompt_tokens = len(pipeline.tokenizer.apply_chat_template(messages, max_context_length))
213213
completion_tokens = len(pipeline.tokenizer.encode(output.content, body.max_tokens))
214214

215215
finish_reason = "stop"

0 commit comments

Comments
 (0)