Spaces:
Running
Running
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})) | |