Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,6 @@ from footer import footer
|
|
13 |
# Set the Streamlit page configuration and theme
|
14 |
st.set_page_config(page_title="In-Legal-IPC", layout="centered")
|
15 |
|
16 |
-
# Display the logo image
|
17 |
-
#col1, col2, col3 = st.columns([1, 30, 1])
|
18 |
-
#with col2:
|
19 |
-
# st.image("https://raw.githubusercontent.com/shiv4321/not/refs/heads/main/Banner.png", use_column_width=True)
|
20 |
-
|
21 |
-
|
22 |
# Display the logo image
|
23 |
col1, col2, col3 = st.columns([1, 30, 1])
|
24 |
with col2:
|
@@ -39,7 +33,7 @@ if "messages" not in st.session_state:
|
|
39 |
st.session_state.messages = []
|
40 |
|
41 |
if "memory" not in st.session_state:
|
42 |
-
st.session_state.memory = ConversationBufferWindowMemory(k=
|
43 |
|
44 |
@st.cache_resource
|
45 |
def load_embeddings():
|
@@ -59,7 +53,6 @@ As a legal chatbot specializing in the Indian Penal Code, you are tasked with pr
|
|
59 |
- Limit responses to essential information that directly addresses the user's question, providing concise yet comprehensive explanations.
|
60 |
- Avoid assuming specific contexts or details not provided in the query, focusing on delivering universally applicable legal interpretations unless otherwise specified.
|
61 |
- Conclude with a brief summary that captures the essence of the legal discussion and corrects any common misinterpretations related to the topic.
|
62 |
-
|
63 |
CONTEXT: {context}
|
64 |
CHAT HISTORY: {chat_history}
|
65 |
QUESTION: {question}
|
@@ -72,8 +65,6 @@ ANSWER:
|
|
72 |
</s>[INST]
|
73 |
"""
|
74 |
|
75 |
-
|
76 |
-
|
77 |
prompt = PromptTemplate(template=prompt_template,
|
78 |
input_variables=['context', 'question', 'chat_history'])
|
79 |
|
@@ -95,11 +86,18 @@ def reset_conversation():
|
|
95 |
st.session_state.messages = []
|
96 |
st.session_state.memory.clear()
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
for message in st.session_state.messages:
|
99 |
with st.chat_message(message["role"]):
|
100 |
st.write(message["content"])
|
101 |
|
102 |
-
|
103 |
input_prompt = st.chat_input("Say something...")
|
104 |
if input_prompt:
|
105 |
with st.chat_message("user"):
|
@@ -125,9 +123,5 @@ if input_prompt:
|
|
125 |
if st.button('🗑️ Reset All Chat', on_click=reset_conversation):
|
126 |
st.experimental_rerun()
|
127 |
|
128 |
-
|
129 |
-
|
130 |
# Define the CSS to style the footer
|
131 |
-
footer()
|
132 |
-
|
133 |
-
|
|
|
13 |
# Set the Streamlit page configuration and theme
|
14 |
st.set_page_config(page_title="In-Legal-IPC", layout="centered")
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
# Display the logo image
|
17 |
col1, col2, col3 = st.columns([1, 30, 1])
|
18 |
with col2:
|
|
|
33 |
st.session_state.messages = []
|
34 |
|
35 |
if "memory" not in st.session_state:
|
36 |
+
st.session_state.memory = ConversationBufferWindowMemory(k=5, memory_key="chat_history", return_messages=True)
|
37 |
|
38 |
@st.cache_resource
|
39 |
def load_embeddings():
|
|
|
53 |
- Limit responses to essential information that directly addresses the user's question, providing concise yet comprehensive explanations.
|
54 |
- Avoid assuming specific contexts or details not provided in the query, focusing on delivering universally applicable legal interpretations unless otherwise specified.
|
55 |
- Conclude with a brief summary that captures the essence of the legal discussion and corrects any common misinterpretations related to the topic.
|
|
|
56 |
CONTEXT: {context}
|
57 |
CHAT HISTORY: {chat_history}
|
58 |
QUESTION: {question}
|
|
|
65 |
</s>[INST]
|
66 |
"""
|
67 |
|
|
|
|
|
68 |
prompt = PromptTemplate(template=prompt_template,
|
69 |
input_variables=['context', 'question', 'chat_history'])
|
70 |
|
|
|
86 |
st.session_state.messages = []
|
87 |
st.session_state.memory.clear()
|
88 |
|
89 |
+
# Add the PDF button just above the chat input
|
90 |
+
st.markdown(
|
91 |
+
"[📄 PDF](https://drive.google.com/file/d/1Xkq64r4Id8qSyb5woVzdvArhzUxvKJk8/view?usp=drive_link)",
|
92 |
+
unsafe_allow_html=True
|
93 |
+
)
|
94 |
+
|
95 |
+
# Display previous messages
|
96 |
for message in st.session_state.messages:
|
97 |
with st.chat_message(message["role"]):
|
98 |
st.write(message["content"])
|
99 |
|
100 |
+
# Chat input area
|
101 |
input_prompt = st.chat_input("Say something...")
|
102 |
if input_prompt:
|
103 |
with st.chat_message("user"):
|
|
|
123 |
if st.button('🗑️ Reset All Chat', on_click=reset_conversation):
|
124 |
st.experimental_rerun()
|
125 |
|
|
|
|
|
126 |
# Define the CSS to style the footer
|
127 |
+
footer()
|
|
|
|