Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,11 @@ import os
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
|
| 5 |
-
HF_TOKEN = os.getenv("HF_API_TOKEN")
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
HEADERS = {"Authorization": f"Bearer {HF_TOKEN}"}
|
| 8 |
|
| 9 |
def tutor_ia(mensaje, idioma, modo):
|
|
@@ -43,7 +46,6 @@ Mensaje del estudiante:
|
|
| 43 |
except Exception as e:
|
| 44 |
return f"⚠️ Error al conectar con Hugging Face: {str(e)}"
|
| 45 |
|
| 46 |
-
# Define la interfaz de Gradio
|
| 47 |
demo = gr.Interface(
|
| 48 |
fn=tutor_ia,
|
| 49 |
inputs=[
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
|
| 5 |
+
HF_TOKEN = os.getenv("HF_API_TOKEN")
|
| 6 |
+
if not HF_TOKEN:
|
| 7 |
+
raise ValueError("El token HF_API_TOKEN no está configurado en los secretos del Space.")
|
| 8 |
+
|
| 9 |
+
API_URL = "https://api-inference.huggingface.co/models/bigscience/bloomz-7b1"
|
| 10 |
HEADERS = {"Authorization": f"Bearer {HF_TOKEN}"}
|
| 11 |
|
| 12 |
def tutor_ia(mensaje, idioma, modo):
|
|
|
|
| 46 |
except Exception as e:
|
| 47 |
return f"⚠️ Error al conectar con Hugging Face: {str(e)}"
|
| 48 |
|
|
|
|
| 49 |
demo = gr.Interface(
|
| 50 |
fn=tutor_ia,
|
| 51 |
inputs=[
|