Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,9 @@ GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
|
| 9 |
# ===============================
|
| 10 |
# π§ Usage Limit Configuration
|
| 11 |
# ===============================
|
| 12 |
-
ENABLE_IP_LIMIT = True
|
| 13 |
-
MAX_USES = 1
|
| 14 |
-
USAGE_FILE = "ip_usage.json"
|
| 15 |
# ===============================
|
| 16 |
|
| 17 |
if not GROQ_API_KEY:
|
|
@@ -62,15 +62,14 @@ def groq_api_chat(prompt, model="llama3-8b-8192", max_tokens=800):
|
|
| 62 |
# Helpers
|
| 63 |
# -------------------------------
|
| 64 |
def get_component_updates(interactive_state: bool):
|
| 65 |
-
"""Returns a tuple of gr.update objects for all interactive components."""
|
| 66 |
upd = gr.update(interactive=interactive_state)
|
| 67 |
return (
|
| 68 |
-
upd, upd, upd,
|
| 69 |
-
upd,
|
| 70 |
-
upd, upd, upd, upd, upd, upd,
|
| 71 |
-
upd,
|
| 72 |
-
upd,
|
| 73 |
-
upd
|
| 74 |
)
|
| 75 |
|
| 76 |
def enforce_limit(request: gr.Request):
|
|
@@ -217,32 +216,64 @@ def social_channel_launch(request: gr.Request, channel, hashtags, checkbox_value
|
|
| 217 |
# UI
|
| 218 |
# -------------------------------
|
| 219 |
CSS = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
body {
|
| 221 |
-
background-color:
|
| 222 |
-
color:
|
| 223 |
}
|
|
|
|
|
|
|
| 224 |
.gradio-container {
|
| 225 |
-
background-color:
|
| 226 |
-
color:
|
|
|
|
|
|
|
| 227 |
}
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
}
|
|
|
|
|
|
|
| 233 |
.gr-button {
|
| 234 |
-
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
| 236 |
}
|
| 237 |
.gr-button:hover {
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
.gr-checkbox, .gr-checkbox-group {
|
| 241 |
-
color: white !important;
|
| 242 |
}
|
|
|
|
|
|
|
| 243 |
.gradio-container h1, .gradio-container h2, .gradio-container label, .gradio-container p {
|
| 244 |
-
color:
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
}
|
| 247 |
"""
|
| 248 |
|
|
|
|
| 9 |
# ===============================
|
| 10 |
# π§ Usage Limit Configuration
|
| 11 |
# ===============================
|
| 12 |
+
ENABLE_IP_LIMIT = True
|
| 13 |
+
MAX_USES = 1
|
| 14 |
+
USAGE_FILE = "ip_usage.json"
|
| 15 |
# ===============================
|
| 16 |
|
| 17 |
if not GROQ_API_KEY:
|
|
|
|
| 62 |
# Helpers
|
| 63 |
# -------------------------------
|
| 64 |
def get_component_updates(interactive_state: bool):
|
|
|
|
| 65 |
upd = gr.update(interactive=interactive_state)
|
| 66 |
return (
|
| 67 |
+
upd, upd, upd,
|
| 68 |
+
upd,
|
| 69 |
+
upd, upd, upd, upd, upd, upd,
|
| 70 |
+
upd,
|
| 71 |
+
upd,
|
| 72 |
+
upd
|
| 73 |
)
|
| 74 |
|
| 75 |
def enforce_limit(request: gr.Request):
|
|
|
|
| 216 |
# UI
|
| 217 |
# -------------------------------
|
| 218 |
CSS = """
|
| 219 |
+
/* Set the primary colors */
|
| 220 |
+
:root {
|
| 221 |
+
--bg-color: #0d1117;
|
| 222 |
+
--text-color: #c9d1d9;
|
| 223 |
+
--border-color: #30363d;
|
| 224 |
+
--primary-color: #58a6ff;
|
| 225 |
+
--secondary-color: #4a5665;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
body {
|
| 229 |
+
background-color: var(--bg-color) !important;
|
| 230 |
+
color: var(--text-color) !important;
|
| 231 |
}
|
| 232 |
+
|
| 233 |
+
/* General container and card styling */
|
| 234 |
.gradio-container {
|
| 235 |
+
background-color: var(--bg-color) !important;
|
| 236 |
+
color: var(--text-color) !important;
|
| 237 |
+
border: none;
|
| 238 |
+
box-shadow: none;
|
| 239 |
}
|
| 240 |
+
|
| 241 |
+
.gradio-container .block {
|
| 242 |
+
border-color: var(--border-color) !important;
|
| 243 |
+
background-color: var(--bg-color) !important;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
/* Input components */
|
| 247 |
+
.gr-text-input, .gr-dropdown, .gr-checkbox-group, .gr-checkbox-label {
|
| 248 |
+
background-color: var(--bg-color) !important;
|
| 249 |
+
border-color: var(--border-color) !important;
|
| 250 |
+
color: var(--text-color) !important;
|
| 251 |
}
|
| 252 |
+
|
| 253 |
+
/* Button styling */
|
| 254 |
.gr-button {
|
| 255 |
+
background-color: var(--secondary-color) !important;
|
| 256 |
+
color: var(--text-color) !important;
|
| 257 |
+
border: 1px solid var(--primary-color) !important;
|
| 258 |
+
font-weight: bold;
|
| 259 |
+
border-radius: 4px;
|
| 260 |
}
|
| 261 |
.gr-button:hover {
|
| 262 |
+
background-color: var(--primary-color) !important;
|
| 263 |
+
color: var(--bg-color) !important;
|
|
|
|
|
|
|
| 264 |
}
|
| 265 |
+
|
| 266 |
+
/* Headings and labels */
|
| 267 |
.gradio-container h1, .gradio-container h2, .gradio-container label, .gradio-container p {
|
| 268 |
+
color: var(--text-color) !important;
|
| 269 |
+
font-weight: bold;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
/* Specific Markdown for outputs */
|
| 273 |
+
.gradio-container .gr-markdown, .gradio-container .gr-markdown-container {
|
| 274 |
+
background-color: var(--bg-color) !important;
|
| 275 |
+
color: var(--text-color) !important;
|
| 276 |
+
border-color: var(--border-color) !important;
|
| 277 |
}
|
| 278 |
"""
|
| 279 |
|