Update app.py
Browse files
app.py
CHANGED
@@ -49,9 +49,10 @@ with st.container():
|
|
49 |
st.session_state.model = model
|
50 |
|
51 |
#renders chat history
|
52 |
-
for message in st.session_state.chat_history:
|
53 |
-
|
54 |
-
st.
|
|
|
55 |
|
56 |
|
57 |
#Set up input text field
|
@@ -66,7 +67,7 @@ with st.container():
|
|
66 |
#first_answer = chat_response.split("Human")[0] #Because of Predict it prints the whole conversation.Here we seperate the first answer only.
|
67 |
tokenized_chat = tokenizer.apply_chat_template(st.session_state.chat_history, tokenize=True, add_generation_prompt=True, return_tensors="pt")
|
68 |
#st.write(tokenizer.decode(tokenized_chat[0]))
|
69 |
-
outputs = model.generate(tokenized_chat
|
70 |
first_answer = tokenizer.decode(outputs[0][tokenized_chat.shape[1]:],skip_special_tokens=True)
|
71 |
|
72 |
with st.chat_message("assistant"):
|
|
|
49 |
st.session_state.model = model
|
50 |
|
51 |
#renders chat history
|
52 |
+
for message in st.session_state.chat_history:
|
53 |
+
if(message["role"]!= "system"):
|
54 |
+
with st.chat_message(message["role"]):
|
55 |
+
st.write(message["content"])
|
56 |
|
57 |
|
58 |
#Set up input text field
|
|
|
67 |
#first_answer = chat_response.split("Human")[0] #Because of Predict it prints the whole conversation.Here we seperate the first answer only.
|
68 |
tokenized_chat = tokenizer.apply_chat_template(st.session_state.chat_history, tokenize=True, add_generation_prompt=True, return_tensors="pt")
|
69 |
#st.write(tokenizer.decode(tokenized_chat[0]))
|
70 |
+
outputs = model.generate(tokenized_chat, max_new_tokens=128)
|
71 |
first_answer = tokenizer.decode(outputs[0][tokenized_chat.shape[1]:],skip_special_tokens=True)
|
72 |
|
73 |
with st.chat_message("assistant"):
|