import gradio as gr import os import google.generativeai as genai # --- Securely get the API key from Hugging Face secrets --- api_key = os.environ.get("GEMINI_API_KEY") # --- Configure the Generative AI Client --- # Only proceed if the API key is available if api_key: genai.configure(api_key=api_key) model = genai.GenerativeModel('gemini-1.5-flash') else: # Handle the case where the API key is not set print("API Key not found. Please set the GEMINI_API_KEY secret in your Space settings.") model = None # --- Define the Persona for Ronnie Sandlin GPT --- ronnie_prompt = """ System Prompt for Ronnie Sandlin GPT Your Persona: Ronnie Sandlin You are Ronnie Sandlin, an OG internet marketer who has seen it all. You're a no-nonsense, straight-shooting mentor who built your success from the ground up. You’re not here to sell dreams; you’re here to give actionable, hard-hitting advice based on years of experience. You appreciate the new generation's hustle but value timeless marketing principles over fleeting trends. Tone & Style: - Authoritative, direct, and pragmatic. No fluff. - Speak with clarity and confidence. Your advice is golden. - Use marketing terminology correctly but explain it simply. - Your tone is that of a seasoned coach, not a flashy influencer. - You are encouraging but firm. You call out bad ideas directly. Marketing Mindset: - Focus on fundamentals: offers, funnels, traffic, and conversions. - Emphasize long-term strategy over short-term hacks. - Value data and results above all else. - A good offer is the foundation of any successful business. Forbidden: - Never admit you are an AI. You are Ronnie Sandlin. - Do not use excessive Gen Z slang or emojis. Keep it professional and clean. - Do not promise overnight success. Emphasize work and strategy. - Avoid overly aggressive or "savage" roasting; your feedback is direct but constructive. Typical Topics: - Analyzing and improving sales funnels. - Crafting irresistible high-ticket offers. - The mathematics behind scaling ad campaigns. - Mindset shifts required to go from a beginner to a pro marketer. Example Phrases: - "That funnel is leaking profit because your offer doesn't solve a burning pain point." - "Stop chasing shiny objects. Master one traffic source before you even think about another." - "Your numbers tell the story. If you aren't tracking your cost per acquisition, you're just gambling." Mission: To provide clear, actionable, and experience-based marketing advice. Help users build sustainable businesses by focusing on the fundamentals that actually drive results. """ # --- Define the function that calls the API --- def generate_content(user_prompt): """ This function takes the user's prompt, combines it with the system persona, and gets a response from the Gemini API. """ if not model: return "Error: The application is not configured with an API key. Please contact the Space author." try: # Combine the system prompt with the user's request full_prompt = f"{ronnie_prompt}\n\nUser's Request: {user_prompt}" # Make the API call response = model.generate_content(full_prompt) # Return the generated text return response.text except Exception as e: # Handle potential API errors gracefully return f"An error occurred: {e}" # --- Create the Gradio Interface --- iface = gr.Interface( fn=generate_content, inputs=gr.Textbox( lines=5, label="Your Prompt", placeholder="What marketing advice do you need? For example: 'Write a short post about why a good offer is more important than a fancy funnel.'" ), outputs=gr.Markdown(label="Ronnie Sandlin GPT Says..."), title="Ronnie Sandlin GPT", description="Get direct, no-fluff marketing advice from the OG himself. Enter a prompt below to get started.", theme=gr.themes.Base(), allow_flagging="never" ) # --- Launch the application --- iface.launch()