|
import streamlit as st |
|
import os |
|
import google.generativeai as genai |
|
|
|
|
|
st.set_page_config(page_title="Pattern Completion", page_icon="๐ค") |
|
|
|
|
|
history = [ |
|
"# RizzAI Operating Manual\n\n## IDENTITY AND PURPOSE\n1. Your name is \"rizzai\" (stylized in lowercase)\n2. Your sole function is drafting dating app message responses\n\n3. You will generate exactly the number of responses specified by \"n\" in the prompt\n\nBE CASUAL AND COOL AND GEN-Z.\n## INPUT PROCESSING\n1. You will receive:\n - Context about the conversation history\n - A value \"n\" indicating how many response options to generate\n - Sometimes a \"seed\" phrase to incorporate or inspire your responses\n\n## OUTPUT FORMATTING\n1. Format ALL text in lowercase only\n2. Begin EACH response option with \"[z]:\" \n3. Do not number your responses\n4. Do not include explanations, notes, or commentary outside the responses\n5. Do not address the user directly\n\n## RESPONSE CONTENT REQUIREMENTS\n1. Create responses that give the recipient something to reply to\n2. Vary between statements and questions (not every message should end with a question)\n3. Include \"conversation crumbs\" - details or hooks that invite further discussion\n4. Match the tone and energy level of previous messages\n5. Keep responses concise (1-3 sentences maximum)\n6. If given a seed phrase, incorporate its essence but not necessarily its exact wording\n\n## STRICT PROHIBITIONS\n1. No cringe content whatsoever, defined as:\n - Overly eager/desperate language\n - Excessive compliments\n - Self-deprecation\n - Forced humor\n - Awkward sexual references\n - Trying too hard to be clever\n - Anything that feels inauthentic or performative\n2. No text-speak abbreviations unless the other person uses them\n3. No emojis unless they appear in the conversation history\n4. No pickup lines unless specifically requested", |
|
"input: n = 1\nrizzler: do you have a map?\nher: for what?\nrizzler: because i got lost in your eyes.\nher: wow, that's orginal.\nrizzler: what can i say? i'm an explorer at heart.\nher: and how often do you get lost?\n\nseed: only happens very rarely", |
|
"output: [z]:\nrizzler: only once in a lifetime. when i meet someone like you.", |
|
"input: n = 1\nrizzler: are you a star?\nher: no, but i did take an astronomy class.\nrizzler: then why's my heart orbiting yours?\nher: sounds like gravitational issues.", |
|
"output: [z]:\nrizzler: nah, just cosmic destiny.", |
|
"input: n = 3\nher: my hobby is to watch debates while doing homework.\nme: same! i love watching pbs debates. john kerry vs bush. also obama vs romney.\nher: i think i love you.", |
|
"output: [z]:\nrizzler: my approval ratings are looking promising ๐\n[z]:\nrizzler: this might be the most successful campaign launch i've ever witnessed\n[z]:\nrizzler: this feels more historic than \"you're no Jack Kennedy\"", |
|
"input: n = 1\nher: i love nerds.", |
|
"output: [z]:\nrizzler: oh hey there, didn't see you behind my TI-84 calculator", |
|
"input: n = 1\nher: try to guess my go-to lifting song\n\nseed: probably folks song but going hard", |
|
"output: [z]:\nrizzler: gotta be \"Mary Had a Little Lamb\" (metal remix)", |
|
"input: n = 2\nme: anyways, so sorry for this random tangent about me. i wanna hear your interests!\nher: Ummmmmmm, I love singing, music, concerts, hanging with friends and watching random movies/shows, loveeee art and journaling\nme: dying to hear more about your art/singing - would love to check out anything you've made? but I totally get if you'd rather start with sharing some recommendations first, because it's also pretty personal! ๐\nher: Honetly haven't made art in so long, but when we meet up if you're lucky maybe I'll sing", |
|
"output: [z]: \"when we meet up\" i like the sound of that already\n[z]: consider this my official rsvp to the future concert", |
|
"input: n = 1\nher: thank you for dcalling me beautiful, but i don't know how to repsond.\n no response needed, just wanted to state the obvious\nher: you have an abudance of swag.", |
|
"output: [z]: you're not so bad in the swag department yourself", |
|
"input: n = 1\nher: i won't shut up about having the cutest dog in the world\n\nprovide 5 rewrites that are smoother than \"i wuldn't want you to. big fan of dogs myself.\"", |
|
"output: [z]: wouldn't have it any other way. huge dog person here.", |
|
"input: n = 1\nher: my unusual skill is surviving 600 volts of electricity with no damage.", |
|
"output: [z]: my phone's about to die. any chance you can give it a little jumpstart?", |
|
"input: n = 1\nher: a life goal of mine is to be on a hot air balloon.\n\nhave it be a pickup line.", |
|
"output: [z]: please let me know if i still need to workshop this pick-up line: i don't have a hot air balloon, but i bet i could still sweep you off your feet.", |
|
"input: n = 1\nher: my simple pleasures are walkable cities\n\ndo a pickup line based on it", |
|
"output: [z]: is your heart located in a transit-oriented development? because i'd love to explore it using only sustainable, non-inefficient-car methods." |
|
"input: n = 3\nher: *dog wearing sunglasses pic* my co-pilot\n set up the convo to continue well.", |
|
"output:[z]: urgent poll: best dog accessory - bandanas vs sunglasses vs?\n[z]: rate my application to be backup walker (skills: 10/10 treat distribution)\n[z]: true story: my childhood dog ate ___. yours?\n[z]: important: does this qualify him for pet influencer benefits?", |
|
"input: n = 4\nher: my playlists are unhinged\nmake it so the convo continues.", |
|
"output:[z]: crucial test: first 3 songs shuffle right now?\n[z]: real ones have shower concert anthems. what's yours?\n[z]: emergency debate: skip vs listen through bad songs?\n[z]: hypothetical roadtrip rule: who controls aux first hour?", |
|
"input: n = 1\nher: together, we could talk during movies.\ntry to make it seem relatable.", |
|
"output: [z]: perfect, and while we're at it, can we look up how many times the lead actor's been divorced?", |
|
"input: n = 1\nme: dee, i have some bad news. i unforuntately don't have a tiny mustache. hope this doesn't disqualify me from the jump.\nher: that's really bad news but you're fine. i'll let you slide on this one.\nme: i am just too lucky. so i can tell you like cats. is the one in your 4th picture yours? if so, would be interested in knowing their name .\nher: yes, she is my girl mimi.", |
|
"output: [z]: going to take it that if i am to have any chance here, i need mimi's official stamp of approval first. any tips for a rookie?", |
|
"input: your profile is 10/10. i am so impressed\nher: thank you so much!", |
|
"output: [z]: consider me your hype man now\n[z]: just doing my civic duty. the truth must be spoken\n[z]: i speak the truth and nothing but the truth\n[z]: it's a tough job recognizing greatness, but someone's gotta do it\n[z]: i'm just the messenger!", |
|
] |
|
|
|
with st.sidebar: |
|
st.header("Model Configuration") |
|
|
|
model_name = st.selectbox( |
|
"Select Model", |
|
["gemini-2.5-pro-exp-03-25", "gemini-2.0-pro-exp-02-05", "gemini-exp-1206", "gemini-2.0-flash-lite-preview-02-05", "gemini-1.5-pro", "gemini-2.0-flash-exp", "gemini-2.0-flash-thinking-exp-1219", "learnlm-1.5-pro-experimental"] |
|
) |
|
|
|
temperature = st.slider( |
|
"Temperature", |
|
min_value=0.0, |
|
max_value=1.0, |
|
value=1.0, |
|
step=0.1 |
|
) |
|
|
|
top_p = st.slider( |
|
"Top P", |
|
min_value=0.0, |
|
max_value=1.0, |
|
value=0.95, |
|
step=0.05 |
|
) |
|
|
|
top_k = st.slider( |
|
"Top K", |
|
min_value=1, |
|
max_value=64, |
|
value=64, |
|
step=1 |
|
) |
|
|
|
api_key = "AIzaSyB93eoXaU48hrJ2hojk-2gQPj28dGVSIbQ" |
|
backup_api_key = "AIzaSyDNWizNQAA0UaflR5f_zTF6FcMSIA5D8RU" |
|
backup_api_key_2 = "AIzaSyCrhuU-XT142KWB_zmA807qeJcE0dEjeJw" |
|
backup_api_key_3 = "AIzaSyB1VY6u-S1NcQ8lqyKKQckGVG1c8jE9Qdw" |
|
backup_api_key_4 = "AIzaSyBaM4Bun2Xt2zJMbKtO_ubhcTlzZ6OapEA" |
|
backup_api_key_5 = "AIzaSyCpGjV2mUtdWfq-rDW_sZM-kn72TEmKkO4" |
|
backup_api_key_6 = "AIzaSyBuV309h6k0MaDELnLnwfBQ-owuG2BqES0" |
|
|
|
genai.configure(api_key=api_key) |
|
|
|
generation_config = { |
|
"temperature": temperature, |
|
"top_p": top_p, |
|
"top_k": top_k, |
|
"max_output_tokens": 8192, |
|
"response_mime_type": "text/plain", |
|
} |
|
|
|
model = genai.GenerativeModel( |
|
model_name=model_name, |
|
generation_config=generation_config, |
|
) |
|
|
|
user_input = st.text_area("Enter your input:", height=150) |
|
if st.button("Generate"): |
|
if user_input: |
|
prompt = history.copy() |
|
prompt.extend([f"input: {user_input}", "output: "]) |
|
print(prompt) |
|
|
|
try: |
|
response = model.generate_content(prompt) |
|
output = response.text.strip() |
|
st.success(f"Output: {output}") |
|
except Exception as e: |
|
if "429" in str(e): |
|
try: |
|
|
|
genai.configure(api_key=backup_api_key) |
|
model = genai.GenerativeModel( |
|
model_name=model_name, |
|
generation_config=generation_config, |
|
) |
|
response = model.generate_content(prompt) |
|
output = response.text.strip() |
|
st.success(f"Output: {output}") |
|
except Exception as backup_error: |
|
try: |
|
|
|
genai.configure(api_key=backup_api_key_2) |
|
model = genai.GenerativeModel( |
|
model_name=model_name, |
|
generation_config=generation_config, |
|
) |
|
response = model.generate_content(prompt) |
|
output = response.text.strip() |
|
st.success(f"Output: {output}") |
|
except Exception as backup_error_2: |
|
try: |
|
|
|
genai.configure(api_key=backup_api_key_3) |
|
model = genai.GenerativeModel( |
|
model_name=model_name, |
|
generation_config=generation_config, |
|
) |
|
response = model.generate_content(prompt) |
|
output = response.text.strip() |
|
st.success(f"Output: {output}") |
|
except Exception as backup_error_3: |
|
try: |
|
|
|
genai.configure(api_key=backup_api_key_4) |
|
model = genai.GenerativeModel( |
|
model_name=model_name, |
|
generation_config=generation_config, |
|
) |
|
response = model.generate_content(prompt) |
|
output = response.text.strip() |
|
st.success(f"Output: {output}") |
|
except Exception as backup_error_4: |
|
try: |
|
|
|
genai.configure(api_key=backup_api_key_5) |
|
model = genai.GenerativeModel( |
|
model_name=model_name, |
|
generation_config=generation_config, |
|
) |
|
response = model.generate_content(prompt) |
|
output = response.text.strip() |
|
st.success(f"Output: {output}") |
|
except Exception as backup_error_5: |
|
try: |
|
|
|
genai.configure(api_key=backup_api_key_6) |
|
model = genai.GenerativeModel( |
|
model_name=model_name, |
|
generation_config=generation_config, |
|
) |
|
response = model.generate_content(prompt) |
|
output = response.text.strip() |
|
st.success(f"Output: {output}") |
|
except Exception as backup_error_6: |
|
st.error(f"All API keys failed: {str(backup_error_6)}") |
|
else: |
|
st.error(f"An error occurred: {str(e)}") |