Spaces:
Runtime error
Runtime error
Update backend.py
Browse files- backend.py +7 -1
backend.py
CHANGED
|
@@ -5,6 +5,8 @@ from sentence_transformers import SentenceTransformer
|
|
| 5 |
import chromadb
|
| 6 |
from chromadb.config import Settings
|
| 7 |
from huggingface_hub import InferenceClient
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# 1. Funciones
|
| 10 |
def extraer_texto(url):
|
|
@@ -59,7 +61,11 @@ for url in urls:
|
|
| 59 |
collection.add(documents=[chunk], ids=[f"{url}_chunk_{i}"], embeddings=[emb])
|
| 60 |
|
| 61 |
# 5. Cliente LLM
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
# 6. Funci贸n para Gradio
|
| 65 |
def responder_pregunta(pregunta: str, k=3, max_chars=1500) -> str:
|
|
|
|
| 5 |
import chromadb
|
| 6 |
from chromadb.config import Settings
|
| 7 |
from huggingface_hub import InferenceClient
|
| 8 |
+
import os
|
| 9 |
+
from huggingface_hub import InferenceClient
|
| 10 |
|
| 11 |
# 1. Funciones
|
| 12 |
def extraer_texto(url):
|
|
|
|
| 61 |
collection.add(documents=[chunk], ids=[f"{url}_chunk_{i}"], embeddings=[emb])
|
| 62 |
|
| 63 |
# 5. Cliente LLM
|
| 64 |
+
hf_token = os.getenv("HF_Token")
|
| 65 |
+
client = InferenceClient(
|
| 66 |
+
"HuggingFaceH4/zephyr-7b-beta",
|
| 67 |
+
token=hf_token
|
| 68 |
+
)
|
| 69 |
|
| 70 |
# 6. Funci贸n para Gradio
|
| 71 |
def responder_pregunta(pregunta: str, k=3, max_chars=1500) -> str:
|