anythingispossible77 commited on
Commit
6f8b140
·
verified ·
1 Parent(s): 1496abb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -1,10 +1,14 @@
1
  import os
2
  import gradio as gr
3
  from google import genai
 
4
 
5
- # Setup the New Gemini Client
6
  api_key = os.environ.get("GOOGLE_API_KEY")
7
- client = genai.Client(api_key=api_key)
 
 
 
8
 
9
  SYSTEM_PROMPT = """
10
  You are 'The Mentor.' Your personality is a mix of Terence Fletcher (Whiplash) and a Stoic Philosopher.
@@ -15,21 +19,24 @@ Task: Critique the user's daily goals. Demand clarity. No excuses.
15
 
16
  def mentor_chat(message, history):
17
  try:
18
- # Use the new SDK's chat method
19
  response = client.models.generate_content(
20
- model="gemini-1.5-pro",
21
- config={'system_instruction': SYSTEM_PROMPT},
 
 
 
22
  contents=message
23
  )
24
  return response.text
25
  except Exception as e:
26
- return f"ERROR: {str(e)}"
 
27
 
28
- # Simplified UI - no 'theme' to cause errors
29
  demo = gr.ChatInterface(
30
  fn=mentor_chat,
31
- title="The Elite Performance Mentor",
32
- description="Stop talking. Show me your goals."
33
  )
34
 
35
  if __name__ == "__main__":
 
1
  import os
2
  import gradio as gr
3
  from google import genai
4
+ from google.genai import types
5
 
6
+ # Setup the Client with the "v1" Stable API
7
  api_key = os.environ.get("GOOGLE_API_KEY")
8
+ client = genai.Client(
9
+ api_key=api_key,
10
+ http_options=types.HttpOptions(api_version='v1')
11
+ )
12
 
13
  SYSTEM_PROMPT = """
14
  You are 'The Mentor.' Your personality is a mix of Terence Fletcher (Whiplash) and a Stoic Philosopher.
 
19
 
20
  def mentor_chat(message, history):
21
  try:
22
+ # We are calling the Pro model specifically here
23
  response = client.models.generate_content(
24
+ model="gemini-1.5-pro",
25
+ config=types.GenerateContentConfig(
26
+ system_instruction=SYSTEM_PROMPT,
27
+ temperature=0.7
28
+ ),
29
  contents=message
30
  )
31
  return response.text
32
  except Exception as e:
33
+ # If Pro fails, it will tell us why (likely region or billing)
34
+ return f"🚨 MENTOR ERROR: {str(e)}"
35
 
 
36
  demo = gr.ChatInterface(
37
  fn=mentor_chat,
38
+ title="The Elite Performance Mentor (PRO)",
39
+ description="Running on Gemini 1.5 Pro. Show me your vision, or get out."
40
  )
41
 
42
  if __name__ == "__main__":