vbhalla8 commited on
Commit
e9129d8
·
verified ·
1 Parent(s): 5a320ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -98
app.py CHANGED
@@ -4,84 +4,12 @@ from huggingface_hub import InferenceClient
4
  # SETS UP CLIENT INTERFACE API
5
  client = InferenceClient()
6
 
7
- # SVG vampire animation code
8
  VAMPIRE_SVG = '''
9
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" style="width: 200px; height: 200px;">
10
- <defs>
11
- <style>
12
- @keyframes eyeGlow {
13
- 0%, 100% { filter: drop-shadow(0 0 2px #ff3300); }
14
- 50% { filter: drop-shadow(0 0 4px #ff3300); }
15
- }
16
- @keyframes floating {
17
- 0%, 100% { transform: translateY(0) rotate(-2deg); }
18
- 50% { transform: translateY(-5px) rotate(2deg); }
19
- }
20
- @keyframes capeWave {
21
- 0%, 100% { transform: skewX(0deg); }
22
- 50% { transform: skewX(-5deg); }
23
- }
24
- @keyframes angryShake {
25
- 0%, 100% { transform: translateX(0); }
26
- 25% { transform: translateX(-2px); }
27
- 75% { transform: translateX(2px); }
28
- }
29
- </style>
30
- </defs>
31
-
32
- <!-- Dramatic cape background -->
33
- <g style="animation: capeWave 3s ease-in-out infinite">
34
- <path d="M100 150 Q 200 180 300 150 L 350 400 L 50 400 Z" fill="#880000"/>
35
- <path d="M120 150 Q 200 170 280 150 L 320 400 L 80 400 Z" fill="#aa0000"/>
36
- </g>
37
-
38
- <!-- Main character group -->
39
- <g style="animation: floating 4s ease-in-out infinite">
40
- <!-- Suit -->
41
- <rect x="165" y="140" width="70" height="90" rx="5" fill="#111111"/>
42
- <rect x="180" y="140" width="40" height="70" fill="#ffffff"/>
43
- <path d="M185 150 Q 200 145 215 150 Q 200 155 185 150" fill="#cc0000"/>
44
-
45
- <!-- Face -->
46
- <path d="M160 130 C 160 70, 240 70, 240 130 Q 200 160 160 130" fill="#ffe6e6"/>
47
-
48
- <!-- Angry pointed ears -->
49
- <path d="M160 110 Q 150 95 165 105" fill="#ffe6e6"/>
50
- <path d="M240 110 Q 250 95 235 105" fill="#ffe6e6"/>
51
-
52
- <!-- Spiky angry hair -->
53
- <g style="animation: angryShake 0.5s ease-in-out infinite">
54
- <path d="M155 120 C 150 60, 250 60, 245 120" fill="#111111"/>
55
- <path d="M165 85 Q 175 60 185 85" fill="#111111"/>
56
- <path d="M185 80 Q 200 50 215 80" fill="#111111"/>
57
- <path d="M215 85 Q 225 60 235 85" fill="#111111"/>
58
- </g>
59
-
60
- <!-- Angry eyes -->
61
- <g style="animation: eyeGlow 1s ease-in-out infinite">
62
- <path d="M165 105 Q 180 95 195 105 Q 180 115 165 105" fill="#ffffff"/>
63
- <path d="M205 105 Q 220 95 235 105 Q 220 115 205 105" fill="#ffffff"/>
64
- <circle cx="180" cy="105" r="8" fill="#ff3300"/>
65
- <circle cx="220" cy="105" r="8" fill="#ff3300"/>
66
- <circle cx="180" cy="105" r="4" fill="#000000"/>
67
- <circle cx="220" cy="105" r="4" fill="#000000"/>
68
- </g>
69
-
70
- <!-- Angry eyebrows -->
71
- <g style="animation: angryShake 0.5s ease-in-out infinite">
72
- <path d="M165 95 Q 180 85 195 95" stroke="#111111" stroke-width="3" fill="none"/>
73
- <path d="M205 95 Q 220 85 235 95" stroke="#111111" stroke-width="3" fill="none"/>
74
- </g>
75
-
76
- <!-- Angry mouth with fangs -->
77
- <path d="M185 125 Q 200 120 215 125" fill="none" stroke="#111111" stroke-width="2"/>
78
- <path d="M190 125 L 195 133 L 200 125" fill="#ffffff"/>
79
- <path d="M200 125 L 205 133 L 210 125" fill="#ffffff"/>
80
- </g>
81
- </svg>
82
  '''
83
 
84
- # Updated CSS with flexbox layout
85
  CSS_CODE = '''
86
  body {
87
  background-color: black;
@@ -90,16 +18,59 @@ body {
90
  background-position: center;
91
  background-position-y: -100px;
92
  }
93
- .vampire-container {
 
94
  display: flex;
95
- justify-content: center;
96
- margin-bottom: 20px;
 
 
 
 
 
 
 
 
97
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  .title {
99
  color: #cc0000;
100
  text-align: center;
101
  font-family: "Gothic", serif;
102
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
  '''
105
 
@@ -126,27 +97,36 @@ def respond(prompt: str, history):
126
  yield history + [response]
127
 
128
  with gr.Blocks(css=CSS_CODE) as demo:
129
- gr.HTML(f'''
130
- <h1 class="title">DRACULABOT</h1>
131
- <h2 class="title">A Dracula Themed AI ChatBot</h2>
132
- <div class="vampire-container">{VAMPIRE_SVG}</div>
133
- ''')
134
-
135
- with gr.Row():
136
- with gr.Column():
137
- chatbot = gr.Chatbot(
138
- height=600,
139
- label="Dracula",
140
- type="messages"
141
- )
142
- prompt = gr.Textbox(
143
- max_lines=1,
144
- label="Chat Message",
145
- placeholder="Ask your question, Mortal"
146
- )
 
 
 
 
 
147
 
148
- prompt.submit(respond, [prompt, chatbot], [chatbot])
149
- prompt.submit(lambda: "", None, [prompt])
 
 
 
 
150
 
151
  if __name__ == "__main__":
152
  demo.launch()
 
4
  # SETS UP CLIENT INTERFACE API
5
  client = InferenceClient()
6
 
7
+ # SVG vampire animation code (same as before)
8
  VAMPIRE_SVG = '''
9
+ [Previous SVG code remains the same]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  '''
11
 
12
+ # Updated CSS with right-aligned layout
13
  CSS_CODE = '''
14
  body {
15
  background-color: black;
 
18
  background-position: center;
19
  background-position-y: -100px;
20
  }
21
+
22
+ .container {
23
  display: flex;
24
+ flex-direction: column;
25
+ align-items: center;
26
+ }
27
+
28
+ .chat-container {
29
+ display: flex;
30
+ width: 100%;
31
+ max-width: 1200px;
32
+ gap: 20px;
33
+ margin: 0 auto;
34
  }
35
+
36
+ .chat-column {
37
+ flex: 1;
38
+ min-width: 0;
39
+ }
40
+
41
+ .vampire-column {
42
+ width: 300px;
43
+ position: sticky;
44
+ top: 20px;
45
+ align-self: flex-start;
46
+ }
47
+
48
+ .vampire-container {
49
+ background: rgba(0, 0, 0, 0.5);
50
+ border-radius: 10px;
51
+ padding: 20px;
52
+ margin-top: 20px;
53
+ }
54
+
55
  .title {
56
  color: #cc0000;
57
  text-align: center;
58
  font-family: "Gothic", serif;
59
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
60
+ margin-bottom: 20px;
61
+ }
62
+
63
+ /* Custom styling for chat interface */
64
+ .chatbot {
65
+ background: rgba(0, 0, 0, 0.7) !important;
66
+ border: 1px solid #cc0000 !important;
67
+ border-radius: 10px !important;
68
+ }
69
+
70
+ .textbox {
71
+ background: rgba(0, 0, 0, 0.7) !important;
72
+ border: 1px solid #cc0000 !important;
73
+ color: #ffffff !important;
74
  }
75
  '''
76
 
 
97
  yield history + [response]
98
 
99
  with gr.Blocks(css=CSS_CODE) as demo:
100
+ with gr.Column(elem_classes="container"):
101
+ gr.HTML('''
102
+ <h1 class="title">DRACULABOT</h1>
103
+ <h2 class="title">A Dracula Themed AI ChatBot</h2>
104
+ ''')
105
+
106
+ with gr.Row(elem_classes="chat-container"):
107
+ with gr.Column(elem_classes="chat-column"):
108
+ chatbot = gr.Chatbot(
109
+ height=600,
110
+ label="Dracula",
111
+ type="messages",
112
+ elem_classes="chatbot"
113
+ )
114
+ prompt = gr.Textbox(
115
+ max_lines=1,
116
+ label="Chat Message",
117
+ placeholder="Ask your question, Mortal",
118
+ elem_classes="textbox"
119
+ )
120
+
121
+ prompt.submit(respond, [prompt, chatbot], [chatbot])
122
+ prompt.submit(lambda: "", None, [prompt])
123
 
124
+ with gr.Column(elem_classes="vampire-column"):
125
+ gr.HTML(f'''
126
+ <div class="vampire-container">
127
+ {VAMPIRE_SVG}
128
+ </div>
129
+ ''')
130
 
131
  if __name__ == "__main__":
132
  demo.launch()