Spaces:
Build error
Build error
File size: 3,014 Bytes
d895fb7 e7cc722 d895fb7 e7cc722 d895fb7 99de2f4 d895fb7 35375aa d895fb7 266c675 dd6e51b 36306c8 d624538 266c675 d624538 266c675 d624538 e629181 d624538 2f12c4d 6f9c4d9 36306c8 6f9c4d9 2f12c4d 36306c8 d895fb7 36306c8 734da0f d895fb7 dd6e51b d895fb7 030bf78 d895fb7 cd24407 dd6e51b c520a24 dd6e51b cd24407 dd6e51b 0ce5327 dd6e51b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
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"]) |