Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,7 +104,7 @@ class GradioInterface:
|
|
| 104 |
def __init__(self, prompt_refiner: PromptRefiner):
|
| 105 |
self.prompt_refiner = prompt_refiner
|
| 106 |
|
| 107 |
-
# Define custom CSS for containers
|
| 108 |
custom_css = """
|
| 109 |
.container {
|
| 110 |
border: 2px solid var(--primary-500);
|
|
@@ -116,32 +116,16 @@ class GradioInterface:
|
|
| 116 |
position: relative;
|
| 117 |
}
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
color: var(--primary-500);
|
| 127 |
-
font-weight: bold;
|
| 128 |
-
font-size: 1.2em;
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
.input-container::before {
|
| 132 |
-
content: 'PROMPT REFINEMENT';
|
| 133 |
-
position: absolute;
|
| 134 |
-
top: -12px;
|
| 135 |
-
left: 20px;
|
| 136 |
-
background: var(--background-fill-primary);
|
| 137 |
-
padding: 0 10px;
|
| 138 |
-
color: var(--primary-500);
|
| 139 |
-
font-weight: bold;
|
| 140 |
-
font-size: 1.2em;
|
| 141 |
-
}
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
position: absolute;
|
| 146 |
top: -12px;
|
| 147 |
left: 20px;
|
|
@@ -151,41 +135,11 @@ class GradioInterface:
|
|
| 151 |
font-weight: bold;
|
| 152 |
font-size: 1.2em;
|
| 153 |
}
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
left: 20px;
|
| 160 |
-
background: var(--background-fill-primary);
|
| 161 |
-
padding: 0 10px;
|
| 162 |
-
color: var(--primary-500);
|
| 163 |
-
font-weight: bold;
|
| 164 |
-
font-size: 1.2em;
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
-
.results-container::before {
|
| 168 |
-
content: 'RESULTS';
|
| 169 |
-
position: absolute;
|
| 170 |
-
top: -12px;
|
| 171 |
-
left: 20px;
|
| 172 |
-
background: var(--background-fill-primary);
|
| 173 |
-
padding: 0 10px;
|
| 174 |
-
color: var(--primary-500);
|
| 175 |
-
font-weight: bold;
|
| 176 |
-
font-size: 1.2em;
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
.examples-container::before {
|
| 180 |
-
content: 'EXAMPLES';
|
| 181 |
-
position: absolute;
|
| 182 |
-
top: -12px;
|
| 183 |
-
left: 20px;
|
| 184 |
-
background: var(--background-fill-primary);
|
| 185 |
-
padding: 0 10px;
|
| 186 |
-
color: var(--primary-500);
|
| 187 |
-
font-weight: bold;
|
| 188 |
-
font-size: 1.2em;
|
| 189 |
}
|
| 190 |
"""
|
| 191 |
|
|
@@ -198,7 +152,6 @@ class GradioInterface:
|
|
| 198 |
|
| 199 |
# Input Container
|
| 200 |
with gr.Column(elem_classes=["container", "input-container"]):
|
| 201 |
-
gr.Markdown("## Refine Prompt")
|
| 202 |
with gr.Row():
|
| 203 |
prompt_text = gr.Textbox(label="Type the prompt (or let it empty to see metaprompt)")
|
| 204 |
with gr.Accordion("Meta Prompt explanation", open=False):
|
|
@@ -213,24 +166,16 @@ class GradioInterface:
|
|
| 213 |
|
| 214 |
# Analysis Container
|
| 215 |
with gr.Column(elem_classes=["container", "analysis-container"]):
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
gr.Markdown("### Explanation of Refinements")
|
| 223 |
-
explanation_of_refinements = gr.Markdown(label="Explanation of Refinements")
|
| 224 |
|
| 225 |
with gr.Accordion("Full Response JSON", open=False, visible=False):
|
| 226 |
full_response_json = gr.JSON()
|
| 227 |
|
| 228 |
-
refine_button.click(
|
| 229 |
-
fn=self.refine_prompt,
|
| 230 |
-
inputs=[prompt_text, meta_prompt_choice],
|
| 231 |
-
outputs=[analysis_evaluation, refined_prompt, explanation_of_refinements, full_response_json]
|
| 232 |
-
)
|
| 233 |
-
|
| 234 |
# Model Application Container
|
| 235 |
with gr.Column(elem_classes=["container", "model-container"]):
|
| 236 |
gr.Markdown("## See MetaPrompt Impact")
|
|
@@ -253,15 +198,9 @@ class GradioInterface:
|
|
| 253 |
# Results Container
|
| 254 |
with gr.Column(elem_classes=["container", "results-container"]):
|
| 255 |
with gr.Tab("Original Prompt Output"):
|
| 256 |
-
original_output = gr.Markdown(
|
| 257 |
with gr.Tab("Refined Prompt Output"):
|
| 258 |
-
refined_output = gr.Markdown(
|
| 259 |
-
|
| 260 |
-
apply_button.click(
|
| 261 |
-
fn=self.apply_prompts,
|
| 262 |
-
inputs=[prompt_text, refined_prompt, apply_model],
|
| 263 |
-
outputs=[original_output, refined_output]
|
| 264 |
-
)
|
| 265 |
|
| 266 |
# Examples Container
|
| 267 |
with gr.Column(elem_classes=["container", "examples-container"]):
|
|
@@ -282,9 +221,6 @@ class GradioInterface:
|
|
| 282 |
inputs=[prompt_text, meta_prompt_choice]
|
| 283 |
)
|
| 284 |
|
| 285 |
-
# Rest of the class methods remain the same...
|
| 286 |
-
|
| 287 |
-
# Rest of the class methods remain the same
|
| 288 |
def refine_prompt(self, prompt: str, meta_prompt_choice: str) -> tuple:
|
| 289 |
input_data = PromptInput(text=prompt, meta_prompt_choice=meta_prompt_choice)
|
| 290 |
result = self.prompt_refiner.refine_prompt(input_data)
|
|
|
|
| 104 |
def __init__(self, prompt_refiner: PromptRefiner):
|
| 105 |
self.prompt_refiner = prompt_refiner
|
| 106 |
|
| 107 |
+
# Define custom CSS for containers and to override input styling
|
| 108 |
custom_css = """
|
| 109 |
.container {
|
| 110 |
border: 2px solid var(--primary-500);
|
|
|
|
| 116 |
position: relative;
|
| 117 |
}
|
| 118 |
|
| 119 |
+
/* Add container titles */
|
| 120 |
+
.title-container::before { content: 'PROMPT++'; }
|
| 121 |
+
.input-container::before { content: 'PROMPT REFINEMENT'; }
|
| 122 |
+
.analysis-container::before { content: 'ANALYSIS & REFINEMENT'; }
|
| 123 |
+
.model-container::before { content: 'MODEL APPLICATION'; }
|
| 124 |
+
.results-container::before { content: 'RESULTS'; }
|
| 125 |
+
.examples-container::before { content: 'EXAMPLES'; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
+
/* Style for container titles */
|
| 128 |
+
.container::before {
|
| 129 |
position: absolute;
|
| 130 |
top: -12px;
|
| 131 |
left: 20px;
|
|
|
|
| 135 |
font-weight: bold;
|
| 136 |
font-size: 1.2em;
|
| 137 |
}
|
| 138 |
+
|
| 139 |
+
/* Override input styling for output elements */
|
| 140 |
+
.output-text {
|
| 141 |
+
border: none !important;
|
| 142 |
+
background: transparent !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
}
|
| 144 |
"""
|
| 145 |
|
|
|
|
| 152 |
|
| 153 |
# Input Container
|
| 154 |
with gr.Column(elem_classes=["container", "input-container"]):
|
|
|
|
| 155 |
with gr.Row():
|
| 156 |
prompt_text = gr.Textbox(label="Type the prompt (or let it empty to see metaprompt)")
|
| 157 |
with gr.Accordion("Meta Prompt explanation", open=False):
|
|
|
|
| 166 |
|
| 167 |
# Analysis Container
|
| 168 |
with gr.Column(elem_classes=["container", "analysis-container"]):
|
| 169 |
+
gr.Markdown("### Initial prompt analysis")
|
| 170 |
+
analysis_evaluation = gr.Markdown() # Removed label
|
| 171 |
+
gr.Markdown("### Refined Prompt")
|
| 172 |
+
refined_prompt = gr.Textbox(interactive=False, elem_classes="output-text") # Added elem_classes
|
| 173 |
+
gr.Markdown("### Explanation of Refinements")
|
| 174 |
+
explanation_of_refinements = gr.Markdown() # Removed label
|
|
|
|
|
|
|
| 175 |
|
| 176 |
with gr.Accordion("Full Response JSON", open=False, visible=False):
|
| 177 |
full_response_json = gr.JSON()
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
# Model Application Container
|
| 180 |
with gr.Column(elem_classes=["container", "model-container"]):
|
| 181 |
gr.Markdown("## See MetaPrompt Impact")
|
|
|
|
| 198 |
# Results Container
|
| 199 |
with gr.Column(elem_classes=["container", "results-container"]):
|
| 200 |
with gr.Tab("Original Prompt Output"):
|
| 201 |
+
original_output = gr.Markdown() # Removed label
|
| 202 |
with gr.Tab("Refined Prompt Output"):
|
| 203 |
+
refined_output = gr.Markdown() # Removed label
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
# Examples Container
|
| 206 |
with gr.Column(elem_classes=["container", "examples-container"]):
|
|
|
|
| 221 |
inputs=[prompt_text, meta_prompt_choice]
|
| 222 |
)
|
| 223 |
|
|
|
|
|
|
|
|
|
|
| 224 |
def refine_prompt(self, prompt: str, meta_prompt_choice: str) -> tuple:
|
| 225 |
input_data = PromptInput(text=prompt, meta_prompt_choice=meta_prompt_choice)
|
| 226 |
result = self.prompt_refiner.refine_prompt(input_data)
|