Abhlash commited on
Commit
598d90e
·
verified ·
1 Parent(s): 4f3bf06

updated chat.py

Browse files
Files changed (1) hide show
  1. bot/chat.py +7 -7
bot/chat.py CHANGED
@@ -66,7 +66,7 @@ def correct_year(response):
66
  print(f"Corrected response: {response}") # Debug print
67
  return response
68
 
69
- def bot(history):
70
  user_message = history[-1][0].lower()
71
  current_year = datetime.now().year
72
  print(f"Current year: {current_year}") # Debug print
@@ -77,20 +77,20 @@ def bot(history):
77
  transportation = "car" # Default transportation
78
  packing_list = generate_packing_list(duration, preferences, transportation)
79
  context = f"Here's a suggested packing list for your Burn: {', '.join(packing_list)}. Remember, radical self-reliance is key, but don't be afraid to ask your camp or neighbors if you forget something!"
80
- bot_message = chat_with_groq(f"Respond to a request for a packing list. Use this information, but phrase it in your own words and add your personal touch: {context}", history)
81
  elif "principles" in user_message:
82
  context = "The 10 Principles of Burning Man are: " + ", ".join(burning_man_principles.keys())
83
- bot_message = chat_with_groq(f"The user asked about the Burning Man principles. Explain them in a casual, friendly way, as if you're chatting at Center Camp. Use this for reference, but don't just list them: {context}", history)
84
  elif "faq" in user_message:
85
  context = "\n".join([f"Q: {q} A: {a}" for q, a in faq.items()])
86
- bot_message = chat_with_groq(f"The user asked about Burning Man FAQs. Use this information to answer in a friendly, conversational way: {context}", history)
87
  elif "weather" in user_message:
88
  weather_info = get_weather()
89
  context = f"Current weather in Black Rock City: {weather_info}"
90
- bot_message = chat_with_groq(f"The user asked about the weather. Respond with this information, but add your personal touch and some advice: {context}", history)
91
  elif "survival tips" in user_message:
92
  context = "\n".join(survival_tips)
93
- bot_message = chat_with_groq(f"The user asked for survival tips. Share these tips in a friendly, experienced Burner way: {context}", history)
94
  elif "date of the event" in user_message or "when is burning man" in user_message or "this year" in user_message:
95
  print("Fetching event dates...") # Debug print
96
  event_info = get_burning_man_dates()
@@ -102,7 +102,7 @@ def bot(history):
102
  print(f"Event info: {event_info}") # Debug print
103
  bot_message = f"Oh, dear playa pal! As far as the default world goes, it's the fabulous year of {current_year}! 🌟 And guess what? {event_info} Let's make the most of it!"
104
  else:
105
- bot_message = chat_with_groq(user_message, history)
106
 
107
  # Apply year correction to the bot's message
108
  corrected_message = correct_year(bot_message)
 
66
  print(f"Corrected response: {response}") # Debug print
67
  return response
68
 
69
+ async def bot(history):
70
  user_message = history[-1][0].lower()
71
  current_year = datetime.now().year
72
  print(f"Current year: {current_year}") # Debug print
 
77
  transportation = "car" # Default transportation
78
  packing_list = generate_packing_list(duration, preferences, transportation)
79
  context = f"Here's a suggested packing list for your Burn: {', '.join(packing_list)}. Remember, radical self-reliance is key, but don't be afraid to ask your camp or neighbors if you forget something!"
80
+ bot_message = await chat_with_groq(f"Respond to a request for a packing list. Use this information, but phrase it in your own words and add your personal touch: {context}", history)
81
  elif "principles" in user_message:
82
  context = "The 10 Principles of Burning Man are: " + ", ".join(burning_man_principles.keys())
83
+ bot_message = await chat_with_groq(f"The user asked about the Burning Man principles. Explain them in a casual, friendly way, as if you're chatting at Center Camp. Use this for reference, but don't just list them: {context}", history)
84
  elif "faq" in user_message:
85
  context = "\n".join([f"Q: {q} A: {a}" for q, a in faq.items()])
86
+ bot_message = await chat_with_groq(f"The user asked about Burning Man FAQs. Use this information to answer in a friendly, conversational way: {context}", history)
87
  elif "weather" in user_message:
88
  weather_info = get_weather()
89
  context = f"Current weather in Black Rock City: {weather_info}"
90
+ bot_message = await chat_with_groq(f"The user asked about the weather. Respond with this information, but add your personal touch and some advice: {context}", history)
91
  elif "survival tips" in user_message:
92
  context = "\n".join(survival_tips)
93
+ bot_message = await chat_with_groq(f"The user asked for survival tips. Share these tips in a friendly, experienced Burner way: {context}", history)
94
  elif "date of the event" in user_message or "when is burning man" in user_message or "this year" in user_message:
95
  print("Fetching event dates...") # Debug print
96
  event_info = get_burning_man_dates()
 
102
  print(f"Event info: {event_info}") # Debug print
103
  bot_message = f"Oh, dear playa pal! As far as the default world goes, it's the fabulous year of {current_year}! 🌟 And guess what? {event_info} Let's make the most of it!"
104
  else:
105
+ bot_message = await chat_with_groq(user_message, history)
106
 
107
  # Apply year correction to the bot's message
108
  corrected_message = correct_year(bot_message)