Zeel commited on
Commit
6ac728f
·
1 Parent(s): 71604ee

Allow usage without chat template

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -73,7 +73,9 @@ else:
73
  if chat_template is None:
74
  chat_template = text_tokenizer.chat_template
75
  if chat_template is None:
76
- raise ValueError("Chat template not found in the tokenizer. Please select a chat template from the dropdown.")
 
 
77
 
78
  with st.expander("Click to see the chat template"):
79
  st.markdown("#### Chat Template (in Jinja2 format)")
@@ -89,7 +91,10 @@ try:
89
  except:
90
  pass
91
 
92
- converted_message = text_tokenizer.apply_chat_template(message, tokenize=False, add_generation_prompt=False, chat_template=chat_template)
 
 
 
93
 
94
  st.markdown("#### Original Message")
95
  st.code(converted_message, language="html")
 
73
  if chat_template is None:
74
  chat_template = text_tokenizer.chat_template
75
  if chat_template is None:
76
+ # raise ValueError("Chat template not found in the tokenizer. Please select a chat template from the dropdown.")
77
+ import warnings
78
+ st.warning("Chat template not found in the tokenizer. Not using any chat template.")
79
 
80
  with st.expander("Click to see the chat template"):
81
  st.markdown("#### Chat Template (in Jinja2 format)")
 
91
  except:
92
  pass
93
 
94
+ if chat_template is not None:
95
+ converted_message = text_tokenizer.apply_chat_template(message, tokenize=False, add_generation_prompt=False, chat_template=chat_template)
96
+ else:
97
+ converted_message = message
98
 
99
  st.markdown("#### Original Message")
100
  st.code(converted_message, language="html")