saffr0n commited on
Commit
2c169bc
1 Parent(s): d15fd17

Log the conversation

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -58,6 +58,8 @@ def generate(
58
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
59
  conversation.append({"role": "user", "content": message})
60
  input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
 
 
61
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
62
  input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
63
  gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
 
58
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
59
  conversation.append({"role": "user", "content": message})
60
  input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
61
+ print(tokenizer.apply_chat_template(conversation, tokenize=False))
62
+ print(conversation)
63
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
64
  input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
65
  gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")