Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def render_chat_history(chat_history):
|
|
27 |
for message in chat_history:
|
28 |
if(message["role"]!= "system"):
|
29 |
with st.chat_message(message["role"]):
|
30 |
-
st.
|
31 |
|
32 |
#Application
|
33 |
with st.container():
|
@@ -46,17 +46,18 @@ with st.container():
|
|
46 |
},
|
47 |
{"role": "assistant", "content": "Hello, how can I help you today?"},
|
48 |
] #Initialize chat history
|
49 |
-
|
50 |
-
|
51 |
if 'model' not in st.session_state:
|
52 |
st.session_state.model = model
|
|
|
|
|
53 |
|
54 |
#Set up input text field
|
55 |
input_text = st.chat_input(placeholder="Here you can chat with our hotel booking model.")
|
56 |
|
57 |
if input_text:
|
58 |
-
|
59 |
-
|
60 |
st.session_state.chat_history.append({"role" : "user", "content" : input_text}) #append message to chat history
|
61 |
|
62 |
#chat_response = demo_chat.demo_chain(input_text=input_text, memory=st.session_state.memory, model= chat_model)
|
@@ -66,10 +67,7 @@ with st.container():
|
|
66 |
outputs = model.generate(tokenized_chat, max_new_tokens=128)
|
67 |
first_answer = tokenizer.decode(outputs[0][tokenized_chat.shape[1]:],skip_special_tokens=True)
|
68 |
|
69 |
-
|
70 |
-
|
71 |
st.session_state.chat_history.append({"role": "assistant", "content": first_answer})
|
72 |
st.markdown('</div>', unsafe_allow_html=True)
|
73 |
-
|
74 |
-
with message_container:
|
75 |
-
render_chat_history(st.session_state.chat_history)
|
|
|
27 |
for message in chat_history:
|
28 |
if(message["role"]!= "system"):
|
29 |
with st.chat_message(message["role"]):
|
30 |
+
st.markdown(message["content"])
|
31 |
|
32 |
#Application
|
33 |
with st.container():
|
|
|
46 |
},
|
47 |
{"role": "assistant", "content": "Hello, how can I help you today?"},
|
48 |
] #Initialize chat history
|
49 |
+
|
|
|
50 |
if 'model' not in st.session_state:
|
51 |
st.session_state.model = model
|
52 |
+
|
53 |
+
render_chat_history(st.session_state.chat_history)
|
54 |
|
55 |
#Set up input text field
|
56 |
input_text = st.chat_input(placeholder="Here you can chat with our hotel booking model.")
|
57 |
|
58 |
if input_text:
|
59 |
+
with st.chat_message("user"):
|
60 |
+
st.markdown(input_text)
|
61 |
st.session_state.chat_history.append({"role" : "user", "content" : input_text}) #append message to chat history
|
62 |
|
63 |
#chat_response = demo_chat.demo_chain(input_text=input_text, memory=st.session_state.memory, model= chat_model)
|
|
|
67 |
outputs = model.generate(tokenized_chat, max_new_tokens=128)
|
68 |
first_answer = tokenizer.decode(outputs[0][tokenized_chat.shape[1]:],skip_special_tokens=True)
|
69 |
|
70 |
+
with st.chat_message("assistant"):
|
71 |
+
st.markdown(first_answer)
|
72 |
st.session_state.chat_history.append({"role": "assistant", "content": first_answer})
|
73 |
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|