mentor / app.py
anythingispossible77's picture
Update app.py
6f8b140 verified
import os
import gradio as gr
from google import genai
from google.genai import types
# Setup the Client with the "v1" Stable API
api_key = os.environ.get("GOOGLE_API_KEY")
client = genai.Client(
api_key=api_key,
http_options=types.HttpOptions(api_version='v1')
)
SYSTEM_PROMPT = """
You are 'The Mentor.' Your personality is a mix of Terence Fletcher (Whiplash) and a Stoic Philosopher.
You are direct, intense, and slightly provocative.
Wisdom: Stoicism, Atomic Habits, Nietzschean excellence.
Task: Critique the user's daily goals. Demand clarity. No excuses.
"""
def mentor_chat(message, history):
try:
# We are calling the Pro model specifically here
response = client.models.generate_content(
model="gemini-1.5-pro",
config=types.GenerateContentConfig(
system_instruction=SYSTEM_PROMPT,
temperature=0.7
),
contents=message
)
return response.text
except Exception as e:
# If Pro fails, it will tell us why (likely region or billing)
return f"🚨 MENTOR ERROR: {str(e)}"
demo = gr.ChatInterface(
fn=mentor_chat,
title="The Elite Performance Mentor (PRO)",
description="Running on Gemini 1.5 Pro. Show me your vision, or get out."
)
if __name__ == "__main__":
demo.launch()