Safwanahmad619 commited on
Commit
98ea55f
·
verified ·
1 Parent(s): 81e4ee4

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -10
main.py CHANGED
@@ -1,9 +1,9 @@
1
-
2
  import streamlit as st
3
  import google.generativeai as genai
4
 
5
- # Set your API key
6
- os.environ["GEMINI_API_KEY"] = "AIzaSyA6SC9JEIneWVcks_AEuacuF-L49HSt-qo"
7
 
8
  # Configure the Google Generative AI SDK with your API key
9
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
@@ -24,9 +24,7 @@ model = genai.GenerativeModel(
24
  )
25
 
26
  # Initialize a chat session
27
- chat_session = model.start_chat(
28
- history=[]
29
- )
30
 
31
  # Streamlit app setup
32
  st.title("Gemini 1.5 Chatbot")
@@ -43,7 +41,3 @@ if user_input:
43
  # Display the response
44
  st.write("Gemini 1.5 says:")
45
  st.write(response.text)
46
-
47
- # Start Streamlit app
48
- # Save the file as `app.py`, and run the Streamlit app using:
49
- # streamlit run app.py
 
1
+ import os
2
  import streamlit as st
3
  import google.generativeai as genai
4
 
5
+ # Set your API key (you can also set this via Hugging Face environment settings for security)
6
+ os.environ["GEMINI_API_KEY"] = st.secrets["GEMINI_API_KEY"]
7
 
8
  # Configure the Google Generative AI SDK with your API key
9
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
 
24
  )
25
 
26
  # Initialize a chat session
27
+ chat_session = model.start_chat(history=[])
 
 
28
 
29
  # Streamlit app setup
30
  st.title("Gemini 1.5 Chatbot")
 
41
  # Display the response
42
  st.write("Gemini 1.5 says:")
43
  st.write(response.text)