-
Notifications
You must be signed in to change notification settings - Fork 0
/
embeddings_cc_public.htm
93 lines (92 loc) · 4.2 KB
/
embeddings_cc_public.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>☎ embeddings.cc API</title>
<script>
function apiCall(httpMethod, host, path, params) {
var url = host + path;
document.getElementById('request').innerHTML = httpMethod + "\n" + url + "\n" + params;
var xhr = new XMLHttpRequest();
xhr.open(httpMethod, url, true);
xhr.setRequestHeader("Content-type", "application/json");
var begin = new Date();
xhr.onreadystatechange = function() {
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
try {
document.getElementById('result').innerHTML = JSON.stringify(JSON.parse(xhr.responseText), null, 2);
} catch (e) {
document.getElementById('result').innerHTML = xhr.responseText;
document.getElementById('runtime').value = (new Date() - begin) / 1000;
}
} else if (this.readyState === XMLHttpRequest.DONE) {
document.getElementById('result').innerHTML = xhr.responseText;
}
}
if (params) {
xhr.send(params);
} else {
xhr.send();
}
}
</script>
</head>
<body style="font-family:sans-serif">
<div style="max-width:800px;margin:0 auto">
<p style="text-align:center">
APIS:
<a href="https://embeddings.cc/api" target="_blank">embeddings.cc</a> -
<a href="https://embeddings.cs.upb.de:8443/api" target="_blank">embeddings.cs.upb.de:8443</a> -
<a href="http://127.0.0.1:1337/api" target="_blank">127.0.0.1:1337</a>
</p>
<form onsubmit="apiCall(document.getElementById('method').value, document.getElementById('host').value, document.getElementById('path').value, document.getElementById('params').value); return false">
<label for="method">Method:</label>
<select id="method" size="2" style="width:100%;padding:10px">
<option value="POST" selected>POST</option>
<option value="GET">GET</option>
</select>
<label for="host">Host:</label>
<select id="host" size="3" style="width:100%;padding:10px">
<option value="https://embeddings.cc" selected>https://embeddings.cc</option>
<option value="https://embeddings.cs.upb.de:8443">https://embeddings.cs.upb.de:8443</option>
<option value="http://127.0.0.1:1337">http://127.0.0.1:1337</option>
</select>
<label for="path">Path:</label>
<!--
<input type="text" id="path" list="paths" style="width:100%;padding:10px">
<datalist id="paths">
-->
<select id="path" size="7" style="width:100%;padding:10px">
<option value="/api/v1/ping">/api/v1/ping</option>
<option value="/api/v1/get_indices">/api/v1/get_indices</option>
<option value="/api/v1/get_size">/api/v1/get_size</option>
<option value="/api/v1/get_random_entities">/api/v1/get_random_entities</option>
<option value="/api/v1/get_entities">/api/v1/get_entities</option>
<option value="/api/v1/get_embeddings">/api/v1/get_embeddings</option>
<option value="/api/v1/get_similar_embeddings">/api/v1/get_similar_embeddings</option>
<option value="/api/v1/get_similar_entities">/api/v1/get_similar_entities</option>
</select>
<!--
</datalist>
-->
<label for="params">Parameters:</label>
<textarea id="params" style="width:100%;height:120px;padding:10px">
{
"___index": "index_test",
"size": "3",
"offset": "0",
"entities": ["http://example.com/0", "http://example.com/1"],
"embeddings": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]
}
</textarea>
<input type="submit" value="Send request" style="width:100%;padding:10px">
<label for="request">Request:</label>
<textarea id="request" style="width:100%;height:120px;padding:10px;background:#f5f5f5" readonly></textarea>
<label for="result">Result:</label>
<textarea id="result" style="width:100%;height:120px;padding:10px;background:#f5f5f5" readonly></textarea>
<label for="runtime">Runtime:</label>
<input id="runtime" type="text" value="" readonly style="width:100%;padding:10px;background:#f5f5f5">
</form>
</div>
</body>
</html>