gabruarya commited on
Commit
6ce5bf7
โ€ข
1 Parent(s): 128d8a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -15
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["human", "ai"]
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"From {chat.origin} : {chat.message}")
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
  )