Skip to content

Commit 9278957

Browse files
committed
Add LMArena
1 parent 96780cf commit 9278957

6 files changed

Lines changed: 116 additions & 35 deletions

File tree

‎packages/browser/src/content-scripts/send-prompt-content-script/chatbots/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from './gemini'
77
export * from './grok'
88
export * from './github-copilot'
99
export * from './hugging-chat'
10+
export * from './lmarena'
1011
export * from './minimax'
1112
export * from './meta'
1213
export * from './mistral'
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Chatbot } from '../types/chatbot'
2+
import {
3+
add_apply_response_button,
4+
observe_for_responses
5+
} from '../utils/add-apply-response-button'
6+
import { report_initialization_error } from '../utils/report-initialization-error'
7+
8+
export const lmarena: Chatbot = {
9+
wait_until_ready: async () => {
10+
await new Promise((resolve) => setTimeout(resolve, 500))
11+
},
12+
inject_apply_response_button: (
13+
client_id: number,
14+
raw_instructions?: string,
15+
edit_format?: string
16+
) => {
17+
const add_buttons = (footer: Element) => {
18+
add_apply_response_button({
19+
client_id,
20+
raw_instructions,
21+
edit_format,
22+
footer,
23+
get_chat_turn: (f) =>
24+
f
25+
.closest('div[role="group"]')
26+
?.querySelector('div.prose') as HTMLElement,
27+
perform_copy: (f) => {
28+
const copy_button = f.querySelector(
29+
'button:first-child'
30+
) as HTMLElement
31+
if (!copy_button) {
32+
report_initialization_error({
33+
function_name: 'lmarena.perform_copy',
34+
log_message: 'Copy button not found'
35+
})
36+
return
37+
}
38+
copy_button.click()
39+
},
40+
insert_button: (f, b) =>
41+
f.insertBefore(b, f.children[0])
42+
})
43+
}
44+
45+
observe_for_responses({
46+
chatbot_name: 'LMArena',
47+
is_generating: () => !!document.querySelector('canvas[data-sentry-component="Loading"]'),
48+
footer_selector: 'div[data-sentry-component="MessageActions"]',
49+
add_buttons
50+
})
51+
}
52+
}

‎packages/browser/src/content-scripts/send-prompt-content-script/send-prompt-content-script.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
yuanbao,
1919
doubao,
2020
kimi,
21+
lmarena,
2122
together,
2223
github_copilot,
2324
hugging_chat,
@@ -71,6 +72,9 @@ const is_yuanbao = current_url.startsWith(yuanbao_url)
7172
const hugging_chat_url = 'https://huggingface.co/chat/'
7273
const is_hugging_chat = current_url.startsWith(hugging_chat_url)
7374

75+
const lmarena_url = 'https://lmarena.ai/'
76+
const is_lmarena = current_url.startsWith(lmarena_url)
77+
7478
const minimax_url = 'https://agent.minimax.io/'
7579
const is_minimax = current_url.startsWith(minimax_url)
7680

@@ -113,6 +117,8 @@ if (is_ai_studio) {
113117
chatbot = claude
114118
} else if (is_hugging_chat) {
115119
chatbot = hugging_chat
120+
} else if (is_lmarena) {
121+
chatbot = lmarena
116122
} else if (is_minimax) {
117123
chatbot = minimax
118124
} else if (is_mistral) {
@@ -159,7 +165,8 @@ export const get_textarea_element = () => {
159165
[z_ai_url]: 'textarea',
160166
[github_copilot_url]: 'textarea',
161167
[hugging_chat_url]: 'textarea',
162-
[minimax_url]: 'textarea'
168+
[minimax_url]: 'textarea',
169+
[lmarena_url]: 'textarea'
163170
} as any
164171

165172
// Find the appropriate selector based on the URL without the hash

‎packages/browser/src/content-scripts/send-prompt-content-script/utils/apply-response-styles.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const apply_chat_response_button_style = (button: HTMLButtonElement) => {
22
button.style.margin = '4px 8px'
3-
button.style.padding = '7px 11px'
3+
button.style.padding = '6px 9px'
44
button.style.borderRadius = '999px'
55
button.style.backgroundColor = '#fbb100'
66
button.style.cursor = 'pointer'
@@ -10,7 +10,7 @@ export const apply_chat_response_button_style = (button: HTMLButtonElement) => {
1010

1111
const svg = button.querySelector('svg')
1212
if (svg) {
13-
svg.style.height = '14px'
13+
svg.style.height = '13px'
1414
}
1515
}
1616

‎packages/ui/src/components/editor/panel/Presets/Presets.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const chatbot_to_icon: Record<keyof typeof CHATBOTS, Icon.Variant> = {
2121
Kimi: 'KIMI',
2222
Minimax: 'MINIMAX',
2323
Mistral: 'MISTRAL',
24+
LMArena: 'LMARENA',
2425
// Meta: 'META',
2526
'Open WebUI': 'OPEN_WEBUI',
2627
OpenRouter: 'OPENROUTER',

‎packages/vscode/package.json‎

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -655,38 +655,42 @@
655655
},
656656
{
657657
"name": "(11)",
658-
"chatbot": "Minimax"
658+
"chatbot": "LMArena"
659659
},
660660
{
661661
"name": "(12)",
662-
"chatbot": "Mistral"
662+
"chatbot": "Minimax"
663663
},
664664
{
665665
"name": "(13)",
666-
"chatbot": "Open WebUI"
666+
"chatbot": "Mistral"
667667
},
668668
{
669669
"name": "(14)",
670-
"chatbot": "OpenRouter"
670+
"chatbot": "Open WebUI"
671671
},
672672
{
673673
"name": "(15)",
674-
"chatbot": "Perplexity"
674+
"chatbot": "OpenRouter"
675675
},
676676
{
677677
"name": "(16)",
678-
"chatbot": "Qwen"
678+
"chatbot": "Perplexity"
679679
},
680680
{
681681
"name": "(17)",
682-
"chatbot": "Together"
682+
"chatbot": "Qwen"
683683
},
684684
{
685685
"name": "(18)",
686-
"chatbot": "Yuanbao"
686+
"chatbot": "Together"
687687
},
688688
{
689689
"name": "(19)",
690+
"chatbot": "Yuanbao"
691+
},
692+
{
693+
"name": "(20)",
690694
"chatbot": "Z.AI"
691695
}
692696
],
@@ -712,6 +716,7 @@
712716
"Grok",
713717
"HuggingChat",
714718
"Kimi",
719+
"LMArena",
715720
"Minimax",
716721
"Mistral",
717722
"Open WebUI",
@@ -848,38 +853,42 @@
848853
},
849854
{
850855
"name": "(11)",
851-
"chatbot": "Minimax"
856+
"chatbot": "LMArena"
852857
},
853858
{
854859
"name": "(12)",
855-
"chatbot": "Mistral"
860+
"chatbot": "Minimax"
856861
},
857862
{
858863
"name": "(13)",
859-
"chatbot": "Open WebUI"
864+
"chatbot": "Mistral"
860865
},
861866
{
862867
"name": "(14)",
863-
"chatbot": "OpenRouter"
868+
"chatbot": "Open WebUI"
864869
},
865870
{
866871
"name": "(15)",
867-
"chatbot": "Perplexity"
872+
"chatbot": "OpenRouter"
868873
},
869874
{
870875
"name": "(16)",
871-
"chatbot": "Qwen"
876+
"chatbot": "Perplexity"
872877
},
873878
{
874879
"name": "(17)",
875-
"chatbot": "Together"
880+
"chatbot": "Qwen"
876881
},
877882
{
878883
"name": "(18)",
879-
"chatbot": "Yuanbao"
884+
"chatbot": "Together"
880885
},
881886
{
882887
"name": "(19)",
888+
"chatbot": "Yuanbao"
889+
},
890+
{
891+
"name": "(20)",
883892
"chatbot": "Z.AI"
884893
}
885894
],
@@ -905,6 +914,7 @@
905914
"Grok",
906915
"HuggingChat",
907916
"Kimi",
917+
"LMArena",
908918
"Minimax",
909919
"Mistral",
910920
"Open WebUI",
@@ -1041,38 +1051,42 @@
10411051
},
10421052
{
10431053
"name": "(11)",
1044-
"chatbot": "Minimax"
1054+
"chatbot": "LMArena"
10451055
},
10461056
{
10471057
"name": "(12)",
1048-
"chatbot": "Mistral"
1058+
"chatbot": "Minimax"
10491059
},
10501060
{
10511061
"name": "(13)",
1052-
"chatbot": "Open WebUI"
1062+
"chatbot": "Mistral"
10531063
},
10541064
{
10551065
"name": "(14)",
1056-
"chatbot": "OpenRouter"
1066+
"chatbot": "Open WebUI"
10571067
},
10581068
{
10591069
"name": "(15)",
1060-
"chatbot": "Perplexity"
1070+
"chatbot": "OpenRouter"
10611071
},
10621072
{
10631073
"name": "(16)",
1064-
"chatbot": "Qwen"
1074+
"chatbot": "Perplexity"
10651075
},
10661076
{
10671077
"name": "(17)",
1068-
"chatbot": "Together"
1078+
"chatbot": "Qwen"
10691079
},
10701080
{
10711081
"name": "(18)",
1072-
"chatbot": "Yuanbao"
1082+
"chatbot": "Together"
10731083
},
10741084
{
10751085
"name": "(19)",
1086+
"chatbot": "Yuanbao"
1087+
},
1088+
{
1089+
"name": "(20)",
10761090
"chatbot": "Z.AI"
10771091
}
10781092
],
@@ -1098,6 +1112,7 @@
10981112
"Grok",
10991113
"HuggingChat",
11001114
"Kimi",
1115+
"LMArena",
11011116
"Minimax",
11021117
"Mistral",
11031118
"Open WebUI",
@@ -1204,38 +1219,42 @@
12041219
},
12051220
{
12061221
"name": "(11)",
1207-
"chatbot": "Minimax"
1222+
"chatbot": "LMArena"
12081223
},
12091224
{
12101225
"name": "(12)",
1211-
"chatbot": "Mistral"
1226+
"chatbot": "Minimax"
12121227
},
12131228
{
12141229
"name": "(13)",
1215-
"chatbot": "Open WebUI"
1230+
"chatbot": "Mistral"
12161231
},
12171232
{
12181233
"name": "(14)",
1219-
"chatbot": "OpenRouter"
1234+
"chatbot": "Open WebUI"
12201235
},
12211236
{
12221237
"name": "(15)",
1223-
"chatbot": "Perplexity"
1238+
"chatbot": "OpenRouter"
12241239
},
12251240
{
12261241
"name": "(16)",
1227-
"chatbot": "Qwen"
1242+
"chatbot": "Perplexity"
12281243
},
12291244
{
12301245
"name": "(17)",
1231-
"chatbot": "Together"
1246+
"chatbot": "Qwen"
12321247
},
12331248
{
12341249
"name": "(18)",
1235-
"chatbot": "Yuanbao"
1250+
"chatbot": "Together"
12361251
},
12371252
{
12381253
"name": "(19)",
1254+
"chatbot": "Yuanbao"
1255+
},
1256+
{
1257+
"name": "(20)",
12391258
"chatbot": "Z.AI"
12401259
}
12411260
],
@@ -1261,6 +1280,7 @@
12611280
"Grok",
12621281
"HuggingChat",
12631282
"Kimi",
1283+
"LMArena",
12641284
"Minimax",
12651285
"Mistral",
12661286
"Open WebUI",

0 commit comments

Comments
 (0)