File size: 1,687 Bytes
b9e397f d4caf59 09780df 1bc78de 09780df d6e21ad 09780df b9e397f d6e21ad b9e397f 89b131b 7fa9c40 3cba556 49b5707 3cba556 7fa9c40 49b5707 3cba556 89b131b 48959bc 09780df d6e21ad 79c30fa d6e21ad b9e397f d6e21ad e64be28 b9e397f d6e21ad 12bce35 d6e21ad 7fa9c40 e64be28 |
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 |
import streamlit as st
from PIL import Image
from groq import Groq
import os
# Initialize the Groq client
client = Groq(
api_key=os.environ.get("GROQ_API_KEY"),
)
# Function to process the input text
def process_text(input_text):
prompt = '''
Eres un experto en lenguaje claro. Las pautas b谩sicas para lenguaje claro son:
- Expresar una idea por oraci贸n.
- Utilizar oraciones de treinta palabras o menos.
- Evitar la jerga.
- Seguir el orden sujeto, verbo y predicado.
- Utilizar una estructura l贸gica, organizando la informaci贸n de manera clara y coherente.
Eval煤a la calidad del lenguaje de este texto y sugiere las correcciones oportunas.
Muestra siempre primero el texto corregido y a continuaci贸n las explicaciones, utilizando el siguiente lenguaje de marcado:
###TEXTO CORREGIDO###
###EXPLICACI脫N###
"
'''
input = prompt + input_text
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": input,
}
],
model="llama-3.3-70b-versatile",
)
return chat_completion.choices[0].message.content
# Main app
st.write("# Inicio")
# Create a text input widget with session state
if "user_input" not in st.session_state:
st.session_state["user_input"] = ""
user_input = st.text_input('Pega tu texto:', st.session_state["user_input"])
# Create a button to submit the input
if st.button("Enviar"):
processed_output = process_text(user_input)
st.write('Aqu铆 est谩 el texto corregido:\n', processed_output)
st.session_state["user_input"] = "" # Clear the input field after processing
|