rwitz commited on
Commit
0db6418
1 Parent(s): 4d15f04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -12,7 +12,7 @@ with open('chatbot_urls.json', 'r') as file:
12
 
13
  # Initialize or get user-specific ELO ratings
14
  def get_user_elo_ratings(state):
15
- return state.value['elo_ratings']
16
 
17
  # Read and write ELO ratings to file (thread-safe)
18
  def read_elo_ratings():
@@ -29,7 +29,7 @@ def write_elo_ratings(elo_ratings):
29
  # Function to get bot response
30
  def format_chatml_prompt(state):
31
  chatml_prompt = ""
32
- for message in state.value["history"]:
33
  chatml_prompt += f"<|im_start|> "+message['role']+"- "+ message['content']+"<|im_end|>\n"
34
  return chatml_prompt
35
  def get_bot_response(url, prompt,state):
@@ -67,8 +67,8 @@ def chat_with_bots(user_input, state):
67
  def update_ratings(state, winner_index):
68
  elo_ratings = get_user_elo_ratings()
69
  bot_names = list(chatbots.keys())
70
- winner = state.value['last_bots'][winner_index]
71
- loser = state.value['last_bots'][1 - winner_index]
72
 
73
  elo_ratings = update_elo_ratings(elo_ratings, winner, loser)
74
  write_elo_ratings(elo_ratings)
 
12
 
13
  # Initialize or get user-specific ELO ratings
14
  def get_user_elo_ratings(state):
15
+ return state['elo_ratings']
16
 
17
  # Read and write ELO ratings to file (thread-safe)
18
  def read_elo_ratings():
 
29
  # Function to get bot response
30
  def format_chatml_prompt(state):
31
  chatml_prompt = ""
32
+ for message in state["history"]:
33
  chatml_prompt += f"<|im_start|> "+message['role']+"- "+ message['content']+"<|im_end|>\n"
34
  return chatml_prompt
35
  def get_bot_response(url, prompt,state):
 
67
  def update_ratings(state, winner_index):
68
  elo_ratings = get_user_elo_ratings()
69
  bot_names = list(chatbots.keys())
70
+ winner = state['last_bots'][winner_index]
71
+ loser = state['last_bots'][1 - winner_index]
72
 
73
  elo_ratings = update_elo_ratings(elo_ratings, winner, loser)
74
  write_elo_ratings(elo_ratings)