Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,15 +10,17 @@ from langchain.vectorstores import Pinecone
|
|
10 |
from langchain.prompts import PromptTemplate
|
11 |
from langchain.chains import RetrievalQA
|
12 |
import streamlit.components.v1 as components
|
|
|
13 |
|
14 |
HUGGINGFACEHUB_API_TOKEN = st.secrets['HUGGINGFACEHUB_API_TOKEN']
|
15 |
os.environ["HUGGINGFACEHUB_API_TOKEN"] = HUGGINGFACEHUB_API_TOKEN
|
|
|
16 |
|
17 |
|
18 |
@dataclass
|
19 |
class Message:
|
20 |
"""Class for keeping track of a chat message."""
|
21 |
-
origin: Literal["
|
22 |
message: str
|
23 |
|
24 |
|
@@ -74,12 +76,11 @@ def on_click_callback():
|
|
74 |
human_prompt
|
75 |
)
|
76 |
llm_response = response['result']
|
77 |
-
print(llm_response)
|
78 |
st.session_state.history.append(
|
79 |
-
Message("human", human_prompt)
|
80 |
)
|
81 |
st.session_state.history.append(
|
82 |
-
Message("ai", llm_response)
|
83 |
)
|
84 |
|
85 |
|
@@ -90,36 +91,28 @@ st.title("LegalEase Advisor Chatbot ๐ฎ๐ณ")
|
|
90 |
st.markdown(
|
91 |
"""
|
92 |
๐ **Namaste! Welcome to LegalEase Advisor!**
|
93 |
-
|
94 |
I'm here to assist you with your legal queries within the framework of Indian law. Whether you're navigating through specific legal issues or seeking general advice, I'm here to help.
|
95 |
-
|
96 |
๐ **How I Can Assist:**
|
97 |
- Answer questions on various aspects of Indian law.
|
98 |
- Guide you through legal processes relevant to India.
|
99 |
- Provide information on your rights and responsibilities as per Indian legal standards.
|
100 |
-
|
101 |
๐ **Privacy & Security:**
|
102 |
Rest assured, your privacy is of utmost importance. All interactions are confidential and secure. No personal details are stored unless you choose to create an account.
|
103 |
-
|
104 |
โ๏ธ **Disclaimer:**
|
105 |
While I can provide general information, it's essential to consult with a qualified Indian attorney for advice tailored to your specific situation.
|
106 |
-
|
107 |
๐ค **Getting Started:**
|
108 |
Feel free to ask any legal question related to Indian law, using keywords like "property rights," "labor laws," or "family law." I'm here to assist you!
|
109 |
-
|
110 |
Let's get started! How can I assist you today?
|
111 |
"""
|
112 |
)
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
chat_placeholder = st.container()
|
118 |
prompt_placeholder = st.form("chat-form")
|
119 |
|
120 |
with chat_placeholder:
|
121 |
for chat in st.session_state.history:
|
122 |
-
st.markdown(f"
|
123 |
|
124 |
with prompt_placeholder:
|
125 |
st.markdown("**Chat**")
|
@@ -134,4 +127,3 @@ with prompt_placeholder:
|
|
134 |
type="primary",
|
135 |
on_click=on_click_callback,
|
136 |
)
|
137 |
-
|
|
|
10 |
from langchain.prompts import PromptTemplate
|
11 |
from langchain.chains import RetrievalQA
|
12 |
import streamlit.components.v1 as components
|
13 |
+
import time
|
14 |
|
15 |
HUGGINGFACEHUB_API_TOKEN = st.secrets['HUGGINGFACEHUB_API_TOKEN']
|
16 |
os.environ["HUGGINGFACEHUB_API_TOKEN"] = HUGGINGFACEHUB_API_TOKEN
|
17 |
+
speed = 10
|
18 |
|
19 |
|
20 |
@dataclass
|
21 |
class Message:
|
22 |
"""Class for keeping track of a chat message."""
|
23 |
+
origin: Literal["๐ค Human", "๐จ๐ปโโ๏ธ Ai"]
|
24 |
message: str
|
25 |
|
26 |
|
|
|
76 |
human_prompt
|
77 |
)
|
78 |
llm_response = response['result']
|
|
|
79 |
st.session_state.history.append(
|
80 |
+
Message("๐ค human", human_prompt)
|
81 |
)
|
82 |
st.session_state.history.append(
|
83 |
+
Message("๐จ๐ปโโ๏ธ ai", llm_response)
|
84 |
)
|
85 |
|
86 |
|
|
|
91 |
st.markdown(
|
92 |
"""
|
93 |
๐ **Namaste! Welcome to LegalEase Advisor!**
|
|
|
94 |
I'm here to assist you with your legal queries within the framework of Indian law. Whether you're navigating through specific legal issues or seeking general advice, I'm here to help.
|
|
|
95 |
๐ **How I Can Assist:**
|
96 |
- Answer questions on various aspects of Indian law.
|
97 |
- Guide you through legal processes relevant to India.
|
98 |
- Provide information on your rights and responsibilities as per Indian legal standards.
|
|
|
99 |
๐ **Privacy & Security:**
|
100 |
Rest assured, your privacy is of utmost importance. All interactions are confidential and secure. No personal details are stored unless you choose to create an account.
|
|
|
101 |
โ๏ธ **Disclaimer:**
|
102 |
While I can provide general information, it's essential to consult with a qualified Indian attorney for advice tailored to your specific situation.
|
|
|
103 |
๐ค **Getting Started:**
|
104 |
Feel free to ask any legal question related to Indian law, using keywords like "property rights," "labor laws," or "family law." I'm here to assist you!
|
105 |
+
|
106 |
Let's get started! How can I assist you today?
|
107 |
"""
|
108 |
)
|
109 |
|
|
|
|
|
|
|
110 |
chat_placeholder = st.container()
|
111 |
prompt_placeholder = st.form("chat-form")
|
112 |
|
113 |
with chat_placeholder:
|
114 |
for chat in st.session_state.history:
|
115 |
+
st.markdown(f"{chat.origin} : {chat.message}")
|
116 |
|
117 |
with prompt_placeholder:
|
118 |
st.markdown("**Chat**")
|
|
|
127 |
type="primary",
|
128 |
on_click=on_click_callback,
|
129 |
)
|
|