miguelcastroe commited on
Commit
351433f
verified
1 Parent(s): 1ab2322

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +169 -1
app.py CHANGED
@@ -37,4 +37,172 @@ def evaluar_prompt(prompt):
37
 
38
  # Check clarity
39
  if len(prompt.split()) < 5:
40
- feedback += "- Claridad: El prompt es muy breve y puede
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  # Check clarity
39
  if len(prompt.split()) < 5:
40
+ feedback += "- Claridad: El prompt es muy breve y puede no ser claro.\n"
41
+ claridad = 40
42
+ else:
43
+ feedback += "- Claridad: El prompt es claro.\n"
44
+ claridad = 80
45
+
46
+ # Check logic
47
+ if any(word in prompt.lower() for word in ["mejor", "peor", "煤nico"]):
48
+ feedback += "- L贸gica: El prompt contiene t茅rminos subjetivos que podr铆an sesgar el an谩lisis.\n"
49
+ logica = 50
50
+ else:
51
+ feedback += "- L贸gica: El prompt evita t茅rminos subjetivos, lo que mejora la l贸gica.\n"
52
+ logica = 80
53
+
54
+ # Check relevance
55
+ if "hablar" in prompt.lower() or "describe" in prompt.lower():
56
+ feedback += "- Relevancia: El prompt es relevante para una solicitud de informaci贸n.\n"
57
+ relevancia = 70
58
+ else:
59
+ feedback += "- Relevancia: La relevancia del prompt es discutible.\n"
60
+ relevancia = 50
61
+
62
+ # Check evidence request
63
+ if any(word in prompt.lower() for word in ["evidencia", "pruebas", "demuestra"]):
64
+ feedback += "- Evidencia: El prompt solicita evidencia, lo cual es positivo.\n"
65
+ evidencia = 80
66
+ else:
67
+ feedback += "- Evidencia: El prompt no solicita evidencia expl铆cita.\n"
68
+ evidencia = 50
69
+
70
+ # Evaluate depth
71
+ if len(prompt) > 50:
72
+ feedback += "- Profundidad: El prompt tiene suficiente profundidad para un an谩lisis detallado.\n"
73
+ profundidad = 70
74
+ else:
75
+ feedback += "- Profundidad: El prompt podr铆a beneficiarse de mayor profundidad.\n"
76
+ profundidad = 50
77
+
78
+ # Evaluate if it challenges assumptions
79
+ if "asume" in prompt.lower() or "supone" in prompt.lower():
80
+ feedback += "- Cuestionar Supuestos: El prompt reconoce suposiciones, lo cual es bueno.\n"
81
+ cuestionar_supuestos = 70
82
+ else:
83
+ feedback += "- Cuestionar Supuestos: El prompt podr铆a beneficiarse de un cuestionamiento de suposiciones.\n"
84
+ cuestionar_supuestos = 50
85
+
86
+ # Summarize scores and final assessment
87
+ calificacion_final = (
88
+ claridad + logica + relevancia + evidencia + profundidad + cuestionar_supuestos
89
+ ) / 6
90
+
91
+ if calificacion_final < 51:
92
+ feedback += f"Calificaci贸n final: {calificacion_final:.2f}%. El prompt necesita mejoras significativas en pensamiento cr铆tico."
93
+ else:
94
+ feedback += f"Calificaci贸n final: {calificacion_final:.2f}%. El prompt cumple con los principios de pensamiento cr铆tico."
95
+
96
+ return feedback, calificacion_final
97
+
98
+ except Exception as e:
99
+ return str(e), "Error"
100
+
101
+ # Gradio Interface with Styles and Layout Inspired by the Example Provided
102
+ def interfaz():
103
+ with gr.Blocks(css="""
104
+ body {
105
+ font-family: Arial, sans-serif;
106
+ background-color: #f4f4f4;
107
+ color: #333333;
108
+ margin: 0;
109
+ padding: 0;
110
+ }
111
+ .container {
112
+ max-width: 1200px;
113
+ margin: 0 auto;
114
+ padding: 20px;
115
+ display: flex;
116
+ flex-direction: column;
117
+ align-items: center;
118
+ }
119
+ .hero-section {
120
+ background-color: white;
121
+ text-align: center;
122
+ padding: 50px 0;
123
+ width: 100%;
124
+ }
125
+ .hero-section h1 {
126
+ font-size: 48px;
127
+ font-weight: bold;
128
+ color: #007BFF;
129
+ margin: 0;
130
+ }
131
+ .hero-section p {
132
+ font-size: 20px;
133
+ color: #666;
134
+ margin: 20px 0 0;
135
+ }
136
+ .evaluation-section {
137
+ background-color: #333333;
138
+ color: white;
139
+ padding: 50px;
140
+ width: 100%;
141
+ display: flex;
142
+ justify-content: space-between;
143
+ align-items: center;
144
+ }
145
+ .evaluation-section h2 {
146
+ font-size: 36px;
147
+ font-weight: bold;
148
+ margin-bottom: 20px;
149
+ }
150
+ .evaluation-section .left,
151
+ .evaluation-section .right {
152
+ width: 45%;
153
+ }
154
+ .evaluation-section .left p,
155
+ .evaluation-section .right p {
156
+ font-size: 16px;
157
+ line-height: 1.6;
158
+ }
159
+ .evaluation-section .right {
160
+ text-align: left;
161
+ }
162
+ .evaluation-section .button-container {
163
+ margin-top: 20px;
164
+ }
165
+ .evaluation-section .button-container .gr-button {
166
+ background-color: #007BFF;
167
+ color: white;
168
+ padding: 15px 30px;
169
+ font-size: 18px;
170
+ border: none;
171
+ cursor: pointer;
172
+ }
173
+ .evaluation-section .button-container .gr-button:hover {
174
+ background-color: #0056b3;
175
+ }
176
+ .evaluation-section .gr-textbox,
177
+ .evaluation-section .gr-number {
178
+ width: 100%;
179
+ padding: 15px;
180
+ font-size: 16px;
181
+ margin-top: 10px;
182
+ box-sizing: border-box;
183
+ }
184
+ """) as demo:
185
+ with gr.Row(elem_id="hero-section"):
186
+ gr.Markdown("<h1>Wearable Devices</h1>", elem_classes="hero-section")
187
+ gr.Markdown("<p>We are currently in the Research & Development phase. Stay tuned for more updates!</p>", elem_classes="hero-section")
188
+
189
+ with gr.Row(elem_id="evaluation-section"):
190
+ with gr.Column(elem_id="left"):
191
+ gr.Markdown("<h2>An谩lisis del Prompt</h2>", elem_classes="evaluation-section")
192
+ gr.Markdown("<p>Ingrese su prompt a continuaci贸n para recibir una evaluaci贸n detallada basada en principios de pensamiento cr铆tico.</p>", elem_classes="evaluation-section")
193
+
194
+ with gr.Column(elem_id="right"):
195
+ prompt_input = gr.Textbox(label="Escribe tu prompt aqu铆:", placeholder="Escribe tu prompt...", elem_classes="gr-textbox")
196
+ feedback_output = gr.Textbox(label="Retroalimentaci贸n:", interactive=False, elem_classes="gr-textbox")
197
+ calificacion_output = gr.Number(label="Calificaci贸n Final:", interactive=False, elem_classes="gr-number")
198
+
199
+ with gr.Row(elem_id="button-container"):
200
+ evaluar_button = gr.Button("Evaluar Prompt", elem_classes="gr-button")
201
+
202
+ evaluar_button.click(evaluar_prompt, inputs=prompt_input, outputs=[feedback_output, calificacion_output])
203
+
204
+ return demo
205
+
206
+ # Run the interface
207
+ demo = interfaz()
208
+ demo.launch()