memoona-nz commited on
Commit
def0dca
·
verified ·
1 Parent(s): 86112aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -1,8 +1,11 @@
 
1
  import gradio as gr
2
  from google import genai
3
- import os
4
- client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
5
 
 
 
 
 
6
 
7
  # ---------------- AI CALL ----------------
8
  def ask(prompt):
@@ -11,7 +14,9 @@ def ask(prompt):
11
  model="gemini-2.5-flash",
12
  contents=prompt
13
  )
 
14
  return response.text
 
15
  except Exception as e:
16
  return f"Error: {str(e)}"
17
 
@@ -48,6 +53,9 @@ Final Answer:
48
  # ---------------- MAIN FUNCTION ----------------
49
  def run_dashboard(task):
50
 
 
 
 
51
  z = ask(zero_shot(task))
52
  f = ask(few_shot(task))
53
  c = ask(cot(task))
@@ -72,7 +80,12 @@ demo = gr.Interface(
72
  ],
73
 
74
  title="Prompt Engineering Explorer",
75
- description="Compare how different prompting styles (Zero-shot, Few-shot, Chain-of-Thought) affect AI-generated responses.",
 
 
 
 
 
76
 
77
  theme=gr.themes.Soft(
78
  primary_hue="cyan",
 
1
+ import os
2
  import gradio as gr
3
  from google import genai
 
 
4
 
5
+ # Secure API key from Hugging Face Secrets
6
+ client = genai.Client(
7
+ api_key=os.getenv("GEMINI_API_KEY")
8
+ )
9
 
10
  # ---------------- AI CALL ----------------
11
  def ask(prompt):
 
14
  model="gemini-2.5-flash",
15
  contents=prompt
16
  )
17
+
18
  return response.text
19
+
20
  except Exception as e:
21
  return f"Error: {str(e)}"
22
 
 
53
  # ---------------- MAIN FUNCTION ----------------
54
  def run_dashboard(task):
55
 
56
+ if not task.strip():
57
+ return "Please enter a prompt.", "", ""
58
+
59
  z = ask(zero_shot(task))
60
  f = ask(few_shot(task))
61
  c = ask(cot(task))
 
80
  ],
81
 
82
  title="Prompt Engineering Explorer",
83
+
84
+ description="""
85
+ Compare how different prompting styles
86
+ (Zero-shot, Few-shot, Chain-of-Thought)
87
+ affect AI-generated responses.
88
+ """,
89
 
90
  theme=gr.themes.Soft(
91
  primary_hue="cyan",