hruday96 commited on
Commit
d39daa5
Β·
verified Β·
1 Parent(s): 4923001

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -13
app.py CHANGED
@@ -1,23 +1,72 @@
1
  import streamlit as st
2
  import google.generativeai as genai
3
 
4
- # Streamlit app layout
5
- st.title('PromptLab')
 
6
 
7
- # Create two columns for the Shinobi and Raikage buttons
8
- col1, col2 = st.columns(2)
 
9
 
10
- mode = st.radio("Choose a mode:", ["Shinobi", "Raikage"], horizontal=True)
 
11
 
12
- # Retrieve the API key from Streamlit secrets
13
- GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]
14
 
15
- # Configure the Google Generative AI API with your API key
16
- genai.configure(api_key=GOOGLE_API_KEY)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- # Input field for the blog topic
19
- topic = st.text_area('Enter your prompt:')
20
 
21
- # Display selected mode
22
- st.write(f"You selected: {mode}")
23
 
 
1
  import streamlit as st
2
  import google.generativeai as genai
3
 
4
+ # πŸ”‘ Load API Key from Streamlit Secrets
5
+ GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]
6
+ genai.configure(api_key=GOOGLE_API_KEY)
7
 
8
+ # 🎨 Streamlit UI Setup
9
+ st.title("⚑ PromptLab – AI-Powered Prompt Enhancer")
10
+ st.write("Enhance your prompts with **Shinobi** (Structured) or **Raikage** (Execution-Focused)")
11
 
12
+ # 🎭 Mode Selection
13
+ mode = st.radio("Select Mode:", ["πŸŒ€ Shinobi", "⚑ Raikage"], horizontal=True)
14
 
15
+ # ✍️ User Input for Prompt
16
+ user_prompt = st.text_area("Enter your prompt:")
17
 
18
+ # πŸš€ Generate Enhanced Prompt
19
+ if st.button("Enhance Prompt"):
20
+ if not user_prompt.strip():
21
+ st.warning("⚠️ Please enter a prompt before enhancing.")
22
+ else:
23
+ with st.spinner("Enhancing your prompt... ⚑"):
24
+ # πŸ› οΈ Apply Shinobi or Raikage Framework
25
+ if mode == "πŸŒ€ Shinobi":
26
+ structured_prompt = f"""
27
+ You are an advanced prompt enhancer, specializing in creating structured, high-clarity prompts that optimize LLM performance.
28
+ Your task is to refine a given prompt using the **Shinobi framework**, ensuring:
29
+
30
+ βœ… **Concise & High-Density Prompting** β†’ Remove fluff, keeping instructions clear and actionable.
31
+ βœ… **Explicit Role Definition** β†’ Assign a role to the AI for better contextual grounding.
32
+ βœ… **Step-by-Step Clarity** β†’ Break the task into structured sections.
33
+ βœ… **Defined Output Format** β†’ Specify the response format.
34
+
35
+ ### **Enhance the following prompt using Shinobi principles:**
36
+
37
+ **Original Prompt:**
38
+ {user_prompt}
39
+
40
+ **Enhanced Shinobi Prompt:**
41
+ """
42
+ else:
43
+ structured_prompt = f"""
44
+ You are an elite AI strategist, specializing in designing execution-focused prompts that maximize LLM efficiency.
45
+ Your task is to refine a given prompt using the **Raikage framework**, ensuring:
46
+
47
+ βœ… **Precision & Depth** β†’ Ensure expert-level guidance, reducing vagueness.
48
+ βœ… **Context & Execution Approach** β†’ Include a structured methodology.
49
+ βœ… **Defined Output Format** β†’ Specify exact structure (JSON, markdown, tables, etc.).
50
+ βœ… **Edge Case Handling & Constraints** β†’ Account for potential failures.
51
+
52
+ ### **Enhance the following prompt using Raikage principles:**
53
+
54
+ **Original Prompt:**
55
+ {user_prompt}
56
+
57
+ **Enhanced Raikage Prompt:**
58
+ """
59
+
60
+ # 🧠 Call Gemini API
61
+ model = genai.GenerativeModel('gemini-pro')
62
+ response = model.generate_content(structured_prompt)
63
+
64
+ # πŸ“ Display Output
65
+ enhanced_prompt = response.text.strip()
66
+ st.subheader("πŸ”Ή Enhanced Prompt:")
67
+ st.code(enhanced_prompt, language="markdown")
68
 
69
+ # πŸ“‹ Copy Button
70
+ st.button("πŸ“‹ Copy to Clipboard", on_click=lambda: st.session_state.update({"copied_text": enhanced_prompt}))
71
 
 
 
72