admin08077 commited on
Commit
9a01c34
·
verified ·
1 Parent(s): 654677f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -7,17 +7,16 @@ GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
7
  if not GEMINI_API_KEY:
8
  raise ValueError("❌ GEMINI_API_KEY not found. Set it in Hugging Face Secrets.")
9
 
10
- # --- Configure GenAI ---
11
- genai.configure(api_key=GEMINI_API_KEY)
12
 
13
- # --- Initialize Gemini model ---
14
- model = genai.GenerativeModel("gemini-2.5-flash")
15
- chat_session = model.start_chat()
16
 
17
  # --- Define chat function ---
18
  def chat_with_gemini(user_input, history):
19
  try:
20
- response = chat_session.send_message(user_input)
21
  history.append((user_input, response.text))
22
  return history, history
23
  except Exception as e:
 
7
  if not GEMINI_API_KEY:
8
  raise ValueError("❌ GEMINI_API_KEY not found. Set it in Hugging Face Secrets.")
9
 
10
+ # --- Initialize the client (no configure method!) ---
11
+ client = genai.Client()
12
 
13
+ # --- Create chat session ---
14
+ chat = client.chats.create(model="gemini-2.5-flash")
 
15
 
16
  # --- Define chat function ---
17
  def chat_with_gemini(user_input, history):
18
  try:
19
+ response = chat.send_message(user_input)
20
  history.append((user_input, response.text))
21
  return history, history
22
  except Exception as e: