cylnx commited on
Commit
ecc91b8
·
verified ·
1 Parent(s): 295ebf0

🎨 Redesign from AnyCoder

Browse files

This Pull Request contains a redesigned version of the app with:

- ✨ Modern, mobile-friendly design
- 🎯 Minimal, clean components
- 📱 Responsive layout
- 🚀 Improved user experience

Generated by [AnyCoder](https://huggingface.co/spaces/akhaliq/anycoder)

Files changed (1) hide show
  1. app.py +187 -2
app.py CHANGED
@@ -8,7 +8,6 @@ if not (key := os.getenv("NVIDIA_API_KEY")):
8
  client = OpenAI(base_url="https://integrate.api.nvidia.com/v1", api_key=key)
9
 
10
  def respond(message, history):
11
- # В Gradio 4.x история уже в формате OpenAI (список словарей)
12
  messages = history + [{"role": "user", "content": message}]
13
 
14
  try:
@@ -28,5 +27,191 @@ def respond(message, history):
28
  except Exception as e:
29
  yield f"Ошибка: {e}"
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  if __name__ == "__main__":
32
- gr.ChatInterface(respond, title="Step 3.5 Flash").launch(ssr_mode=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  client = OpenAI(base_url="https://integrate.api.nvidia.com/v1", api_key=key)
9
 
10
  def respond(message, history):
 
11
  messages = history + [{"role": "user", "content": message}]
12
 
13
  try:
 
27
  except Exception as e:
28
  yield f"Ошибка: {e}"
29
 
30
+ # Custom theme for modern, clean look
31
+ custom_theme = gr.themes.Soft(
32
+ primary_hue="teal",
33
+ secondary_hue="gray",
34
+ neutral_hue="slate",
35
+ font=gr.themes.GoogleFont("Inter"),
36
+ text_size="lg",
37
+ spacing_size="lg",
38
+ radius_size="md"
39
+ ).set(
40
+ button_primary_background_fill="*primary_600",
41
+ button_primary_background_fill_hover="*primary_700",
42
+ block_title_text_weight="600",
43
+ body_background_fill="*neutral_50",
44
+ )
45
+
46
+ # Custom CSS for mobile-friendly design
47
+ custom_css = """
48
+ /* Mobile-first responsive design */
49
+ .gradio-container {
50
+ max-width: 100% !important;
51
+ padding: 8px !important;
52
+ }
53
+
54
+ /* Chat container optimization */
55
+ .chat-container {
56
+ max-width: 800px;
57
+ margin: 0 auto;
58
+ }
59
+
60
+ /* Better message bubbles */
61
+ .message {
62
+ padding: 12px 16px !important;
63
+ border-radius: 12px !important;
64
+ }
65
+
66
+ /* User message styling */
67
+ .message.user {
68
+ background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%) !important;
69
+ color: white !important;
70
+ }
71
+
72
+ /* Assistant message styling */
73
+ .message.assistant {
74
+ background: white !important;
75
+ border: 1px solid #e2e8f0 !important;
76
+ color: #1e293b !important;
77
+ }
78
+
79
+ /* Input area optimization */
80
+ .input-area {
81
+ padding: 12px !important;
82
+ background: white !important;
83
+ border-radius: 12px !important;
84
+ box-shadow: 0 -2px 10px rgba(0,0,0,0.05) !important;
85
+ }
86
+
87
+ /* Textbox styling */
88
+ .textarea {
89
+ border-radius: 12px !important;
90
+ border: 2px solid #e2e8f0 !important;
91
+ padding: 12px !important;
92
+ transition: border-color 0.2s ease !important;
93
+ }
94
+
95
+ .textarea:focus {
96
+ border-color: #14b8a6 !important;
97
+ outline: none !important;
98
+ }
99
+
100
+ /* Button styling */
101
+ .submit-button {
102
+ border-radius: 10px !important;
103
+ transition: transform 0.15s ease, box-shadow 0.15s ease !important;
104
+ }
105
+
106
+ .submit-button:hover {
107
+ transform: translateY(-1px) !important;
108
+ box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3) !important;
109
+ }
110
+
111
+ /* Title area */
112
+ .title-area {
113
+ text-align: center;
114
+ padding: 16px 0 !important;
115
+ }
116
+
117
+ .title-area h1 {
118
+ font-size: 1.5rem !important;
119
+ font-weight: 600 !important;
120
+ color: #1e293b !important;
121
+ margin-bottom: 4px !important;
122
+ }
123
+
124
+ .title-area p {
125
+ color: #64748b !important;
126
+ font-size: 0.9rem !important;
127
+ }
128
+
129
+ /* Reduce padding on mobile */
130
+ @media (max-width: 640px) {
131
+ .gradio-container {
132
+ padding: 4px !important;
133
+ }
134
+
135
+ .chat-message {
136
+ font-size: 0.95rem !important;
137
+ }
138
+
139
+ .title-area h1 {
140
+ font-size: 1.25rem !important;
141
+ }
142
+ }
143
+
144
+ /* Subtle animations */
145
+ @keyframes fadeIn {
146
+ from { opacity: 0; transform: translateY(8px); }
147
+ to { opacity: 1; transform: translateY(0); }
148
+ }
149
+
150
+ .message {
151
+ animation: fadeIn 0.2s ease-out !important;
152
+ }
153
+ """
154
+
155
+ # Custom JavaScript for enhanced UX
156
+ custom_js = """
157
+ function() {
158
+ // Add smooth scroll behavior
159
+ const style = document.createElement('style');
160
+ style.textContent = `
161
+ html { scroll-behavior: smooth; }
162
+ .chat-scroller { scroll-behavior: smooth; }
163
+ `;
164
+ document.head.appendChild(style);
165
+ }
166
+ """
167
+
168
  if __name__ == "__main__":
169
+ with gr.Blocks(
170
+ title="Step 3.5 Flash Chat",
171
+ fill_height=True
172
+ ) as demo:
173
+ # Header with anycoder link
174
+ gr.HTML("""
175
+ <div style="text-align: center; padding: 12px 0; margin-bottom: 8px;">
176
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder"
177
+ target="_blank"
178
+ style="font-size: 0.75rem; color: #64748b; text-decoration: none; opacity: 0.7;">
179
+ Built with anycoder
180
+ </a>
181
+ </div>
182
+ """)
183
+
184
+ gr.ChatInterface(
185
+ respond,
186
+ title="Step 3.5 Flash",
187
+ description="Chat with Step 3.5 Flash - Powered by NVIDIA",
188
+ chatbot=gr.Chatbot(
189
+ show_label=False,
190
+ container=True,
191
+ height=500,
192
+ bubble_full_width=False,
193
+ layout="bubble",
194
+ avatar_images=(None, None),
195
+ render_markdown=True,
196
+ ),
197
+ textbox=gr.Textbox(
198
+ placeholder="Type your message...",
199
+ show_label=False,
200
+ container=True,
201
+ scale=5,
202
+ ),
203
+ submit_btn="Send",
204
+ stop_btn="Stop",
205
+ clear_btn="Clear",
206
+ show_examples=False,
207
+ show_copy_button=True,
208
+ fill_height=True,
209
+ )
210
+
211
+ demo.launch(
212
+ theme=custom_theme,
213
+ css=custom_css,
214
+ js=custom_js,
215
+ fill_width=True,
216
+ ssr_mode=False,
217
+ )