Spaces:
Paused
Paused
Handle missing Blablador key
Browse files
app.py
CHANGED
|
@@ -822,9 +822,10 @@ async def generate_response(prompt: str, max_new_tokens: int = MAX_NEW_TOKENS) -
|
|
| 822 |
|
| 823 |
url = f"{REMOTE_API_BASE}/completions"
|
| 824 |
headers = {
|
| 825 |
-
"Content-Type": "application/json"
|
| 826 |
-
"Authorization": f"Bearer {BLABLADOR_API_KEY}"
|
| 827 |
}
|
|
|
|
|
|
|
| 828 |
payload = {
|
| 829 |
"model": selected_model,
|
| 830 |
"prompt": prompt,
|
|
@@ -857,6 +858,13 @@ async def run_agent_streaming(
|
|
| 857 |
yield "<p style='color: var(--body-text-color-subdued); text-align: center; padding: 2rem;'>Please enter a question to begin.</p>"
|
| 858 |
return
|
| 859 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
# Load tokenizer for prompt formatting
|
| 861 |
try:
|
| 862 |
load_tokenizer()
|
|
|
|
| 822 |
|
| 823 |
url = f"{REMOTE_API_BASE}/completions"
|
| 824 |
headers = {
|
| 825 |
+
"Content-Type": "application/json"
|
|
|
|
| 826 |
}
|
| 827 |
+
if BLABLADOR_API_KEY:
|
| 828 |
+
headers["Authorization"] = f"Bearer {BLABLADOR_API_KEY}"
|
| 829 |
payload = {
|
| 830 |
"model": selected_model,
|
| 831 |
"prompt": prompt,
|
|
|
|
| 858 |
yield "<p style='color: var(--body-text-color-subdued); text-align: center; padding: 2rem;'>Please enter a question to begin.</p>"
|
| 859 |
return
|
| 860 |
|
| 861 |
+
if not BLABLADOR_API_KEY:
|
| 862 |
+
yield """<div class="error-message">
|
| 863 |
+
<p><strong>BLABLADOR_API_KEY Missing</strong></p>
|
| 864 |
+
<p>The Blablador API Key is not configured in the Space secrets. Please add it to your Space settings.</p>
|
| 865 |
+
</div>"""
|
| 866 |
+
return
|
| 867 |
+
|
| 868 |
# Load tokenizer for prompt formatting
|
| 869 |
try:
|
| 870 |
load_tokenizer()
|