import streamlit as st from transformers import pipeline import os from huggingface_hub import login token = os.getenv("TokenForRepos") login(token) # Autenticación en Hugging Face si es necesario os.environ["HUGGINGFACEHUB_API_TOKEN"] = token st.write("Inicializando") # Configurar el generador de texto usando LLaMA 3.2 generator = pipeline("text-generation", model="meta-llama/Llama-3.2-1B-Instruct") # Título de la app en Streamlit st.title("Generador de Texto con LLaMA 3.2") # Título exercise 1 st.title("Exercise 1") #text of exercise 1 text = f"""El sistema CRISPR-Cas9 permite una edición precisa del genoma mediante la creación de rupturas de doble cadena en ubicaciones específicas del ADN, lo que facilita modificaciones genéticas específicas.""" #prompt prompt_1 = f""" Perform the following actions: 1 - Rewrite the text, which is in medical technical terms, into simple words so that anyone who doesn't know much about medicine can understand it while maintaining the accuracy of the information. 2 - Identify the main theme of the text. 3 - Determine the tone in which the text is written. 4 - Translate text to English, Arabic and French maintaining the accuracy of the information. 5 - Output a json object that contains the following keys: id, main_text, tone, lenguage, text. Separate your answers with line breaks. Text: ```{text}``` Show me only the json output that I'm asking you for in the last point """ #""" #promp = f""" #Translate text to English, Arabic and French delimited by triple backticks. #Text : ```{text}``` #""" #""" # Cuadro de texto para que el usuario escriba el prompt #prompt = st.text_input("Escribe tu prompt", "Hola, ¿cómo estás?") prompt = st.text_input("Escribe tu prompt", prompt_1) # Botón para generar el texto exercise 1 if st.button("Generar texto"): result = generator(prompt, max_length=400, num_return_sequences=1) st.write("Texto generado:") st.write(result[0]["generated_text"]) ###----------------------------### # Título exercise 2 st.title("Exercise 2") #text of exercise 1 text = f"""Un experimento reciente observó que los ratones expuestos a una dieta rica en grasas mostraron niveles aumentados de una bacteria intestinal específica, que está vinculada a trastornos metabólicos""" #exercise 2 prompt_2 = f""" Perform the following actions: 1 - From limited data from a scientific study, infer potential conclusions. 2 - Suggest areas for future research. 3 - Each conclusion should be in English as if explaining to a 10-year-old. Separate your answers with line breaks. Text: ```{text}``` """ # Cuadro de texto para que el usuario escriba el prompt #prompt = st.text_input("Escribe tu prompt", "Hola, ¿cómo estás?") prompt2 = st.text_input("Escribe tu prompt", prompt_2) # Botón para generar el texto exercise 2 if st.button("Generar texto2"): result = generator(prompt2, max_length=400, num_return_sequences=1) st.write("Texto generado:") st.write(result[0]["generated_text"])