Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -106,7 +106,7 @@ class GradioInterface:
|
|
| 106 |
|
| 107 |
# Define custom CSS for containers
|
| 108 |
custom_css = """
|
| 109 |
-
.
|
| 110 |
border: 2px solid var(--primary-500);
|
| 111 |
border-radius: 10px;
|
| 112 |
padding: 20px;
|
|
@@ -116,19 +116,8 @@ class GradioInterface:
|
|
| 116 |
position: relative;
|
| 117 |
}
|
| 118 |
|
| 119 |
-
.
|
| 120 |
-
content:
|
| 121 |
-
position: absolute;
|
| 122 |
-
top: -12px;
|
| 123 |
-
left: 20px;
|
| 124 |
-
background: var(--background-fill-primary);
|
| 125 |
-
padding: 0 10px;
|
| 126 |
-
color: var(--primary-500);
|
| 127 |
-
font-weight: bold;
|
| 128 |
-
}
|
| 129 |
-
|
| 130 |
-
.output-container::before {
|
| 131 |
-
content: 'Output Section';
|
| 132 |
position: absolute;
|
| 133 |
top: -12px;
|
| 134 |
left: 20px;
|
|
@@ -136,16 +125,21 @@ class GradioInterface:
|
|
| 136 |
padding: 0 10px;
|
| 137 |
color: var(--primary-500);
|
| 138 |
font-weight: bold;
|
|
|
|
| 139 |
}
|
| 140 |
"""
|
| 141 |
|
| 142 |
with gr.Blocks(css=custom_css) as self.interface:
|
| 143 |
-
|
| 144 |
-
gr.
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
# Input Container
|
| 148 |
-
with gr.Column(elem_classes="input-container"):
|
|
|
|
| 149 |
gr.Markdown("## Refine Prompt")
|
| 150 |
with gr.Row():
|
| 151 |
prompt_text = gr.Textbox(label="Type the prompt (or let it empty to see metaprompt)")
|
|
@@ -159,8 +153,9 @@ class GradioInterface:
|
|
| 159 |
)
|
| 160 |
refine_button = gr.Button("Refine Prompt")
|
| 161 |
|
| 162 |
-
#
|
| 163 |
-
with gr.Column(elem_classes="
|
|
|
|
| 164 |
with gr.Row():
|
| 165 |
gr.Markdown("### Initial prompt analysis")
|
| 166 |
with gr.Column():
|
|
@@ -179,8 +174,9 @@ class GradioInterface:
|
|
| 179 |
outputs=[analysis_evaluation, refined_prompt, explanation_of_refinements, full_response_json]
|
| 180 |
)
|
| 181 |
|
| 182 |
-
# Model Application
|
| 183 |
-
with gr.Column(elem_classes="
|
|
|
|
| 184 |
gr.Markdown("## See MetaPrompt Impact")
|
| 185 |
with gr.Row():
|
| 186 |
apply_model = gr.Dropdown(
|
|
@@ -199,7 +195,8 @@ class GradioInterface:
|
|
| 199 |
apply_button = gr.Button("Apply MetaPrompt")
|
| 200 |
|
| 201 |
# Results Container
|
| 202 |
-
with gr.Column(elem_classes="
|
|
|
|
| 203 |
with gr.Tab("Original Prompt Output"):
|
| 204 |
original_output = gr.Markdown(label="Original Prompt Output")
|
| 205 |
with gr.Tab("Refined Prompt Output"):
|
|
@@ -211,23 +208,25 @@ class GradioInterface:
|
|
| 211 |
outputs=[original_output, refined_output]
|
| 212 |
)
|
| 213 |
|
| 214 |
-
# Examples
|
| 215 |
-
with gr.
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
[
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
| 231 |
|
| 232 |
# Rest of the class methods remain the same
|
| 233 |
def refine_prompt(self, prompt: str, meta_prompt_choice: str) -> tuple:
|
|
|
|
| 106 |
|
| 107 |
# Define custom CSS for containers
|
| 108 |
custom_css = """
|
| 109 |
+
.container {
|
| 110 |
border: 2px solid var(--primary-500);
|
| 111 |
border-radius: 10px;
|
| 112 |
padding: 20px;
|
|
|
|
| 116 |
position: relative;
|
| 117 |
}
|
| 118 |
|
| 119 |
+
.container::before {
|
| 120 |
+
content: attr(data-title);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
position: absolute;
|
| 122 |
top: -12px;
|
| 123 |
left: 20px;
|
|
|
|
| 125 |
padding: 0 10px;
|
| 126 |
color: var(--primary-500);
|
| 127 |
font-weight: bold;
|
| 128 |
+
font-size: 1.2em;
|
| 129 |
}
|
| 130 |
"""
|
| 131 |
|
| 132 |
with gr.Blocks(css=custom_css) as self.interface:
|
| 133 |
+
# Title Container
|
| 134 |
+
with gr.Column(elem_classes="container", elem_id="title-container") as title_container:
|
| 135 |
+
title_container.dataset["title"] = "PROMPT++"
|
| 136 |
+
gr.Markdown("# PROMPT++")
|
| 137 |
+
gr.Markdown("### Automating Prompt Engineering by Refining your Prompts")
|
| 138 |
+
gr.Markdown("Learn how to generate an improved version of your prompts. Enter a main idea for a prompt, choose a meta prompt, and the model will attempt to generate an improved version.")
|
| 139 |
|
| 140 |
# Input Container
|
| 141 |
+
with gr.Column(elem_classes="container", elem_id="input-container") as input_container:
|
| 142 |
+
input_container.dataset["title"] = "PROMPT REFINEMENT"
|
| 143 |
gr.Markdown("## Refine Prompt")
|
| 144 |
with gr.Row():
|
| 145 |
prompt_text = gr.Textbox(label="Type the prompt (or let it empty to see metaprompt)")
|
|
|
|
| 153 |
)
|
| 154 |
refine_button = gr.Button("Refine Prompt")
|
| 155 |
|
| 156 |
+
# Analysis Container
|
| 157 |
+
with gr.Column(elem_classes="container", elem_id="analysis-container") as analysis_container:
|
| 158 |
+
analysis_container.dataset["title"] = "ANALYSIS & REFINEMENT"
|
| 159 |
with gr.Row():
|
| 160 |
gr.Markdown("### Initial prompt analysis")
|
| 161 |
with gr.Column():
|
|
|
|
| 174 |
outputs=[analysis_evaluation, refined_prompt, explanation_of_refinements, full_response_json]
|
| 175 |
)
|
| 176 |
|
| 177 |
+
# Model Application Container
|
| 178 |
+
with gr.Column(elem_classes="container", elem_id="model-container") as model_container:
|
| 179 |
+
model_container.dataset["title"] = "MODEL APPLICATION"
|
| 180 |
gr.Markdown("## See MetaPrompt Impact")
|
| 181 |
with gr.Row():
|
| 182 |
apply_model = gr.Dropdown(
|
|
|
|
| 195 |
apply_button = gr.Button("Apply MetaPrompt")
|
| 196 |
|
| 197 |
# Results Container
|
| 198 |
+
with gr.Column(elem_classes="container", elem_id="results-container") as results_container:
|
| 199 |
+
results_container.dataset["title"] = "RESULTS"
|
| 200 |
with gr.Tab("Original Prompt Output"):
|
| 201 |
original_output = gr.Markdown(label="Original Prompt Output")
|
| 202 |
with gr.Tab("Refined Prompt Output"):
|
|
|
|
| 208 |
outputs=[original_output, refined_output]
|
| 209 |
)
|
| 210 |
|
| 211 |
+
# Examples Container
|
| 212 |
+
with gr.Column(elem_classes="container", elem_id="examples-container") as examples_container:
|
| 213 |
+
examples_container.dataset["title"] = "EXAMPLES"
|
| 214 |
+
with gr.Accordion("Examples", open=True):
|
| 215 |
+
gr.Examples(
|
| 216 |
+
examples=[
|
| 217 |
+
["Write a story on the end of prompt engineering replaced by an Ai specialized in refining prompts.", "star"],
|
| 218 |
+
["Tell me about that guy who invented the light bulb", "physics"],
|
| 219 |
+
["Explain the universe.", "star"],
|
| 220 |
+
["What's the population of New York City and how tall is the Empire State Building and who was the first mayor?", "morphosis"],
|
| 221 |
+
["List American presidents.", "verse"],
|
| 222 |
+
["Explain why the experiment failed.", "morphosis"],
|
| 223 |
+
["Is nuclear energy good?", "verse"],
|
| 224 |
+
["How does a computer work?", "phor"],
|
| 225 |
+
["How to make money fast?", "done"],
|
| 226 |
+
["how can you prove IT0's lemma in stochastic calculus ?", "arpe"],
|
| 227 |
+
],
|
| 228 |
+
inputs=[prompt_text, meta_prompt_choice]
|
| 229 |
+
)
|
| 230 |
|
| 231 |
# Rest of the class methods remain the same
|
| 232 |
def refine_prompt(self, prompt: str, meta_prompt_choice: str) -> tuple:
|