rdlf commited on
Commit
d6e21ad
verified
1 Parent(s): de4e953

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -25
app.py CHANGED
@@ -3,22 +3,16 @@ from PIL import Image
3
  from groq import Groq
4
  import os
5
 
6
-
7
- #st.image('calamo.png', caption="", use_column_width=False)
8
-
9
  client = Groq(
10
  api_key=os.environ.get("GROQ_API_KEY"),
11
  )
12
- # Rest of your Streamlit app
13
- st.write("# Inicio")
14
 
15
- # Other content of your app
16
- #st.title("plAIn")
17
- # Add more components here
18
- # Create a text input widget
19
- user_input = st.text_input('Pega tu texto:', '')
20
 
21
- # Define a function to process the input
22
  def process_text(input_text):
23
  prompt = '''
24
  Eres un experto en lenguaje claro. Las pautas b谩sicas para lenguaje claro son:
@@ -27,23 +21,36 @@ def process_text(input_text):
27
  - Evitar la jerga.
28
  - Seguir el orden sujeto, verbo y predicado.
29
  - Utilizar una estructura l贸gica, organizando la informaci贸n de manera clara y coherente.
30
- Eval煤a la calidad del lenguaje de este texto y sugiere las correcciones oportunas:"
 
 
 
 
 
 
 
31
  '''
32
  input = prompt + input_text
33
 
34
  chat_completion = client.chat.completions.create(
35
- messages=[
36
- {
37
- "role": "user",
38
- "content": input,
39
- }
40
- ],
41
- model="mixtral-8x7b-32768",
42
- )
43
- return (chat_completion.choices[0].message.content)
 
 
 
44
 
45
- # Call the function with the user input
46
- processed_output = process_text(user_input)
47
 
48
- # Display the processed output
49
- st.write('Texto procesado:', processed_output)
 
 
 
 
3
  from groq import Groq
4
  import os
5
 
6
+ # Initialize the Groq client
 
 
7
  client = Groq(
8
  api_key=os.environ.get("GROQ_API_KEY"),
9
  )
 
 
10
 
11
+ # Function to clear the input field
12
+ def clear_input():
13
+ st.session_state["user_input"] = ""
 
 
14
 
15
+ # Function to process the input text
16
  def process_text(input_text):
17
  prompt = '''
18
  Eres un experto en lenguaje claro. Las pautas b谩sicas para lenguaje claro son:
 
21
  - Evitar la jerga.
22
  - Seguir el orden sujeto, verbo y predicado.
23
  - Utilizar una estructura l贸gica, organizando la informaci贸n de manera clara y coherente.
24
+ 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, con el siguiente lenguaje de marcado:
25
+
26
+ ###TEXTO CORREGIDO###
27
+
28
+
29
+ ###EXPLICACI脫N###
30
+
31
+ "
32
  '''
33
  input = prompt + input_text
34
 
35
  chat_completion = client.chat.completions.create(
36
+ messages=[
37
+ {
38
+ "role": "user",
39
+ "content": input,
40
+ }
41
+ ],
42
+ model="mixtral-8x7b-32768",
43
+ )
44
+ return chat_completion.choices[0].message.content
45
+
46
+ # Main app
47
+ st.write("# Inicio")
48
 
49
+ # Create a text input widget with session state
50
+ user_input = st.text_input('Pega tu texto:', '', key="user_input")
51
 
52
+ # Create a button to submit the input
53
+ if st.button("Submit"):
54
+ processed_output = process_text(user_input)
55
+ st.write('Texto procesado:', processed_output)
56
+ clear_input() # Clear the input field after processing