prompt-lab / app.py
hruday96's picture
Update app.py
d39daa5 verified
raw
history blame
3.31 kB
import streamlit as st
import google.generativeai as genai
# πŸ”‘ Load API Key from Streamlit Secrets
GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]
genai.configure(api_key=GOOGLE_API_KEY)
# 🎨 Streamlit UI Setup
st.title("⚑ PromptLab – AI-Powered Prompt Enhancer")
st.write("Enhance your prompts with **Shinobi** (Structured) or **Raikage** (Execution-Focused)")
# 🎭 Mode Selection
mode = st.radio("Select Mode:", ["πŸŒ€ Shinobi", "⚑ Raikage"], horizontal=True)
# ✍️ User Input for Prompt
user_prompt = st.text_area("Enter your prompt:")
# πŸš€ Generate Enhanced Prompt
if st.button("Enhance Prompt"):
if not user_prompt.strip():
st.warning("⚠️ Please enter a prompt before enhancing.")
else:
with st.spinner("Enhancing your prompt... ⚑"):
# πŸ› οΈ Apply Shinobi or Raikage Framework
if mode == "πŸŒ€ Shinobi":
structured_prompt = f"""
You are an advanced prompt enhancer, specializing in creating structured, high-clarity prompts that optimize LLM performance.
Your task is to refine a given prompt using the **Shinobi framework**, ensuring:
βœ… **Concise & High-Density Prompting** β†’ Remove fluff, keeping instructions clear and actionable.
βœ… **Explicit Role Definition** β†’ Assign a role to the AI for better contextual grounding.
βœ… **Step-by-Step Clarity** β†’ Break the task into structured sections.
βœ… **Defined Output Format** β†’ Specify the response format.
### **Enhance the following prompt using Shinobi principles:**
**Original Prompt:**
{user_prompt}
**Enhanced Shinobi Prompt:**
"""
else:
structured_prompt = f"""
You are an elite AI strategist, specializing in designing execution-focused prompts that maximize LLM efficiency.
Your task is to refine a given prompt using the **Raikage framework**, ensuring:
βœ… **Precision & Depth** β†’ Ensure expert-level guidance, reducing vagueness.
βœ… **Context & Execution Approach** β†’ Include a structured methodology.
βœ… **Defined Output Format** β†’ Specify exact structure (JSON, markdown, tables, etc.).
βœ… **Edge Case Handling & Constraints** β†’ Account for potential failures.
### **Enhance the following prompt using Raikage principles:**
**Original Prompt:**
{user_prompt}
**Enhanced Raikage Prompt:**
"""
# 🧠 Call Gemini API
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content(structured_prompt)
# πŸ“ Display Output
enhanced_prompt = response.text.strip()
st.subheader("πŸ”Ή Enhanced Prompt:")
st.code(enhanced_prompt, language="markdown")
# πŸ“‹ Copy Button
st.button("πŸ“‹ Copy to Clipboard", on_click=lambda: st.session_state.update({"copied_text": enhanced_prompt}))