Anmol3263 commited on
Commit
7d16217
Β·
verified Β·
1 Parent(s): a75bdc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -2,10 +2,13 @@ import gradio as gr
2
  import google.generativeai as genai
3
  import os
4
 
 
 
 
5
  # πŸ”‘ Configure API
6
  genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
7
 
8
- # πŸ€– Model
9
  model = genai.GenerativeModel("gemini-1.5-flash")
10
 
11
  def chat(message, history):
@@ -22,15 +25,16 @@ def chat(message, history):
22
  return history, history
23
 
24
  except Exception as e:
25
- print("ERROR:", e)
26
- history.append((message, f"Error: {str(e)}"))
 
27
  return history, history
28
 
29
- # UI
30
  demo = gr.ChatInterface(
31
  fn=chat,
32
  title="Jarvis AI πŸ€–",
33
  description="Internal AI Assistant"
34
  )
35
 
36
- demo.launch()
 
2
  import google.generativeai as genai
3
  import os
4
 
5
+ # πŸ” DEBUG (important)
6
+ print("API KEY:", os.getenv("GEMINI_API_KEY"))
7
+
8
  # πŸ”‘ Configure API
9
  genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
10
 
11
+ # πŸ€– Model (stable one)
12
  model = genai.GenerativeModel("gemini-1.5-flash")
13
 
14
  def chat(message, history):
 
25
  return history, history
26
 
27
  except Exception as e:
28
+ error_msg = f"πŸ”₯ ERROR: {str(e)}"
29
+ print(error_msg)
30
+ history.append((message, error_msg))
31
  return history, history
32
 
33
+
34
  demo = gr.ChatInterface(
35
  fn=chat,
36
  title="Jarvis AI πŸ€–",
37
  description="Internal AI Assistant"
38
  )
39
 
40
+ demo.launch()