Spaces:
Paused
Paused
and
commited on
Commit
·
2284b0f
1
Parent(s):
7bc4d92
- test_evaluate.mjs +25 -0
test_evaluate.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
await fetch('https://gowah44030-playwright.hf.space/evaluate', {
|
| 2 |
+
method: "POST",
|
| 3 |
+
body: JSON.stringify({
|
| 4 |
+
url: 'https://chat.lmsys.org/assets/index-c347e3dc.js',
|
| 5 |
+
code: `
|
| 6 |
+
(async function(){
|
| 7 |
+
return await new Promise(resolve=>{
|
| 8 |
+
|
| 9 |
+
try {
|
| 10 |
+
resolve(await fetch('https://chat.lmsys.org').then(res=>res.text()));
|
| 11 |
+
} catch (e) { resolve(e);}
|
| 12 |
+
return;
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
const ws = new WebSocket('wss://chat.lmsys.org/queue/join');
|
| 16 |
+
ws.addEventListener('error', (e) => { resolve('error');});
|
| 17 |
+
ws.addEventListener('open', function open() { resolve('open');});
|
| 18 |
+
ws.addEventListener('close', () => { resolve('A') });
|
| 19 |
+
|
| 20 |
+
//ws.on('message', function message(_data) { console.log(_data);});
|
| 21 |
+
});
|
| 22 |
+
})()
|
| 23 |
+
`,
|
| 24 |
+
})
|
| 25 |
+
});
|