Spaces:
Runtime error
Runtime error
AlekseyKorshuk
commited on
Commit
·
e053720
1
Parent(s):
7f27042
updates
Browse files- app.py +1 -0
- tabs/arena_battle.py +3 -2
- tabs/arena_side_by_side.py +2 -1
- utils.py +32 -0
app.py
CHANGED
@@ -103,6 +103,7 @@ models = [
|
|
103 |
),
|
104 |
]
|
105 |
model_mapping = {model.name: model for model in models}
|
|
|
106 |
|
107 |
|
108 |
def get_connection():
|
|
|
103 |
),
|
104 |
]
|
105 |
model_mapping = {model.name: model for model in models}
|
106 |
+
print(list(model_mapping.keys()))
|
107 |
|
108 |
|
109 |
def get_connection():
|
tabs/arena_battle.py
CHANGED
@@ -3,6 +3,7 @@ import time
|
|
3 |
import gradio as gr
|
4 |
import random
|
5 |
from conversation import Conversation
|
|
|
6 |
|
7 |
|
8 |
def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, client):
|
@@ -30,7 +31,7 @@ def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, cl
|
|
30 |
values = list(model_mapping.keys())
|
31 |
first_message = (None, bot_config["firstMessage"])
|
32 |
height = 450
|
33 |
-
model_a_value, model_b_value =
|
34 |
with gr.Column():
|
35 |
model_a = gr.Textbox(value=model_a_value, label="Model A", interactive=False, visible=False)
|
36 |
chatbot_a = gr.Chatbot([first_message])
|
@@ -179,7 +180,7 @@ def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, cl
|
|
179 |
return [gr.Textbox.update(visible=True)] * 2
|
180 |
|
181 |
def hide_models():
|
182 |
-
model_a_value, model_b_value =
|
183 |
return [gr.Textbox.update(visible=False, value=model_a_value),
|
184 |
gr.Textbox.update(visible=False, value=model_b_value)]
|
185 |
|
|
|
3 |
import gradio as gr
|
4 |
import random
|
5 |
from conversation import Conversation
|
6 |
+
from utils import get_matchmaking
|
7 |
|
8 |
|
9 |
def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, client):
|
|
|
31 |
values = list(model_mapping.keys())
|
32 |
first_message = (None, bot_config["firstMessage"])
|
33 |
height = 450
|
34 |
+
model_a_value, model_b_value = get_matchmaking(client, values, is_anonymous=True)
|
35 |
with gr.Column():
|
36 |
model_a = gr.Textbox(value=model_a_value, label="Model A", interactive=False, visible=False)
|
37 |
chatbot_a = gr.Chatbot([first_message])
|
|
|
180 |
return [gr.Textbox.update(visible=True)] * 2
|
181 |
|
182 |
def hide_models():
|
183 |
+
model_a_value, model_b_value = get_matchmaking(client, values, is_anonymous=True)
|
184 |
return [gr.Textbox.update(visible=False, value=model_a_value),
|
185 |
gr.Textbox.update(visible=False, value=model_b_value)]
|
186 |
|
tabs/arena_side_by_side.py
CHANGED
@@ -3,6 +3,7 @@ import time
|
|
3 |
import gradio as gr
|
4 |
import random
|
5 |
from conversation import Conversation
|
|
|
6 |
|
7 |
|
8 |
def get_tab_arena_side_by_side(download_bot_config, get_bot_profile, model_mapping, client):
|
@@ -29,7 +30,7 @@ def get_tab_arena_side_by_side(download_bot_config, get_bot_profile, model_mappi
|
|
29 |
values = list(model_mapping.keys())
|
30 |
first_message = (None, bot_config["firstMessage"])
|
31 |
height = 450
|
32 |
-
model_a_value, model_b_value =
|
33 |
with gr.Column():
|
34 |
model_a = gr.Dropdown(values, value=model_a_value, label="Model A")
|
35 |
chatbot_a = gr.Chatbot([first_message])
|
|
|
3 |
import gradio as gr
|
4 |
import random
|
5 |
from conversation import Conversation
|
6 |
+
from utils import get_matchmaking
|
7 |
|
8 |
|
9 |
def get_tab_arena_side_by_side(download_bot_config, get_bot_profile, model_mapping, client):
|
|
|
30 |
values = list(model_mapping.keys())
|
31 |
first_message = (None, bot_config["firstMessage"])
|
32 |
height = 450
|
33 |
+
model_a_value, model_b_value = get_matchmaking(client, values, is_anonymous=False)
|
34 |
with gr.Column():
|
35 |
model_a = gr.Dropdown(values, value=model_a_value, label="Model A")
|
36 |
chatbot_a = gr.Chatbot([first_message])
|
utils.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import itertools
|
2 |
+
import random
|
3 |
+
|
4 |
+
|
5 |
+
def get_matchmaking(client, models, is_anonymous=True):
|
6 |
+
sheet = client.open("Chat Arena").sheet1
|
7 |
+
records = sheet.get_all_records()
|
8 |
+
records = [
|
9 |
+
{
|
10 |
+
col: record.get(col, None)
|
11 |
+
for col in ['model_a', 'model_b']
|
12 |
+
} for record in records if record["is_anonymous"] == is_anonymous
|
13 |
+
]
|
14 |
+
|
15 |
+
combinations = list(itertools.combinations_with_replacement(models, 2))
|
16 |
+
combinations = [frozenset(combination) for combination in combinations if len(set(combination)) > 1]
|
17 |
+
|
18 |
+
records = [
|
19 |
+
frozenset(record.values()) for record in records
|
20 |
+
]
|
21 |
+
|
22 |
+
repetitions_count = {combination: 0 for combination in combinations}
|
23 |
+
|
24 |
+
for record in records:
|
25 |
+
repetitions_count[record] += 1
|
26 |
+
|
27 |
+
sorted_repetitions = dict(sorted(repetitions_count.items(), key=lambda item: item[1]))
|
28 |
+
less_common = list(sorted_repetitions.keys())[0]
|
29 |
+
less_common = list(less_common)
|
30 |
+
random.shuffle(less_common)
|
31 |
+
model_a, model_b = less_common
|
32 |
+
return model_a, model_b
|