Karley8 commited on
Commit
8351c4c
Β·
verified Β·
1 Parent(s): b1b5b72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -31
app.py CHANGED
@@ -3,34 +3,4 @@ import google.generativeai as genai
3
  import os
4
 
5
  # Load API key from environment variables
6
- GOOGLE_API_KEY = os.getenv("3859ec79f3bda0615907794345ff1f17")
7
-
8
- if not GOOGLE_API_KEY:
9
- st.error("⚠️ API key is missing. Please set it in the Hugging Face Space secrets.")
10
- st.stop()
11
-
12
- # Configure Gemini API
13
- genai.configure(api_key=GOOGLE_API_KEY)
14
-
15
- # Function to get a sarcastic response from Gemini
16
- def get_sarcastic_response(user_query):
17
- try:
18
- model = genai.GenerativeModel("gemini-2.0-pro-exp-02-05")
19
- response = model.generate_content(f"Answer the following question in a sarcastic tone:\n{user_query}")
20
- return response.text
21
- except Exception as e:
22
- return f"Oops, looks like sarcasm broke the internet! ({e})"
23
-
24
- # Streamlit UI
25
- st.title("Sarcastic AI πŸ€–πŸ’β€β™‚οΈ")
26
- st.subheader("Ask me anything, and I'll respond with my finest sarcasm.")
27
-
28
- # User Input
29
- user_query = st.text_input("Enter your query:")
30
-
31
- if user_query:
32
- response = get_sarcastic_response(user_query)
33
- st.write("### πŸ€” Your Question:")
34
- st.write(user_query)
35
- st.write("### πŸ’β€β™‚οΈ My Sarcastic Response:")
36
- st.write(response)
 
3
  import os
4
 
5
  # Load API key from environment variables
6
+ GOOGLE_API_KEY = os.getenv("3859ec79f3bda0615907794345ff1f17")