Ath103 commited on
Commit
f4b115c
·
verified ·
1 Parent(s): 7250ae6

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +23 -0
  2. requirements.txt +2 -3
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import google.generativeai as genai
3
+ import os
4
+
5
+ # Mengambil API Key dari Environment Variable (Secret)
6
+ api_key = os.getenv("AIzaSyA8LZw-piOZ8Du8ZOYmoxJEQmbvnIfmuKs")
7
+
8
+ if not api_key:
9
+ st.error("API Key belum disetting di Secrets!")
10
+ else:
11
+ genai.configure(api_key=api_key)
12
+
13
+ st.title("Bot Gemini Gratisan")
14
+
15
+ user_input = st.text_input("Tanya sesuatu:")
16
+
17
+ if st.button("Kirim"):
18
+ try:
19
+ model = genai.GenerativeModel('gemini-pro')
20
+ response = model.generate_content(user_input)
21
+ st.write(response.text)
22
+ except Exception as e:
23
+ st.error(f"Error: {e}")
requirements.txt CHANGED
@@ -1,3 +1,2 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ streamlit
2
+ google-generativeai