Upload index.html
Browse files- index.html +29 -0
index.html
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html>
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8" />
|
| 6 |
+
<title>Open WebUI 模擬版</title>
|
| 7 |
+
<script>
|
| 8 |
+
async function callAPI() {
|
| 9 |
+
const res = await fetch("https://huggingface.co/spaces/Apex123/Chat/v1/chat/completions", {
|
| 10 |
+
method: "POST",
|
| 11 |
+
headers: {
|
| 12 |
+
"Content-Type": "application/json"
|
| 13 |
+
},
|
| 14 |
+
body: JSON.stringify({
|
| 15 |
+
model: "gpt-4",
|
| 16 |
+
messages: [{ role: "user", content: "你好嗎?" }]
|
| 17 |
+
})
|
| 18 |
+
});
|
| 19 |
+
const data = await res.json();
|
| 20 |
+
document.getElementById("result").innerText = data.choices?.[0]?.message?.content || "沒有回應";
|
| 21 |
+
}
|
| 22 |
+
</script>
|
| 23 |
+
</head>
|
| 24 |
+
<body>
|
| 25 |
+
<h1>Open WebUI 前端(連接到 API)</h1>
|
| 26 |
+
<button onclick="callAPI()">送出測試訊息</button>
|
| 27 |
+
<pre id="result">尚未請求</pre>
|
| 28 |
+
</body>
|
| 29 |
+
</html>
|