-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_data.py
More file actions
93 lines (78 loc) · 2.65 KB
/
random_data.py
File metadata and controls
93 lines (78 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import random
from datetime import datetime
from db import (
insert_user,
insert_chatbot,
insert_conversation,
insert_user_messages,
insert_chatbot_messages,
)
# ------------------------------------------------------------------
# Tunables ─ change these if you want more / fewer records
NUM_USERS = 3 # how many fake human users
NUM_CHATBOTS = 2 # how many chatbots
CONV_PER_USER = 2 # conversations each user has with a random bot
MSG_PER_CONV = 6 # total messages per conversation (user+bot)
# ------------------------------------------------------------------
USERNAMES = [
"Seb",
"Jonathan",
"Will",
"vineeth",
"Sebastian",
]
BOT_PERSONAS = [
"GPT1",
"QGPT2",
"AI",
"Flashcard",
]
USER_LINES = [
"Hey, can you help me review Chapter 4?",
"What does this SQL error actually mean?",
"Got any tips for staying focused?",
"Let’s run some practice questions.",
"Explain heteroskedasticity like I'm five.",
]
BOT_LINES = [
"Sure! First, let's outline the key concepts.",
"Here’s a quick query that should fix it:",
"Absolutely. Pomodoro technique works great!",
"Question 1: What is the null hypothesis?",
"In simple terms, it just means the variance isn’t constant.",
]
def random_choice(seq):
return random.choice(seq)
def main():
random.seed()
#Create users
user_ids = []
for i in range(NUM_USERS):
uname = random_choice(USERNAMES) + f"_{random.randint(1000,9999)}"
uid = insert_user(uname)
user_ids.append(uid)
print(f" ✔ user '{uname}' inserted as id={uid}")
#Create chatbots
bot_ids = []
for i in range(NUM_CHATBOTS):
bid = insert_chatbot()
bot_ids.append(bid)
print(f" ✔ chatbot id={bid}")
#Create conversations & messages
print("\nCreating conversations and messages …")
for uid in user_ids:
for _ in range(CONV_PER_USER):
bid = random_choice(bot_ids)
conv_id = insert_conversation(uid, bid)
print(f" ✔ conversation id={conv_id} (user {uid} ⇄ bot {bid})")
# alternate sender: user ➜ bot ➜ user ➜ …
for m in range(MSG_PER_CONV):
if m % 2 == 0: # user turn
msg = random_choice(USER_LINES)
insert_user_messages(uid, conv_id, msg)
else: # bot turn
msg = random_choice(BOT_LINES)
insert_chatbot_messages(bid, conv_id, msg)
print("\n Random seed data inserted successfully!\n")
if __name__ == "__main__":
main()