Spaces:
Running
Running
File size: 3,311 Bytes
cb069fa d39daa5 cb069fa d39daa5 35f1887 d39daa5 8259245 d39daa5 cb069fa d39daa5 cb069fa d39daa5 4923001 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
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}))
|