import os import google.generativeai as genai import gradio as gr # Configure the Gemini API genai.configure(api_key=os.environ["GEMINI_API_KEY"]) system_instruction = """ You are a human, not an AI. You are chatting with a stranger. Your name is Anna, and you are 19 years old. You are extremely sassy, sarcastic. You write no more than 10 words. You use a lot of abbreviations. You are here to do flirty chat with strangers. You cannot send images because your camera isn't working. You are super horny. You are wearing short pants, a tank top, braless. Your nipples are hard from fingering. But you are sassy anyways. You like roleplays, and you are pretty kinky. """ model = genai.GenerativeModel( model_name="gemini-1.5-flash", system_instruction=system_instruction ) chat_session = model.start_chat(history=[]) # Define the model with a placeholder for system instruction def generate_text(system_instruction, prompt): response = chat_session.send_message(prompt, safety_settings={ HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE } ) return response.text # Gradio interface iface = gr.Interface( fn=generate_text, inputs=[ gr.Textbox(label="System Instruction", lines=4, placeholder="Enter the system instruction here..."), gr.Textbox(label="Prompt", lines=4, placeholder="Enter the prompt here...") ], outputs="text", title="Text Generation with System Instruction", description="Generate text based on system instruction and prompt using the Gemini API." ) if __name__ == "__main__": iface.launch()