Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,19 @@
|
|
| 1 |
-
from
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
while True:
|
| 6 |
pregunta = input("Tú: ")
|
| 7 |
if pregunta.lower() in ["salir", "exit"]:
|
| 8 |
break
|
| 9 |
|
| 10 |
-
respuesta =
|
| 11 |
-
|
| 12 |
-
messages=[{"role": "user", "content": pregunta}]
|
| 13 |
-
)
|
| 14 |
-
|
| 15 |
-
print("IA:", respuesta.choices[0].message.content)
|
| 16 |
-
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
|
| 3 |
+
# Cargar un modelo de texto de Hugging Face (gratuito)
|
| 4 |
+
# Puedes cambiar "mistralai/Mistral-7B-Instruct-v0.2" por otro modelo más rápido si quieres
|
| 5 |
+
chatbot = pipeline(
|
| 6 |
+
"text-generation",
|
| 7 |
+
model="mistralai/Mistral-7B-Instruct-v0.2",
|
| 8 |
+
device_map="auto"
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
print("IA lista. Escribe 'salir' para terminar.")
|
| 12 |
|
| 13 |
while True:
|
| 14 |
pregunta = input("Tú: ")
|
| 15 |
if pregunta.lower() in ["salir", "exit"]:
|
| 16 |
break
|
| 17 |
|
| 18 |
+
respuesta = chatbot(pregunta, max_length=200, do_sample=True, temperature=0.7)
|
| 19 |
+
print("IA:", respuesta[0]["generated_text"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|