Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- README.md +3 -9
- import gradio as gr.py +65 -0
- requirements.txt +1 -0
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: green
|
5 |
-
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: prova
|
3 |
+
app_file: import gradio as gr.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
+
sdk_version: 4.21.0
|
|
|
|
|
6 |
---
|
|
|
|
import gradio as gr.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import time
|
3 |
+
from openai import OpenAI
|
4 |
+
client = OpenAI(api_key="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")
|
5 |
+
|
6 |
+
def slowecho(message, history):
|
7 |
+
for i in range(len(message)):
|
8 |
+
time.sleep(0.05)
|
9 |
+
yield "You typed: " + message[: i + 1]
|
10 |
+
|
11 |
+
js = """
|
12 |
+
function createGradioAnimation() {
|
13 |
+
var container = document.createElement('div');
|
14 |
+
container.id = 'gradio-animation';
|
15 |
+
container.style.fontSize = '2em';
|
16 |
+
container.style.fontWeight = 'bold';
|
17 |
+
container.style.textAlign = 'center';
|
18 |
+
container.style.marginBottom = '20px';
|
19 |
+
container.style.color = 'black';
|
20 |
+
|
21 |
+
var text = 'Assistente virtuale di Fabio Pizzul!';
|
22 |
+
for (var i = 0; i < text.length; i++) {
|
23 |
+
(function(i){
|
24 |
+
setTimeout(function(){
|
25 |
+
var letter = document.createElement('span');
|
26 |
+
letter.style.opacity = '0';
|
27 |
+
letter.style.transition = 'opacity 0.5s';
|
28 |
+
letter.innerText = text[i];
|
29 |
+
|
30 |
+
container.appendChild(letter);
|
31 |
+
|
32 |
+
setTimeout(function() {
|
33 |
+
letter.style.opacity = '1';
|
34 |
+
}, 50);
|
35 |
+
}, i * 250);
|
36 |
+
})(i);
|
37 |
+
}
|
38 |
+
|
39 |
+
var gradioContainer = document.querySelector('.gradio-container');
|
40 |
+
gradioContainer.insertBefore(container, gradioContainer.firstChild);
|
41 |
+
|
42 |
+
//Sfondo
|
43 |
+
gradioContainer.style.background = 'white';
|
44 |
+
gradioContainer.style.color = 'black';
|
45 |
+
|
46 |
+
|
47 |
+
return 'Animation created';
|
48 |
+
}
|
49 |
+
"""
|
50 |
+
theme = gr.themes.Base(
|
51 |
+
neutral_hue="zinc",
|
52 |
+
)
|
53 |
+
|
54 |
+
textbox=gr.Textbox(placeholder="Fammi una domanda", container=False, scale=7)
|
55 |
+
|
56 |
+
with gr.Blocks(js=js, theme=theme) as demo:
|
57 |
+
chat= gr.ChatInterface(
|
58 |
+
slowecho,
|
59 |
+
textbox=textbox,
|
60 |
+
retry_btn=None,
|
61 |
+
undo_btn=None,
|
62 |
+
clear_btn=None,
|
63 |
+
)
|
64 |
+
|
65 |
+
demo.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
openai
|