Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ from langchain.schema import (
|
|
7 |
SystemMessage,
|
8 |
)
|
9 |
from langchain_community.chat_models.huggingface import ChatHuggingFace
|
|
|
10 |
|
11 |
st.title("Hi, I am Chatbot Philio :mermaid:")
|
12 |
st.write("I am your hotel booking assistant for today.")
|
@@ -17,11 +18,14 @@ st.write("I am your hotel booking assistant for today.")
|
|
17 |
# base="light"
|
18 |
# primaryColor="#6b4bff"
|
19 |
|
20 |
-
model = demo_chat.load_model()
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
chat_model = ChatHuggingFace(llm=model, token=token)
|
24 |
-
print(chat_model.model_id)
|
25 |
|
26 |
#Application
|
27 |
with st.container():
|
@@ -43,7 +47,6 @@ with st.container():
|
|
43 |
with st.chat_message(message["role"]):
|
44 |
st.write(message["content"])
|
45 |
|
46 |
-
chat_model._to_chat_prompt(st.session_state.chat_history)
|
47 |
|
48 |
#Set up input text field
|
49 |
input_text = st.chat_input(placeholder="Here you can chat with our hotel booking model.")
|
@@ -54,8 +57,9 @@ with st.container():
|
|
54 |
st.session_state.chat_history.append({"role" : "user", "content" : input_text}) #append message to chat history
|
55 |
|
56 |
chat_response = demo_chat.demo_chain(input_text=input_text, memory=st.session_state.memory, model= chat_model)
|
57 |
-
first_answer = chat_response.split("Human")[0] #Because of Predict it prints the whole conversation.Here we seperate the first answer only.
|
58 |
-
|
|
|
59 |
with st.chat_message("assistant"):
|
60 |
st.write(first_answer)
|
61 |
st.session_state.chat_history.append({"role": "assistant", "content": first_answer})
|
|
|
7 |
SystemMessage,
|
8 |
)
|
9 |
from langchain_community.chat_models.huggingface import ChatHuggingFace
|
10 |
+
from transformers import pipeline
|
11 |
|
12 |
st.title("Hi, I am Chatbot Philio :mermaid:")
|
13 |
st.write("I am your hotel booking assistant for today.")
|
|
|
18 |
# base="light"
|
19 |
# primaryColor="#6b4bff"
|
20 |
|
21 |
+
tokenizer, model = demo_chat.load_model()
|
22 |
+
|
23 |
+
model_identifier = "KvrParaskevi/Hotel-Assistant-Attempt4-Llama-2-7b"
|
24 |
+
task = "text-classification" # Change this to your model's task
|
25 |
+
|
26 |
+
# Load the model using the pipeline
|
27 |
+
model_pipeline = pipeline(task, model=model,tokenizer=tokenizer)
|
28 |
|
|
|
|
|
29 |
|
30 |
#Application
|
31 |
with st.container():
|
|
|
47 |
with st.chat_message(message["role"]):
|
48 |
st.write(message["content"])
|
49 |
|
|
|
50 |
|
51 |
#Set up input text field
|
52 |
input_text = st.chat_input(placeholder="Here you can chat with our hotel booking model.")
|
|
|
57 |
st.session_state.chat_history.append({"role" : "user", "content" : input_text}) #append message to chat history
|
58 |
|
59 |
chat_response = demo_chat.demo_chain(input_text=input_text, memory=st.session_state.memory, model= chat_model)
|
60 |
+
#first_answer = chat_response.split("Human")[0] #Because of Predict it prints the whole conversation.Here we seperate the first answer only.
|
61 |
+
first_answer = model_pipeline(st.session_state.chat_history)
|
62 |
+
|
63 |
with st.chat_message("assistant"):
|
64 |
st.write(first_answer)
|
65 |
st.session_state.chat_history.append({"role": "assistant", "content": first_answer})
|