kamau1 commited on
Commit
115f014
·
verified ·
1 Parent(s): e5c9659

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -27,7 +27,7 @@ os.environ["HUGGINGFACEHUB_API_TOKEN"] = st.secrets['huggingface_token']
27
  st.set_page_config(page_title="SemaNaPDF", page_icon="📚",)
28
 
29
  # Sema Translator
30
- #Public_Url = os.environ["sema_url"] #endpoint
31
 
32
  def translate(userinput, target_lang, source_lang=None):
33
  if source_lang:
@@ -130,18 +130,22 @@ def main():
130
  if user_question := st.chat_input("Ask your document anything ......?"):
131
  with st.chat_message("user"):
132
  st.markdown(user_question)
 
 
133
  st.session_state.messages.append({"role": "user", "content": user_question})
134
- response = st.session_state.conversation({"question": user_question})
135
  st.session_state.chat_history = response["chat_history"]
 
 
136
  with st.chat_message("assistant"):
137
- st.markdown(response)
138
  st.session_state.messages.append({"role": "assistant", "content": response})
139
 
140
  # Signature
141
  st.markdown(
142
  """
143
  <div style="position: fixed; bottom: 0; right: 0; padding: 10px;">
144
- <a href="https://kamaukimaru.vercel.app" target="_blank" rel="noopener noreferrer" style="font-size: 12px; color: #808080; text-decoration: none;">©2023 Lewis Kimaru. All rights reserved.</a>
145
  </div>
146
  """,
147
  unsafe_allow_html=True
 
27
  st.set_page_config(page_title="SemaNaPDF", page_icon="📚",)
28
 
29
  # Sema Translator
30
+ Public_Url = 'https://lewiskimaru-helloworld.hf.space/' #endpoint
31
 
32
  def translate(userinput, target_lang, source_lang=None):
33
  if source_lang:
 
130
  if user_question := st.chat_input("Ask your document anything ......?"):
131
  with st.chat_message("user"):
132
  st.markdown(user_question)
133
+
134
+ #user_langd, Queryd = translate(user_question, 'eng_Latn')
135
  st.session_state.messages.append({"role": "user", "content": user_question})
136
+ response = st.session_state.conversation({"question": user_question}) #Queryd
137
  st.session_state.chat_history = response["chat_history"]
138
+
139
+ #output = translate(response['answer'], user_langd, 'eng_Latn')[1] # translated response
140
  with st.chat_message("assistant"):
141
+ st.markdown(response['answer'])
142
  st.session_state.messages.append({"role": "assistant", "content": response})
143
 
144
  # Signature
145
  st.markdown(
146
  """
147
  <div style="position: fixed; bottom: 0; right: 0; padding: 10px;">
148
+ <a href="https://kamaukimaru.vercel.app" target="_blank" style="font-size: 12px; color: #269129; text-decoration: none;">©2023 Lewis Kimaru. All rights reserved.</a>
149
  </div>
150
  """,
151
  unsafe_allow_html=True