vip11017 commited on
Commit
73962a1
·
1 Parent(s): 678db8f

updating demo code to get welcome message

Browse files
app/chatbot/demo_routes.py CHANGED
@@ -63,7 +63,6 @@ async def demo_chatbot_status(submission_id: str):
63
  }
64
 
65
 
66
-
67
  @router.get("/info/{submission_id}")
68
  async def demo_chatbot_info(submission_id: str):
69
  """
 
63
  }
64
 
65
 
 
66
  @router.get("/info/{submission_id}")
67
  async def demo_chatbot_info(submission_id: str):
68
  """
app/chatbot/prod_routes.py CHANGED
@@ -93,6 +93,7 @@ async def prod_chatbot_info(chatbot_id: str):
93
  return {
94
  "chatbot_name": config.get("chatbot_name"),
95
  "company_name": config.get("company_name"),
 
96
  }
97
 
98
  @router.get("/info/faq/{chatbot_id}")
 
93
  return {
94
  "chatbot_name": config.get("chatbot_name"),
95
  "company_name": config.get("company_name"),
96
+ "welcome_message": config.get("welcome_message")
97
  }
98
 
99
  @router.get("/info/faq/{chatbot_id}")
app/ingestion/rag_setup.py CHANGED
@@ -209,6 +209,27 @@ STRICT RULES:
209
  """
210
  return template
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  def store_demo_rag_config(chatbot_id, company_id, ingest: ChatbotIngest) -> None:
213
  """
214
  Stores the RAG configuration prompt for the demo chatbot in MongoDB.
@@ -220,6 +241,7 @@ def store_demo_rag_config(chatbot_id, company_id, ingest: ChatbotIngest) -> None
220
  "chatbot_name": ingest.chatbot_name,
221
  "company_name": ingest.company_name,
222
  "prompt_template": build_demo_prompt(ingest),
 
223
  "retrievers": [
224
  {
225
  "name": "all",
 
209
  """
210
  return template
211
 
212
+ def build_welcome_message(ingest: ChatbotIngest) -> str:
213
+ """
214
+ Build the welcome message for the chatbot using its ingest config.
215
+ """
216
+ # Determine chatbot name
217
+ chatbot_name = ingest.chatbot_name or f"{ingest.company_name} Assistant"
218
+
219
+ # Filter out "capture leads (email, phone)" from purposes
220
+ purposes = [p for p in ingest.chatbot_purpose if p.lower() != "capture leads (email, phone)"]
221
+
222
+ # Construct intro message
223
+ intro_msg = (
224
+ f"Hello! 👋 I'm {chatbot_name}, your virtual assistant for {ingest.company_name}.\n"
225
+ "I can help you with:\n"
226
+ + "\n".join(f"- {p}" for p in purposes)
227
+ + "\nPlease ask me anything or start with one of the suggested FAQs below."
228
+ )
229
+
230
+ return intro_msg
231
+
232
+
233
  def store_demo_rag_config(chatbot_id, company_id, ingest: ChatbotIngest) -> None:
234
  """
235
  Stores the RAG configuration prompt for the demo chatbot in MongoDB.
 
241
  "chatbot_name": ingest.chatbot_name,
242
  "company_name": ingest.company_name,
243
  "prompt_template": build_demo_prompt(ingest),
244
+ "welcome_message": build_welcome_message(ingest),
245
  "retrievers": [
246
  {
247
  "name": "all",