Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +9,26 @@ from vectorstore import load_or_build_vectorstore
|
|
| 9 |
from chain_setup import build_conversational_chain
|
| 10 |
|
| 11 |
def main():
|
| 12 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Paths and constants
|
| 15 |
local_file = "Policies001.pdf"
|
| 16 |
index_folder = "faiss_index"
|
| 17 |
|
| 18 |
-
|
| 19 |
# Step 1: Load Embeddings
|
| 20 |
embeddings = load_embeddings()
|
| 21 |
|
|
@@ -34,7 +47,8 @@ def main():
|
|
| 34 |
# Display existing messages
|
| 35 |
for msg in st.session_state["messages"]:
|
| 36 |
with st.chat_message(msg["role"]):
|
| 37 |
-
|
|
|
|
| 38 |
|
| 39 |
# Step 5: Chat Input
|
| 40 |
user_input = st.chat_input("اكتب سؤالك")
|
|
@@ -44,7 +58,7 @@ def main():
|
|
| 44 |
# a) Display user message
|
| 45 |
st.session_state["messages"].append({"role": "user", "content": user_input})
|
| 46 |
with st.chat_message("user"):
|
| 47 |
-
st.markdown(user_input)
|
| 48 |
|
| 49 |
# b) Run chain
|
| 50 |
response_dict = qa_chain({"question": user_input})
|
|
@@ -53,7 +67,7 @@ def main():
|
|
| 53 |
# c) Display assistant response
|
| 54 |
st.session_state["messages"].append({"role": "assistant", "content": answer})
|
| 55 |
with st.chat_message("assistant"):
|
| 56 |
-
st.markdown(answer)
|
| 57 |
|
| 58 |
if __name__ == "__main__":
|
| 59 |
main()
|
|
|
|
| 9 |
from chain_setup import build_conversational_chain
|
| 10 |
|
| 11 |
def main():
|
| 12 |
+
st.set_page_config(page_title="المحادثة التفاعلية", layout="wide")
|
| 13 |
+
st.title("💬 المحادثة التفاعلية - ادارة البيانات وحماية البيانات الشخصية")
|
| 14 |
+
|
| 15 |
+
# Add custom CSS to support right-to-left text
|
| 16 |
+
st.markdown(
|
| 17 |
+
"""
|
| 18 |
+
<style>
|
| 19 |
+
.rtl {
|
| 20 |
+
direction: rtl;
|
| 21 |
+
text-align: right;
|
| 22 |
+
}
|
| 23 |
+
</style>
|
| 24 |
+
""",
|
| 25 |
+
unsafe_allow_html=True,
|
| 26 |
+
)
|
| 27 |
|
| 28 |
# Paths and constants
|
| 29 |
local_file = "Policies001.pdf"
|
| 30 |
index_folder = "faiss_index"
|
| 31 |
|
|
|
|
| 32 |
# Step 1: Load Embeddings
|
| 33 |
embeddings = load_embeddings()
|
| 34 |
|
|
|
|
| 47 |
# Display existing messages
|
| 48 |
for msg in st.session_state["messages"]:
|
| 49 |
with st.chat_message(msg["role"]):
|
| 50 |
+
# Apply 'rtl' class for RTL text direction
|
| 51 |
+
st.markdown(f'<div class="rtl">{msg["content"]}</div>', unsafe_allow_html=True)
|
| 52 |
|
| 53 |
# Step 5: Chat Input
|
| 54 |
user_input = st.chat_input("اكتب سؤالك")
|
|
|
|
| 58 |
# a) Display user message
|
| 59 |
st.session_state["messages"].append({"role": "user", "content": user_input})
|
| 60 |
with st.chat_message("user"):
|
| 61 |
+
st.markdown(f'<div class="rtl">{user_input}</div>', unsafe_allow_html=True)
|
| 62 |
|
| 63 |
# b) Run chain
|
| 64 |
response_dict = qa_chain({"question": user_input})
|
|
|
|
| 67 |
# c) Display assistant response
|
| 68 |
st.session_state["messages"].append({"role": "assistant", "content": answer})
|
| 69 |
with st.chat_message("assistant"):
|
| 70 |
+
st.markdown(f'<div class="rtl">{answer}</div>', unsafe_allow_html=True)
|
| 71 |
|
| 72 |
if __name__ == "__main__":
|
| 73 |
main()
|