|
|
| <!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> |
|
|