Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ from langchain.chains import ConversationalRetrievalChain
|
|
7 |
import time
|
8 |
import streamlit as st
|
9 |
import os
|
10 |
-
|
11 |
st.set_page_config(page_title="MBAL CHATBOT")
|
12 |
col1, col2, col3 = st.columns([1,2,1])
|
13 |
|
@@ -63,8 +63,9 @@ embeddings = HuggingFaceEmbeddings(model_name="bkai-foundation-models/vietnamese
|
|
63 |
db = FAISS.load_local("mbal_faiss_db", embeddings,allow_dangerous_deserialization= True)
|
64 |
db_retriever = db.as_retriever(search_type="similarity",search_kwargs={"k": 4})
|
65 |
|
66 |
-
prompt_template = """<s>
|
67 |
-
|
|
|
68 |
CHAT HISTORY: {chat_history}[/INST]
|
69 |
ASSISTANT:
|
70 |
</s>
|
@@ -74,7 +75,7 @@ prompt = PromptTemplate(template=prompt_template,
|
|
74 |
input_variables=['question', 'context', 'chat_history'])
|
75 |
|
76 |
|
77 |
-
llm =
|
78 |
|
79 |
# Create a conversational chain using only your database retriever
|
80 |
qa = ConversationalRetrievalChain.from_llm(
|
|
|
7 |
import time
|
8 |
import streamlit as st
|
9 |
import os
|
10 |
+
from langchain.chat_models import ChatOpenAI
|
11 |
st.set_page_config(page_title="MBAL CHATBOT")
|
12 |
col1, col2, col3 = st.columns([1,2,1])
|
13 |
|
|
|
63 |
db = FAISS.load_local("mbal_faiss_db", embeddings,allow_dangerous_deserialization= True)
|
64 |
db_retriever = db.as_retriever(search_type="similarity",search_kwargs={"k": 4})
|
65 |
|
66 |
+
prompt_template = """<s>[INST] Bạn là một chuyên viên tư vấn cho khách hàng về sản phẩm bảo hiểm của công ty MB Ageas Life tại Việt Nam. Hãy trả lời chuyên nghiệp, chính xác, cung cấp thông tin trước rồi hỏi câu tiếp theo. Tất cả các thông tin cung cấp đều trong phạm vi MBAL. Khi có đủ thông tin khách hàng thì mới mời khách hàng đăng ký để nhận tư vấn trên https://www.mbageas.life/
|
67 |
+
{context}
|
68 |
+
QUESTION: {question}
|
69 |
CHAT HISTORY: {chat_history}[/INST]
|
70 |
ASSISTANT:
|
71 |
</s>
|
|
|
75 |
input_variables=['question', 'context', 'chat_history'])
|
76 |
|
77 |
|
78 |
+
llm = ChatOpenAI(model="gpt-4o")
|
79 |
|
80 |
# Create a conversational chain using only your database retriever
|
81 |
qa = ConversationalRetrievalChain.from_llm(
|