Spaces:
Build error
Build error
Create app.yp
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
token = os.getenv("TokenForRepos")
|
| 6 |
+
login(token)
|
| 7 |
+
|
| 8 |
+
# Autenticaci贸n en Hugging Face si es necesario
|
| 9 |
+
os.environ["HUGGINGFACEHUB_API_TOKEN"] = token
|
| 10 |
+
|
| 11 |
+
# Configurar el generador de texto usando LLaMA 3.2
|
| 12 |
+
generator = pipeline("text-generation", model="meta-llama/Llama-3.2-1B")
|
| 13 |
+
|
| 14 |
+
# T铆tulo de la app en Streamlit
|
| 15 |
+
st.title("Generador de Texto con LLaMA 3.2")
|
| 16 |
+
|
| 17 |
+
# Cuadro de texto para que el usuario escriba el prompt
|
| 18 |
+
prompt = st.text_input("Escribe tu prompt", "Hola, 驴c贸mo est谩s?")
|
| 19 |
+
|
| 20 |
+
# Bot贸n para generar el texto
|
| 21 |
+
if st.button("Generar texto"):
|
| 22 |
+
result = generator(prompt, max_length=100, num_return_sequences=1)
|
| 23 |
+
st.write("Texto generado:")
|
| 24 |
+
st.write(result[0]["generated_text"])
|