Görkem Göknar commited on
Commit
fba635a
1 Parent(s): a4e6d2d
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +30 -0
README.md CHANGED
@@ -11,7 +11,7 @@ pinned: false
11
  # Configuration
12
 
13
  `title`: _string_
14
- Display title for the Space
15
 
16
  `emoji`: _string_
17
  Space emoji (emoji-only character allowed)
11
  # Configuration
12
 
13
  `title`: _string_
14
+ Poc with no model first
15
 
16
  `emoji`: _string_
17
  Space emoji (emoji-only character allowed)
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+
4
+ def chat(message):
5
+ history = gr.get_state() or []
6
+ if message.startswith("How many"):
7
+ response = random.randint(1,10)
8
+ elif message.startswith("How"):
9
+ response = random.choice(["Great", "Good", "Okay", "Bad"])
10
+ elif message.startswith("Where"):
11
+ response = random.choice(["Here", "There", "Somewhere"])
12
+ else:
13
+ response = "I don't know"
14
+ history.append((message, response))
15
+ gr.set_state(history)
16
+ html = "<div class='chatbot'>"
17
+ for user_msg, resp_msg in history:
18
+ html += f"<div class='user_msg'>{user_msg}</div>"
19
+ html += f"<div class='resp_msg'>{resp_msg}</div>"
20
+ html += "</div>"
21
+ return html
22
+
23
+ iface = gr.Interface(chat, "text", "html", css="""
24
+ .chatbox {display:flex;flex-direction:column}
25
+ .user_msg, .resp_msg {padding:4px;margin-bottom:4px;border-radius:4px;width:80%}
26
+ .user_msg {background-color:cornflowerblue;color:white;align-self:start}
27
+ .resp_msg {background-color:lightgray;align-self:self-end}
28
+ """, allow_screenshot=False, allow_flagging=False)
29
+ if __name__ == "__main__":
30
+ iface.launch()