ramdas.murali commited on
Commit
66602d6
1 Parent(s): 1da0d23

adding app files

Browse files
Files changed (1) hide show
  1. app.py +70 -0
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import gradio as gr
2
+ # import random
3
+ # import time
4
+
5
+ # with gr.Blocks() as demo:
6
+ # chatbot = gr.Chatbot()
7
+ # msg = gr.Textbox()
8
+ # clear = gr.ClearButton([msg, chatbot])
9
+
10
+ # def respond(message, chat_history):
11
+ # bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
12
+ # chat_history.append((message, bot_message))
13
+ # time.sleep(2)
14
+ # return "", chat_history
15
+
16
+ # msg.submit(respond, [msg, chatbot], [msg, chatbot])
17
+
18
+ # demo.launch()
19
+
20
+
21
+ import gradio as gr
22
+ import random
23
+ import time
24
+
25
+
26
+ css="""
27
+ .feedback {font-size: 24px !important;}
28
+ .feedback textarea {font-size: 24px !important;}
29
+ .rightx { position: relative !important;
30
+ float: right !important;
31
+ border: 2px solid #ff1100 !important;
32
+ }"""
33
+
34
+ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
35
+
36
+
37
+
38
+ def vote(data: gr.LikeData):
39
+ if data.liked:
40
+ print("You upvoted this response: " + data.value)
41
+ else:
42
+ print("You downvoted this response: " + data.value)
43
+
44
+
45
+ img = gr.Image(label=None, height=100, width=100, show_label=False, show_download_button=False, value="https://d2q79iu7y748jz.cloudfront.net/s/_squarelogo/256x256/0c7f916071ff42079edf5ce9e60321c1")
46
+ chatbot = gr.Chatbot(label="Agent")
47
+ chatbot.like(vote, None, None) # Adding this line causes the like/dislike icons to appear in your chatbot
48
+ msg = gr.Textbox(label="Query")
49
+ clear = gr.Button("Clear", min_width=20, scale=0)
50
+
51
+
52
+
53
+ def user(user_message, history):
54
+ return "", history + [[user_message, None]]
55
+
56
+ def bot(history):
57
+ bot_message = random.choice(["How are you?", "Thats really good", "I'm very hungry", "Do you extrude Aluminum?"])
58
+ history[-1][1] = ""
59
+ for character in bot_message:
60
+ history[-1][1] += character
61
+ time.sleep(0.05)
62
+ yield history
63
+
64
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
65
+ bot, chatbot, chatbot
66
+ )
67
+ clear.click(lambda: None, None, chatbot, queue=False)
68
+
69
+ demo.queue()
70
+ demo.launch()