Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Gave bots room topic text in their prompt, increased time to respond, decreased inactivity timer, added randomness to inactivity timer, and tried to fix the (pass) on refresh
Browse files- chat_application/main.py +11 -4
chat_application/main.py
CHANGED
|
@@ -183,6 +183,10 @@ def send_initial_post(room_id, delay):
|
|
| 183 |
if not topic_info:
|
| 184 |
return
|
| 185 |
initialPost = topic_info["post"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
# Store the initial post in the database
|
| 187 |
db_msg = {
|
| 188 |
"sender": "watermelon",
|
|
@@ -206,8 +210,10 @@ def send_bot_joined(room_id, bot_name, delay):
|
|
| 206 |
socketio.emit("message", {"sender": "", "message": f"{bot_name} has entered the chat"}, to=room_id)
|
| 207 |
|
| 208 |
# Trigger a round of bot calls if user has been inactive for a while
|
| 209 |
-
def user_inactivity_tracker(room_id, timeout_seconds=
|
| 210 |
print(f"Started user inactivity tracker for Room ID#{room_id}")
|
|
|
|
|
|
|
| 211 |
while True:
|
| 212 |
room_doc = rooms_collection.find_one({"_id": room_id})
|
| 213 |
# Stop if this room's chat has ended
|
|
@@ -252,8 +258,9 @@ def replace_semicolons(text, probability=0.80):
|
|
| 252 |
return ''.join(modified_text)
|
| 253 |
|
| 254 |
def get_response_delay(response):
|
| 255 |
-
baseDelay =
|
| 256 |
-
randFactor = random.uniform(
|
|
|
|
| 257 |
perCharacterDelay = 0.12
|
| 258 |
# was .25 -> average speed: 3.33 characters/second = 0.3
|
| 259 |
maxDelay = 150 # maximum cap of 2.5 minutes (so the bots don't take too long)
|
|
@@ -558,7 +565,7 @@ def room():
|
|
| 558 |
return redirect(url_for('topics'))
|
| 559 |
nonpass_messages = [
|
| 560 |
m for m in room_doc["messages"]
|
| 561 |
-
if m.get("message", "").strip()
|
| 562 |
]
|
| 563 |
return render_template("room.html", room=room_id, topic_info=topic_info, user=display_name, messages=nonpass_messages, FroBot_name=room_doc["FroBot_name"], HotBot_name=room_doc["HotBot_name"], CoolBot_name=room_doc["CoolBot_name"], ended=room_doc["ended"])
|
| 564 |
|
|
|
|
| 183 |
if not topic_info:
|
| 184 |
return
|
| 185 |
initialPost = topic_info["post"]
|
| 186 |
+
# Add the topic text to bots prompts
|
| 187 |
+
FROBOT_PROMPT = f"The topic of this chat is:\n{topic_info['text']}\n"+FROBOT_PROMPT
|
| 188 |
+
COOLBOT_PROMPT = f"The topic of this chat is:\n{topic_info['text']}\n"+COOLBOT_PROMPT
|
| 189 |
+
HOTBOT_PROMPT = f"The topic of this chat is:\n{topic_info['text']}\n"+HOTBOT_PROMPT
|
| 190 |
# Store the initial post in the database
|
| 191 |
db_msg = {
|
| 192 |
"sender": "watermelon",
|
|
|
|
| 210 |
socketio.emit("message", {"sender": "", "message": f"{bot_name} has entered the chat"}, to=room_id)
|
| 211 |
|
| 212 |
# Trigger a round of bot calls if user has been inactive for a while
|
| 213 |
+
def user_inactivity_tracker(room_id, timeout_seconds=120,randomNorm = (0,15)):
|
| 214 |
print(f"Started user inactivity tracker for Room ID#{room_id}")
|
| 215 |
+
# add randomness to timeout
|
| 216 |
+
timeout_seconds += np.random.normal(randomNorm[0],randomNorm[1])
|
| 217 |
while True:
|
| 218 |
room_doc = rooms_collection.find_one({"_id": room_id})
|
| 219 |
# Stop if this room's chat has ended
|
|
|
|
| 258 |
return ''.join(modified_text)
|
| 259 |
|
| 260 |
def get_response_delay(response):
|
| 261 |
+
baseDelay = 5 # standard delay for thinking
|
| 262 |
+
randFactor = np.random.uniform(0,30, len(response) // 4)
|
| 263 |
+
randFactor = max(randFactor) # Make longer responses more likely to take longer
|
| 264 |
perCharacterDelay = 0.12
|
| 265 |
# was .25 -> average speed: 3.33 characters/second = 0.3
|
| 266 |
maxDelay = 150 # maximum cap of 2.5 minutes (so the bots don't take too long)
|
|
|
|
| 565 |
return redirect(url_for('topics'))
|
| 566 |
nonpass_messages = [
|
| 567 |
m for m in room_doc["messages"]
|
| 568 |
+
if len(re.findall(r"pass",m.get("message", "").strip())) == 0
|
| 569 |
]
|
| 570 |
return render_template("room.html", room=room_id, topic_info=topic_info, user=display_name, messages=nonpass_messages, FroBot_name=room_doc["FroBot_name"], HotBot_name=room_doc["HotBot_name"], CoolBot_name=room_doc["CoolBot_name"], ended=room_doc["ended"])
|
| 571 |
|