prompt-plus-plus / variables.py
baconnier's picture
Update variables.py
d626111 verified
raw
history blame
3.1 kB
import json
import os
# Load templates from environment variable with a safe default
templates_json = os.getenv('PROMPT_TEMPLATES', '{}')
try:
# Parse JSON data with error handling
prompt_data = json.loads(templates_json)
except json.JSONDecodeError:
# Fallback to empty dict if JSON is invalid
prompt_data = {}
#print(prompt_data)
# Create explanations dictionary with safe access
metaprompt_explanations = {
key: data.get("description", "No description available")
for key, data in prompt_data.items()
} if prompt_data else {}
# Generate markdown explanation
explanation_markdown = "".join([
f"- **{key}**: {value}\n"
for key, value in metaprompt_explanations.items()
])
# Define models list
models = [
"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/zephyr-7b-beta",
"HuggingFaceH4/zephyr-7b-alpha",
"Qwen/Qwen2.5-72B-Instruct",
"Qwen/Qwen2.5-1.5B",
"microsoft/Phi-3.5-mini-instruct"
]
examples=[
["Write a story on the end of prompt engineering replaced by an Ai specialized in refining prompts.", "done"],
["Tell me about that guy who invented the light bulb", "physics"],
["Explain the universe.", "star"],
["What's the population of New York City and how tall is the Empire State Building and who was the first mayor?", "morphosis"],
["List American presidents.", "verse"],
["Explain why the experiment failed.", "morphosis"],
["Is nuclear energy good?", "verse"],
["How does a computer work?", "phor"],
["How to make money fast?", "done"],
["how can you prove IT0's lemma in stochastic calculus ?", "arpe"],
]
# Get API token with error handling
api_token = os.getenv('HF_API_TOKEN')
if not api_token:
raise ValueError("HF_API_TOKEN not found in environment variables")
# Create meta_prompts dictionary with safe access
meta_prompts = {
key: data.get("template", "No template available")
for key, data in prompt_data.items()
} if prompt_data else {}
prompt_refiner_model = os.getenv('PROMPT_REFINER_MODEL', 'meta-llama/Llama-3.1-8B-Instruct')
#prompt_refiner_model = os.getenv('prompt_refiner_model')
echo_prompt_refiner = os.getenv('echo_prompt_refiner')
openai_metaprompt = os.getenv('openai_metaprompt')
advanced_meta_prompt = os.getenv('advanced_meta_prompt')
meta_prompts = {
"morphosis": os.getenv('original_meta_prompt'),
"verse": os.getenv('new_meta_prompt'),
"physics": os.getenv('metaprompt1'),
"bolism": os.getenv('loic_metaprompt') ,
"done": os.getenv('metadone'),
"star": echo_prompt_refiner,
"math": os.getenv('metamath'),
"arpe": os.getenv('autoregressive_metaprompt')
}