merve HF staff commited on
Commit
3f0d99a
β€’
1 Parent(s): 702ffe4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -58,21 +58,21 @@ def find_sentences(query):
58
  saved = corpus[corpus_id]
59
  return saved
60
 
61
-
62
- message_history = [{"text":"Let's find out the best task for your use case! Tell me about your use case :)", "is_user":False}]
63
-
64
  st.subheader("If you don't know how to build your machine learning product for your use case, Taskmaster is here to help you! πŸͺ„βœ¨")
65
- st.write("Hint: Try to ask your use case in a question form.")
66
- for msg in message_history:
67
- message(msg["text"], is_user = msg["is_user"]) # display all the previous message
68
 
69
- placeholder = st.empty() # placeholder for latest message
 
 
 
 
 
70
 
71
 
72
  input = st.text_input("Ask me πŸ€—")
73
  if input:
 
74
 
75
- message_history.append({"text":input, "is_user" : True})
76
 
77
  model_answer = find_sentences(input)
78
 
@@ -84,17 +84,14 @@ if input:
84
  response_templates = [f"I think that {key} is the best task for this 🀩 Check out the page πŸ‘‰πŸΌ {url}", f"I think you should use {key} πŸͺ„ Check it out here πŸ‘‰πŸΌ {url}", f"I think {key} should work for you πŸ€“ Check out the page πŸ‘‰πŸΌ {url}"]
85
 
86
  bot_answer = random.choice(response_templates)
87
- message_history.append({"text":bot_answer, "is_user" : False})
 
88
  if key_exists == False:
89
  fallback_template = ["I didn't get the question 🧐 Could you please ask again? Try 'What should I use for detecting masks in an image?'",
90
  "Hmm, not sure I know the answer, maybe you could ask differently? πŸ€“",
91
  "Sorry, I didn't understand you, maybe you could ask differently? πŸ€“ Try asking 'What should I use to extract name in a document' πŸ€—"]
92
  bot_answer = random.choice(fallback_template)
93
- message_history.append({"text":bot_answer, "is_user" : False})
94
-
95
- with placeholder.container():
96
- last_message = message_history[-1]
97
- if last_message:
98
- message(last_message["text"], last_message["is_user"])
99
-
100
-
58
  saved = corpus[corpus_id]
59
  return saved
60
 
 
 
 
61
  st.subheader("If you don't know how to build your machine learning product for your use case, Taskmaster is here to help you! πŸͺ„βœ¨")
 
 
 
62
 
63
+ message("Let's find out the best task for your use case! Tell me about your use case :)")
64
+
65
+ #message_history = [{"text":"Let's find out the best task for your use case! Tell me about your use case :)", "is_user":False}]
66
+ #for msg in message_history:
67
+ # message(msg["text"], is_user = msg["is_user"])
68
+ #placeholder = st.empty() # placeholder for latest message
69
 
70
 
71
  input = st.text_input("Ask me πŸ€—")
72
  if input:
73
+ message(input, is_user = True)
74
 
75
+ #message_history.append({"text":input, "is_user" : True})
76
 
77
  model_answer = find_sentences(input)
78
 
84
  response_templates = [f"I think that {key} is the best task for this 🀩 Check out the page πŸ‘‰πŸΌ {url}", f"I think you should use {key} πŸͺ„ Check it out here πŸ‘‰πŸΌ {url}", f"I think {key} should work for you πŸ€“ Check out the page πŸ‘‰πŸΌ {url}"]
85
 
86
  bot_answer = random.choice(response_templates)
87
+ message(bot_answer)
88
+ #message_history.append({"text":bot_answer, "is_user" : False})
89
  if key_exists == False:
90
  fallback_template = ["I didn't get the question 🧐 Could you please ask again? Try 'What should I use for detecting masks in an image?'",
91
  "Hmm, not sure I know the answer, maybe you could ask differently? πŸ€“",
92
  "Sorry, I didn't understand you, maybe you could ask differently? πŸ€“ Try asking 'What should I use to extract name in a document' πŸ€—"]
93
  bot_answer = random.choice(fallback_template)
94
+ message(bot_answer)
95
+ #message_history.append({"text":bot_answer, "is_user" : False})
96
+
97
+