File size: 1,349 Bytes
8859b87
e44226c
 
 
 
 
 
 
 
8859b87
 
 
f4d3aa3
 
af824f1
f4d3aa3
 
8859b87
f4d3aa3
8859b87
f4d3aa3
 
8859b87
 
 
 
 
e44226c
8859b87
 
 
 
 
af824f1
8859b87
 
 
 
e44226c
f4d3aa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
### ROUND 1 ###
# import gradio as gr

# def echo(message, history):
#     return message

# demo = gr.ChatInterface(fn=echo, type="messages", examples=["hello", "hola", "merhaba"], title="Echo Bot")
# demo.launch()

# import gradio as gr

### ROUND 2 ###
# import random
# import gradio as gr

# def random_response(message, history):
#     return random.choice(["Yes", "No"])

# demo = gr.ChatInterface(random_response, type="messages", autofocus=True)

# if __name__ == "__main__":
#     demo.launch()


### ROUND 3 ###
# def yes(message, history):
#     return "yes"

# def vote(data: gr.LikeData):
#     if data.liked:
#         print("You upvoted this response: " + data.value["value"])
#     else:
#         print("You downvoted this response: " + data.value["value"])

# with gr.Blocks() as demo:
#     chatbot = gr.Chatbot(placeholder="<strong>Your Personal Yes-Man</strong><br>Ask Me Anything")
#     chatbot.like(vote, None, None)
#     gr.ChatInterface(fn=yes, type="messages", chatbot=chatbot)
    
# demo.launch()

### ROUND 4 ###
import time
import gradio as gr

def slow_echo(message, history):
    for i in range(len(message)):
        time.sleep(0.05)
        yield "You typed: " + message[: i + 1]

demo = gr.ChatInterface(
    slow_echo,
    type="messages",
    save_history=True,
)

if __name__ == "__main__":
    demo.launch()