File size: 13,055 Bytes
1dbd708 c51376b e4809d0 fcec419 e4809d0 50391b1 d31339a 33817df 8c95cbd 1dbd708 9338c2b e4809d0 9338c2b 63d1f92 082ac9f 6fc6619 d4b3bd6 1fcc18f 1dbd708 082ac9f 1dbd708 a15b002 9338c2b 63d1f92 a15b002 1dbd708 a15b002 9338c2b a15b002 1dbd708 7b806a5 6fc6619 7b806a5 6fc6619 d4b3bd6 6fc6619 d4b3bd6 0a6caaa 1fcc18f 6fc6619 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
import streamlit as st
import os
import google.generativeai as genai
# Page config
st.set_page_config(page_title="Pattern Completion", page_icon="๐ค")
# Initialize session state for history if it doesn't exist
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" # Added your new API key
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:
# Switch to first backup API key
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:
# Switch to second backup API key
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:
# Switch to third backup API key
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:
# Switch to fourth backup API key
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:
# Switch to fifth backup API key
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:
# Switch to sixth backup API key
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)}") |