Spaces:
Sleeping
Sleeping
yes:
Browse files
app.py
CHANGED
@@ -6,6 +6,11 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
6 |
"""
|
7 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
def respond(
|
11 |
message,
|
@@ -42,22 +47,24 @@ def respond(
|
|
42 |
"""
|
43 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
44 |
"""
|
45 |
-
demo = gr.ChatInterface(
|
46 |
-
respond,
|
47 |
-
additional_inputs=[
|
48 |
-
|
49 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
50 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
51 |
-
gr.Slider(
|
52 |
-
minimum=0.1,
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
)
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
6 |
"""
|
7 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
|
9 |
+
SYSTEM_MAGIC = """
|
10 |
+
You have Python function calling. If you output a python type-hinted set of Markdown triple ticks, preceeded by an exclaimation point, the code within will be executed.
|
11 |
+
You may execute the following functions:
|
12 |
+
|
13 |
+
"""
|
14 |
|
15 |
def respond(
|
16 |
message,
|
|
|
47 |
"""
|
48 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
49 |
"""
|
50 |
+
#demo = gr.ChatInterface(
|
51 |
+
# respond,
|
52 |
+
## additional_inputs=[
|
53 |
+
# gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
54 |
+
# gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
55 |
+
# gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
56 |
+
## gr.Slider(
|
57 |
+
## minimum=0.1,
|
58 |
+
# maximum=1.0,
|
59 |
+
# value=0.95,
|
60 |
+
# step=0.05,
|
61 |
+
# label="Top-p (nucleus sampling)",
|
62 |
+
# ),
|
63 |
+
# ],
|
64 |
+
#)
|
65 |
+
with gr.Blocks() as demo:
|
66 |
+
with gr.Row():
|
67 |
+
gr.HTML(open("page.html", "r").read())
|
68 |
+
|
69 |
+
if __name__ == "__main__":
|
70 |
+
demo.launch()
|
page.html
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Document</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<div style="width: 100%; display: flex; flex-direction: col">
|
10 |
+
<button style="z-index: 1 width: 15%; color: green; background-color: darkslategray; box-shadow: 4px 4px 30px
|
11 |
+
black" id="yomama">Send</button> <input style="z-index: 1; width: 100%;" id="message_input" placeholder="Type messages here..." />
|
12 |
+
</div>
|
13 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.min.js" integrity="sha512-WJXVjqeINVpi5XXJ2jn0BSCfp0y80IKrYh731gLRnkAS9TKc5KNt/OfLtu+fCueqdWniouJ1ubM+VI/hbo7POQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
14 |
+
<script>
|
15 |
+
function setup() {
|
16 |
+
createCanvas(window.innerWidth, window.innerHeight);
|
17 |
+
background(153);
|
18 |
+
textSize(32)
|
19 |
+
textAlign(CENTER);
|
20 |
+
text("Loading...", width / 2, height / 2)
|
21 |
+
}
|
22 |
+
|
23 |
+
let txt;
|
24 |
+
|
25 |
+
class SMessage {
|
26 |
+
constructor(send, content) {
|
27 |
+
this.send = send;
|
28 |
+
this.content = content;
|
29 |
+
this.alive = true;
|
30 |
+
this.x = 0;
|
31 |
+
this.y = 32;
|
32 |
+
this.alpha = 255;
|
33 |
+
}
|
34 |
+
|
35 |
+
draw() {
|
36 |
+
fill(color(0, 0, 0, this.alpha));
|
37 |
+
textSize(18);
|
38 |
+
text(`<${this.send}>: ${this.content}`, this.x, this.y);
|
39 |
+
}
|
40 |
+
|
41 |
+
update() {
|
42 |
+
this.x += 1;
|
43 |
+
if (this.x > 920) {
|
44 |
+
this.x = 0;
|
45 |
+
this.y += 32;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
var _messages = [new SMessage("CLIENT", "Connected!")];
|
51 |
+
const minp = document.querySelector("#message_input");
|
52 |
+
minp.addEventListener("submit", (evt) => {
|
53 |
+
_messages.push(new SMessage("Me", msg));
|
54 |
+
});
|
55 |
+
const minp3 = document.querySelector("#yomama");
|
56 |
+
minp3.addEventListener("click", (evt) => {
|
57 |
+
const _minp = document.querySelector("#message_input");
|
58 |
+
const val = _minp.value;
|
59 |
+
_minp.value = "";
|
60 |
+
_messages.push(new SMessage("Me", msg));
|
61 |
+
});
|
62 |
+
|
63 |
+
socket.on("messag", function(mstr, msg) {
|
64 |
+
_messages.push(new SMessage(mstr, msg));
|
65 |
+
console.log(msg)
|
66 |
+
});
|
67 |
+
|
68 |
+
function draw() {
|
69 |
+
background(153);
|
70 |
+
textSize(50)
|
71 |
+
//text(txt, width / 2, height / 2)
|
72 |
+
_messages.forEach((itm) => {
|
73 |
+
if (itm) {
|
74 |
+
itm.draw();
|
75 |
+
itm.update();
|
76 |
+
}
|
77 |
+
});
|
78 |
+
}
|
79 |
+
|
80 |
+
socket.on("update", function(number) {
|
81 |
+
txt = number
|
82 |
+
})
|
83 |
+
</script>
|
84 |
+
</body>
|
85 |
+
</html>
|
script.js
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function setup() {
|
2 |
+
createCanvas(window.innerWidth, window.innerHeight);
|
3 |
+
background(153);
|
4 |
+
textSize(32)
|
5 |
+
textAlign(CENTER);
|
6 |
+
text("Loading...", width / 2, height / 2)
|
7 |
+
}
|
8 |
+
|
9 |
+
let txt;
|
10 |
+
|
11 |
+
class SMessage {
|
12 |
+
constructor(send, content) {
|
13 |
+
this.send = send;
|
14 |
+
this.content = content;
|
15 |
+
this.alive = true;
|
16 |
+
this.x = 0;
|
17 |
+
this.y = 32;
|
18 |
+
this.alpha = 255;
|
19 |
+
}
|
20 |
+
|
21 |
+
draw() {
|
22 |
+
fill(color(0, 0, 0, this.alpha));
|
23 |
+
textSize(18);
|
24 |
+
text(`<${this.send}>: ${this.content}`, this.x, this.y);
|
25 |
+
}
|
26 |
+
|
27 |
+
update() {
|
28 |
+
this.x += 1;
|
29 |
+
if (this.x > 920) {
|
30 |
+
this.x = 0;
|
31 |
+
this.y += 32;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
var _messages = [new SMessage("CLIENT", "Connected!")];
|
37 |
+
const minp = document.querySelector("#message_input");
|
38 |
+
minp.addEventListener("submit", (evt) => {
|
39 |
+
_messages.push(new SMessage("Me", msg));
|
40 |
+
});
|
41 |
+
const minp3 = document.querySelector("#yomama");
|
42 |
+
minp3.addEventListener("click", (evt) => {
|
43 |
+
const _minp = document.querySelector("#message_input");
|
44 |
+
const val = _minp.value;
|
45 |
+
_minp.value = "";
|
46 |
+
_messages.push(new SMessage("Me", msg));
|
47 |
+
});
|
48 |
+
|
49 |
+
socket.on("messag", function(mstr, msg) {
|
50 |
+
_messages.push(new SMessage(mstr, msg));
|
51 |
+
console.log(msg)
|
52 |
+
});
|
53 |
+
|
54 |
+
function draw() {
|
55 |
+
background(153);
|
56 |
+
textSize(50)
|
57 |
+
//text(txt, width / 2, height / 2)
|
58 |
+
_messages.forEach((itm) => {
|
59 |
+
if (itm) {
|
60 |
+
itm.draw();
|
61 |
+
itm.update();
|
62 |
+
}
|
63 |
+
});
|
64 |
+
}
|
65 |
+
|
66 |
+
socket.on("update", function(number) {
|
67 |
+
txt = number
|
68 |
+
})
|