DSDUDEd commited on
Commit
1346f49
·
verified ·
1 Parent(s): ee1270f

Create script.js

Browse files
Files changed (1) hide show
  1. script.js +16 -0
script.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.getElementById("send-btn").onclick = async () => {
2
+ const message = document.getElementById("user-input").value;
3
+ const model = document.getElementById("model-select").value;
4
+ const output = document.getElementById("output");
5
+
6
+ output.textContent = "Generating...";
7
+
8
+ const res = await fetch("/api/chat", {
9
+ method: "POST",
10
+ headers: { "Content-Type": "application/json" },
11
+ body: JSON.stringify({ message, model })
12
+ });
13
+
14
+ const data = await res.json();
15
+ output.textContent = data.response;
16
+ };