File size: 864 Bytes
25bf773
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Open WebUI 模擬版</title>
    <script>
      async function callAPI() {
        const res = await fetch("https://huggingface.co/spaces/Apex123/Chat/v1/chat/completions", {
          method: "POST",
          headers: {
            "Content-Type": "application/json"
          },
          body: JSON.stringify({
            model: "gpt-4",
            messages: [{ role: "user", content: "你好嗎?" }]
          })
        });
        const data = await res.json();
        document.getElementById("result").innerText = data.choices?.[0]?.message?.content || "沒有回應";
      }
    </script>
  </head>
  <body>
    <h1>Open WebUI 前端(連接到 API)</h1>
    <button onclick="callAPI()">送出測試訊息</button>
    <pre id="result">尚未請求</pre>
  </body>
</html>