Spaces:
Running
Running
import json | |
import os | |
metaprompt_explanations = { | |
"star": "Use ECHO when you need a comprehensive, multi-stage approach for complex prompts. It's ideal for tasks requiring in-depth analysis, exploration of multiple alternatives, and synthesis of ideas. Choose this over others when you have time for a thorough refinement process and need to consider various aspects of the prompt.", | |
"done": "Opt for this when you want a structured approach with emphasis on role-playing and advanced techniques. It's particularly useful for tasks that benefit from diverse perspectives and complex reasoning. Prefer this over 'physics' when you need a more detailed, step-by-step refinement process.", | |
"physics": "Select this when you need a balance between structure and advanced techniques, with a focus on role-playing. It's similar to 'done' but may be more suitable for scientific or technical prompts. Choose this over 'done' for a slightly less complex approach.", | |
"morphosis": "Use this simplified approach for straightforward prompts or when time is limited. It focuses on essential improvements without complex techniques. Prefer this over other methods when you need quick, clear refinements without extensive analysis.", | |
"verse": "Choose this method when you need to analyze and improve a prompt's strengths and weaknesses, with a focus on information flow. It's particularly useful for enhancing the logical structure of prompts. Use this over 'morphosis' when you need more depth but less complexity than 'star'.", | |
"phor": "Employ this advanced approach when you need to combine multiple prompt engineering techniques. It's ideal for complex tasks requiring both clarity and sophisticated prompting methods. Select this over 'star' when you want a more flexible, technique-focused approach.", | |
"bolism": "Utilize this method when working with autoregressive language models and when the task requires careful reasoning before conclusions. It's best for prompts that need detailed output formatting. Choose this over others when the prompt's structure and reasoning order are crucial." | |
} | |
# Load JSON data from environment variable | |
PROMPT_DATA = json.loads(os.getenv('PROMPT_TEMPLATES', '[]')) | |
# Create metaprompt_explanations dictionary from JSON data | |
metaprompt_explanations = { | |
prompt["name"].lower().split()[0]: prompt["description"] | |
for prompt in PROMPT_DATA | |
} | |
models = [ | |
# Meta-Llama models (all support system) | |
"meta-llama/Meta-Llama-3-70B-Instruct", | |
"meta-llama/Meta-Llama-3-8B-Instruct", | |
"meta-llama/Llama-3.1-70B-Instruct", | |
"meta-llama/Llama-3.1-8B-Instruct", | |
"meta-llama/Llama-3.2-3B-Instruct", | |
"meta-llama/Llama-3.2-1B-Instruct", | |
"meta-llama/Llama-2-13b-chat-hf", | |
"meta-llama/Llama-2-7b-chat-hf", | |
# HuggingFaceH4 models (support system) | |
"HuggingFaceH4/zephyr-7b-beta", | |
"HuggingFaceH4/zephyr-7b-alpha", | |
# Qwen models (support system) | |
"Qwen/Qwen2.5-72B-Instruct", | |
"Qwen/Qwen2.5-1.5B", | |
"microsoft/Phi-3.5-mini-instruct" | |
] | |
explanation_markdown = "".join([f"- **{key}**: {value}\n" for key, value in metaprompt_explanations.items()]) | |
# Generate explanation markdown from JSON data | |
explanation_markdown = "".join([ | |
f"- **{prompt['name'].lower().split()[0]}**: {prompt['description']}\n" | |
for prompt in PROMPT_DATA | |
]) | |
meta_info="" | |
api_token = os.getenv('HF_API_TOKEN') | |
if not api_token: | |
raise ValueError("HF_API_TOKEN not found in environment variables") | |
# Store templates in a dictionary | |
meta_prompts = { | |
prompt["name"].lower().split()[0]: prompt["template"] | |
for prompt in PROMPT_DATA | |
} | |
metadone = os.getenv('metadone') | |
prompt_refiner_model = os.getenv('prompt_refiner_model') | |
echo_prompt_refiner = os.getenv('echo_prompt_refiner') | |
metaprompt1 = os.getenv('metaprompt1') | |
loic_metaprompt = os.getenv('loic_metaprompt') | |
openai_metaprompt = os.getenv('openai_metaprompt') | |
original_meta_prompt = os.getenv('original_meta_prompt') | |
new_meta_prompt = os.getenv('new_meta_prompt') | |
advanced_meta_prompt = os.getenv('advanced_meta_prompt') | |
math_meta_prompt = os.getenv('metamath') | |
autoregressive_metaprompt = os.getenv('autoregressive_metaprompt') |