IBHS commited on
Commit
ecd1de3
·
verified ·
1 Parent(s): de23f86

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. .DS_Store +0 -0
  2. .gitignore +3 -1
  3. app.py +37 -9
  4. chroma_store/.DS_Store +0 -0
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
.gitignore CHANGED
@@ -129,4 +129,6 @@ dmypy.json
129
  .pyre/
130
  .idea
131
 
132
- test1.ipynb
 
 
 
129
  .pyre/
130
  .idea
131
 
132
+ test1.ipynb
133
+
134
+ app1.py
app.py CHANGED
@@ -145,9 +145,10 @@ def generate_unique_string():
145
  unique_string = hashlib.sha256((mac_str + cpu_info).encode()).hexdigest()
146
  return unique_string
147
 
148
- def llm_response(query):
149
  titles, links, res_titles, res_links = [], [], [], []
150
- unique_id = generate_unique_string()
 
151
  config = {"configurable": {"thread_id": unique_id }}
152
  try:
153
  # modified_query = runnable.invoke({"input": query, "chat_history": history.messages}).content
@@ -199,9 +200,21 @@ def llm_response(query):
199
 
200
  with gr.Blocks() as demo:
201
  gr.Markdown("## FORTIFIED AI Assistant!")
202
- gr.Markdown("### I'll try to answer any questions related to FORTIFIED program. Tell me what's on your mind?")
203
- with gr.Row():
 
 
 
 
 
 
 
 
 
204
  with gr.Column():
 
 
 
205
  chatbot = gr.Chatbot(type="messages", height=400)
206
  msg = gr.Textbox(label="Hit the Enter to send your question", placeholder="What's on your mind?", show_copy_button=True)
207
  send = gr.Button("Send")
@@ -210,16 +223,31 @@ with gr.Blocks() as demo:
210
  return "", history + [{"role": "user", "content": user_message}]
211
 
212
 
213
- def bot(history: list):
214
- bot_message = llm_response(history[-1]['content'])
215
  history.append({"role": "assistant", "content": ""})
216
  for character in bot_message:
217
  history[-1]['content'] += character
218
  yield history
219
 
220
-
221
- msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)
222
- send.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
 
224
  if __name__ == "__main__":
225
  demo.launch()
 
145
  unique_string = hashlib.sha256((mac_str + cpu_info).encode()).hexdigest()
146
  return unique_string
147
 
148
+ def llm_response(query, session_id):
149
  titles, links, res_titles, res_links = [], [], [], []
150
+ print(session_id)
151
+ unique_id = session_id
152
  config = {"configurable": {"thread_id": unique_id }}
153
  try:
154
  # modified_query = runnable.invoke({"input": query, "chat_history": history.messages}).content
 
200
 
201
  with gr.Blocks() as demo:
202
  gr.Markdown("## FORTIFIED AI Assistant!")
203
+ with gr.Row(visible=True) as role_selector:
204
+ with gr.Column(scale=4):
205
+ pass
206
+ with gr.Column(scale=2):
207
+ gr.Markdown("### Choose your role:")
208
+ homeowner = gr.Button("Homeowner", variant="primary")
209
+ design_pro = gr.Button("Design Professionals", variant="primary")
210
+ evaluator = gr.Button("Evaluator", variant="primary")
211
+ with gr.Column(scale=4):
212
+ pass
213
+ with gr.Row(visible=False) as chat_container:
214
  with gr.Column():
215
+ session_id = gr.Textbox(label="Session ID", visible=False)
216
+ gr.Markdown(
217
+ "### I'll try to answer any questions related to FORTIFIED program. Tell me what's on your mind?")
218
  chatbot = gr.Chatbot(type="messages", height=400)
219
  msg = gr.Textbox(label="Hit the Enter to send your question", placeholder="What's on your mind?", show_copy_button=True)
220
  send = gr.Button("Send")
 
223
  return "", history + [{"role": "user", "content": user_message}]
224
 
225
 
226
+ def bot(history: list, session_id_i):
227
+ bot_message = llm_response(history[-1]['content'], session_id_i)
228
  history.append({"role": "assistant", "content": ""})
229
  for character in bot_message:
230
  history[-1]['content'] += character
231
  yield history
232
 
233
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
234
+ bot, [chatbot, session_id], chatbot
235
+ )
236
+ send.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
237
+ bot, [chatbot, session_id], chatbot
238
+ )
239
+
240
+ def start():
241
+ unique_id = uuid.uuid4()
242
+
243
+ return {
244
+ chat_container: gr.update(visible=True),
245
+ role_selector: gr.update(visible=False),
246
+ session_id: gr.update(value=unique_id),
247
+ }
248
+ homeowner.click(start, [], [chat_container, role_selector, session_id])
249
+ design_pro.click(start, [], [chat_container, role_selector,session_id])
250
+ evaluator.click(start, [], [chat_container, role_selector, session_id])
251
 
252
  if __name__ == "__main__":
253
  demo.launch()
chroma_store/.DS_Store ADDED
Binary file (6.15 kB). View file