Unizomby commited on
Commit
095ee1c
·
verified ·
1 Parent(s): 827fd5f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -16
app.py CHANGED
@@ -20,19 +20,25 @@ def chatbot_response(message):
20
  response = query_engine.query(message)
21
  return str(response)
22
 
23
- # Custom CSS for purple Submit button - Multiple selectors for HF Spaces compatibility
24
  custom_css = """
25
- /* Primary button selectors for different Gradio versions */
26
  button.primary,
27
  .primary,
28
  button[variant="primary"],
29
  .gradio-button.primary,
30
  button.lg.primary,
31
- button.svelte-cmf5ev.primary {
 
 
 
 
 
32
  background: linear-gradient(45deg, #8B5CF6, #A855F7) !important;
33
- border: none !important;
34
  color: white !important;
35
  border-radius: 8px !important;
 
36
  }
37
 
38
  button.primary:hover,
@@ -40,31 +46,57 @@ button.primary:hover,
40
  button[variant="primary"]:hover,
41
  .gradio-button.primary:hover,
42
  button.lg.primary:hover,
43
- button.svelte-cmf5ev.primary:hover {
 
 
 
 
 
44
  background: linear-gradient(45deg, #7C3AED, #9333EA) !important;
45
- transform: translateY(-2px) !important;
46
- box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3) !important;
 
47
  transition: all 0.2s ease !important;
48
  }
49
 
50
- /* More specific selectors for HF Spaces */
51
- .gradio-container button[type="submit"],
52
- .gradio-container .primary-button,
53
- .gradio-container .submit-button {
 
54
  background: linear-gradient(45deg, #8B5CF6, #A855F7) !important;
55
- border: none !important;
56
  color: white !important;
57
  }
58
 
59
- /* Force override any existing styles */
60
- [data-testid="primary-button"],
61
- [role="button"].primary {
 
 
 
 
62
  background: linear-gradient(45deg, #8B5CF6, #A855F7) !important;
63
- border: none !important;
64
  color: white !important;
 
65
  }
66
  """
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  iface = gr.Interface(
69
  fn=chatbot_response,
70
  inputs="text",
@@ -77,6 +109,7 @@ iface = gr.Interface(
77
  ["What technical skills does Donald have?"],
78
  ["How did Donald build this RAG chatbot?"]
79
  ],
 
80
  css=custom_css
81
  )
82
 
 
20
  response = query_engine.query(message)
21
  return str(response)
22
 
23
+ # Custom CSS with even more comprehensive selectors
24
  custom_css = """
25
+ /* Universal purple button styling */
26
  button.primary,
27
  .primary,
28
  button[variant="primary"],
29
  .gradio-button.primary,
30
  button.lg.primary,
31
+ button.svelte-cmf5ev.primary,
32
+ .gradio-container button.primary,
33
+ div[data-testid="submit-button"] button,
34
+ .gradio-interface button[type="submit"],
35
+ button:has-text("Submit"),
36
+ button[title="Submit"] {
37
  background: linear-gradient(45deg, #8B5CF6, #A855F7) !important;
38
+ border: 1px solid #8B5CF6 !important;
39
  color: white !important;
40
  border-radius: 8px !important;
41
+ font-weight: 500 !important;
42
  }
43
 
44
  button.primary:hover,
 
46
  button[variant="primary"]:hover,
47
  .gradio-button.primary:hover,
48
  button.lg.primary:hover,
49
+ button.svelte-cmf5ev.primary:hover,
50
+ .gradio-container button.primary:hover,
51
+ div[data-testid="submit-button"] button:hover,
52
+ .gradio-interface button[type="submit"]:hover,
53
+ button:has-text("Submit"):hover,
54
+ button[title="Submit"]:hover {
55
  background: linear-gradient(45deg, #7C3AED, #9333EA) !important;
56
+ border: 1px solid #7C3AED !important;
57
+ transform: translateY(-1px) !important;
58
+ box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4) !important;
59
  transition: all 0.2s ease !important;
60
  }
61
 
62
+ /* Additional selectors for robustness */
63
+ .gradio-container .submit,
64
+ .gradio-container [data-variant="primary"],
65
+ .interface-submit-btn,
66
+ button.submit-btn {
67
  background: linear-gradient(45deg, #8B5CF6, #A855F7) !important;
68
+ border: 1px solid #8B5CF6 !important;
69
  color: white !important;
70
  }
71
 
72
+ /* Override any Hugging Face specific styles */
73
+ .huggingface-space button.primary {
74
+ background: linear-gradient(45deg, #8B5CF6, #A855F7) !important;
75
+ }
76
+
77
+ /* Fallback with more general selector */
78
+ button:nth-child(2):not(.secondary) {
79
  background: linear-gradient(45deg, #8B5CF6, #A855F7) !important;
 
80
  color: white !important;
81
+ border: 1px solid #8B5CF6 !important;
82
  }
83
  """
84
 
85
+ # Create custom theme
86
+ purple_theme = gr.themes.Soft(
87
+ primary_hue="violet",
88
+ secondary_hue="gray",
89
+ neutral_hue="gray",
90
+ ).set(
91
+ button_primary_background_fill="#8B5CF6",
92
+ button_primary_background_fill_dark="#7C3AED",
93
+ button_primary_background_fill_hover="#A855F7",
94
+ button_primary_border_color="#8B5CF6",
95
+ button_primary_border_color_dark="#7C3AED",
96
+ button_primary_text_color="white",
97
+ button_primary_text_color_dark="white"
98
+ )
99
+
100
  iface = gr.Interface(
101
  fn=chatbot_response,
102
  inputs="text",
 
109
  ["What technical skills does Donald have?"],
110
  ["How did Donald build this RAG chatbot?"]
111
  ],
112
+ theme=purple_theme,
113
  css=custom_css
114
  )
115