baconnier commited on
Commit
1e43057
1 Parent(s): f02ff3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +90 -0
app.py CHANGED
@@ -199,6 +199,96 @@ Only provide the output in the following JSON format enclosed in <json> tags:
199
  }
200
  </json>
201
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  # Define the metaprompts
203
  metaprompt1 = """
204
  As an AI Prompt Enhancement Specialist, your task is to improve the given prompt using advanced prompting techniques while emphasizing the use of previously generated context. Analyze the input prompt and apply the following steps to enhance it:
 
199
  }
200
  </json>
201
  """
202
+
203
+ echo_prompt_refiner = '''You are an AI assistant implementing the ECHO (Self-Harmonized Chain of Thought) method to refine an initial prompt into a more relevant and comprehensive one. Given an initial prompt, follow these steps:
204
+
205
+ 1. Prompt Analysis:
206
+ - Analyze the initial prompt
207
+ - Identify key concepts, objectives, and constraints within the prompt
208
+ - Determine the prompt type (e.g., task-oriented, creative, analytical)
209
+
210
+ 2. Prompt Expansion:
211
+ - Generate 5-7 alternative versions of the prompt that explore different aspects or phrasings
212
+ - Ensure these versions cover various perspectives and potential interpretations
213
+ - Include a mix of more specific, more general, and differently focused versions
214
+
215
+ 3. Prompt Clustering:
216
+ - Group the generated prompts into 2-3 thematic clusters
217
+ - Identify the core themes or objectives represented by each cluster
218
+
219
+ 4. Demonstration Generation:
220
+ - For each cluster, outline how an AI might interpret and approach that prompt version
221
+ - Include potential reasoning steps and areas of focus, without generating actual responses
222
+
223
+ 5. Prompt Refinement:
224
+ - Review the demonstration outlines and identify strengths and weaknesses of each prompt version
225
+ - Refine each version, addressing potential misinterpretations and improving clarity
226
+ - Ensure each refined version maintains the original intent while enhancing specificity or broadening scope as needed
227
+
228
+ 6. Cross-Pollination:
229
+ - Identify effective elements from each refined version
230
+ - Integrate these elements to create a synthesized, improved prompt
231
+
232
+ 7. Final Prompt Synthesis:
233
+ - Combine the most effective elements from all refined versions
234
+ - Construct a final, comprehensive prompt that captures the essence of the original while incorporating improvements
235
+
236
+ Ensure each step of your process is thorough and well-documented in the JSON output. Your final refined prompt should be clear, comprehensive, and effectively capture the intent of the initial prompt while addressing any identified shortcomings.
237
+
238
+ Initial prompt: {insert_prompt_here}
239
+
240
+ Please provide your response in the following JSON format, enclosed in <json> tags:
241
+
242
+ <json>
243
+ {
244
+ "initial_prompt": "The original prompt provided",
245
+ "initial_prompt_evaluation": "Your evaluation of the initial prompt with Strengths and Weaknesses in a string as bullet points format",
246
+ "prompt_analysis": {
247
+ "key_concepts": ["concept1", "concept2", "concept3", "..."],
248
+ "objectives": "String describing the objectives",
249
+ "constraints": "String describing any constraints",
250
+ "prompt_type": "Type of prompt (e.g., task-oriented, creative, analytical)"
251
+ },
252
+ "expanded_prompts": [
253
+ "First alternative prompt version",
254
+ "Second alternative prompt version",
255
+ "...",
256
+ "Last alternative prompt version"
257
+ ],
258
+ "prompt_clusters": {
259
+ "cluster1_name": [
260
+ "First prompt in this cluster",
261
+ "Second prompt in this cluster",
262
+ "..."
263
+ ],
264
+ "cluster2_name": [
265
+ "First prompt in this cluster",
266
+ "Second prompt in this cluster",
267
+ "..."
268
+ ],
269
+ "...": "Additional clusters if needed"
270
+ },
271
+ "demonstration_outlines": {
272
+ "cluster1_name": "Approach outline for this cluster",
273
+ "cluster2_name": "Approach outline for this cluster",
274
+ "...": "Additional outlines if needed"
275
+ },
276
+ "refined_prompts": [
277
+ "First refined prompt version",
278
+ "Second refined prompt version",
279
+ "...",
280
+ "Last refined prompt version"
281
+ ],
282
+ "refined_prompt": "Your refined prompt",
283
+ "final_refined_prompt": "The final, synthesized prompt as a single string",
284
+ "improvement_rationale": "Explanation of how the final prompt improves upon the initial one",
285
+ "potential_limitations": "Any potential limitations or considerations for the refined prompt",
286
+ "explanation_of_refinements": "Detailed explanation of techniques used and improvements made, including the extract of final prompt where it used. Answer in a string"
287
+ }
288
+ </json>
289
+ '''
290
+
291
+
292
  # Define the metaprompts
293
  metaprompt1 = """
294
  As an AI Prompt Enhancement Specialist, your task is to improve the given prompt using advanced prompting techniques while emphasizing the use of previously generated context. Analyze the input prompt and apply the following steps to enhance it: