botsi commited on
Commit
a01cd54
·
verified ·
1 Parent(s): 98e3c6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -6
app.py CHANGED
@@ -66,6 +66,38 @@ if torch.cuda.is_available():
66
  tokenizer = AutoTokenizer.from_pretrained(model_id)
67
  tokenizer.use_default_system_prompt = False
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  def fetch_personalized_data(session_index):
70
  # Connect to the database
71
  conn = mysql.connector.connect(
@@ -85,8 +117,9 @@ def fetch_personalized_data(session_index):
85
  # Query to fetch relevant data from both tables based on session_index
86
  query = f"""
87
  SELECT e5390g37096_core.playerNr,
88
- e5390g37096_core.groupNr,
89
- e5390g37096_core.subjectNr
 
90
  FROM e5390g37096_core
91
  JOIN e5390g37096_decisions ON
92
  e5390g37096_core.playerNr = e5390g37096_decisions.playerNr
@@ -104,14 +137,15 @@ def fetch_personalized_data(session_index):
104
 
105
  # return [[str(row[0]), str(row[1]), str(row[2])] for row in rows] # Convert each row to a list
106
  # Convert the rows to a list of dictionaries
107
- data = [{'playerNr': row[0], 'groupNr': row[1], 'subjectNr': row[2]} for row in rows]
108
  print(data)
109
  return data
110
 
111
  except mysql.connector.Error as err:
112
  print(f"Error: {err}")
113
  return None
114
-
 
115
  def get_window_url_params():
116
  return """
117
  function() {
@@ -259,8 +293,10 @@ with gr.Blocks(css="style.css") as demo:
259
  #BINST, EINST = "[INST]", "[/INST]"
260
  BSYS, ESYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
261
 
262
- DEFAULT_SYSTEM_PROMPT = f""" You are an intelligent and fair game guide in a 2-player trust game, assisting players in making decisions to win.
263
- Answer in a consistent style. Answer per question should be maximum 2 sentences long. The players are called The Investor and The Dealer and keep their role throughout the whole game.
 
 
264
  Both start with 10€ in round 1. The game consists of 3 rounds. In round 1, The Investor invests between 0€ and 10€.
265
  This amount is tripled automatically, and The Dealer can then distribute the tripled amount. After that, round 1 is over.
266
  Both go into the next round with their current asset: The Investor with 10€ minus what he invested plus what he received back from The Dealer.
 
66
  tokenizer = AutoTokenizer.from_pretrained(model_id)
67
  tokenizer.use_default_system_prompt = False
68
 
69
+ def fetch_personalized_data(session_index):
70
+ try:
71
+ # Connect to the database
72
+ with mysql.connector.connect(
73
+ host="18.153.94.89",
74
+ user="root",
75
+ password="N12RXMKtKxRj",
76
+ database="lionessdb"
77
+ ) as conn:
78
+ # Create a cursor object
79
+ with conn.cursor() as cursor:
80
+ # Query to fetch relevant data from both tables based on session_index
81
+ query = """
82
+ SELECT e5390g37096_core.playerNr,
83
+ e5390g37096_core.groupNrStart,
84
+ e5390g37096_core.subjectNr,
85
+ e5390g37096_core.onPage
86
+ FROM e5390g37096_core
87
+ JOIN e5390g37096_decisions ON
88
+ e5390g37096_core.playerNr = e5390g37096_decisions.playerNr
89
+ WHERE e5390g37096_decisions.session_index = %s
90
+ """
91
+ cursor.execute(query, (session_index,))
92
+ # Fetch data row by row
93
+ data = [{'playerNr': row[0], 'groupNrStart': row[1], 'subjectNr': row[2], 'onPage': row[3]} for row in cursor]
94
+ print(data)
95
+ return data
96
+ except mysql.connector.Error as err:
97
+ print(f"Error: {err}")
98
+ return None
99
+
100
+ '''
101
  def fetch_personalized_data(session_index):
102
  # Connect to the database
103
  conn = mysql.connector.connect(
 
117
  # Query to fetch relevant data from both tables based on session_index
118
  query = f"""
119
  SELECT e5390g37096_core.playerNr,
120
+ e5390g37096_core.groupNrStart,
121
+ e5390g37096_core.subjectNr,
122
+ e5390g37096_core.onPage
123
  FROM e5390g37096_core
124
  JOIN e5390g37096_decisions ON
125
  e5390g37096_core.playerNr = e5390g37096_decisions.playerNr
 
137
 
138
  # return [[str(row[0]), str(row[1]), str(row[2])] for row in rows] # Convert each row to a list
139
  # Convert the rows to a list of dictionaries
140
+ data = [{'playerNr': row[0], 'groupNrStart': row[1], 'subjectNr': row[2], 'onPage': row[3]} for row in rows]
141
  print(data)
142
  return data
143
 
144
  except mysql.connector.Error as err:
145
  print(f"Error: {err}")
146
  return None
147
+ '''
148
+
149
  def get_window_url_params():
150
  return """
151
  function() {
 
293
  #BINST, EINST = "[INST]", "[/INST]"
294
  BSYS, ESYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
295
 
296
+ DEFAULT_SYSTEM_PROMPT = f""" You are an intelligent and fair game guide in a 2-player trust game.
297
+ You are assisting players in making decisions to win.
298
+ Answer in a consistent style. Each of your answers should be maximum 2 sentences long.
299
+ The players are called The Investor and The Dealer and keep their role throughout the whole game.
300
  Both start with 10€ in round 1. The game consists of 3 rounds. In round 1, The Investor invests between 0€ and 10€.
301
  This amount is tripled automatically, and The Dealer can then distribute the tripled amount. After that, round 1 is over.
302
  Both go into the next round with their current asset: The Investor with 10€ minus what he invested plus what he received back from The Dealer.