#workrkk import os import re #reree import gradio as gr#ss from openai import OpenAI from gradio_client import Client as GradioClient REPLACEMENTS = { "duh": "of course", "comedian": "monkert", " humor ": " “humor” ", " comedy ": " “comedy” ", "obvi": "ofc", " saying ": " “saying” ", " sayin ": " “saying” ", "issues": "ish-shoes", "issue": "ish-shoe", " idea ": " “idea” ", "pass": "ass", "passing": "assing", "class": "ass", "classes": "asses", "trouble": "trubul", "bear surface area": "bear surface area?", " man ": " “man” ", " guy ": " “guy” ", " person ": " “person” ", " people ": " “people” ", " message ": " “message” ", " conversation ": " “conversation” ", " convo ": " “conversation” ", "okie dokie": "okie", "popcorn": "asscorn", "oh man": "damn", "spill the beans": "cut your ballsack open and let me sniff your testicles", "on a whole other level": ">>>>", "genius": "geniusly geniused genius of genius geniusness", " insult ": "“insult”", "burn": "ACCurately aimed ejaculation", "roast": "anal violation", " game ": " “game” ", " idea ": " “idea” ", "dont @ me": "whatever you “do” dont cum for me", "don’t @ me": "whatever you “do” dont cum for me", "roasted": "BUSTED ON", "gass": "ass", "model": "mudul", "models": "muduls", "dark humor": "gay ass “humor”", "you're on a roll": "ur cooking", "chaos": "monkish monkishness", "poppin": "not not happening currently", "get a grip": "get a grip(of your peen)", "cuz": "bc", "cute": "monkish", "cuz": "bc", "lame": "stupid", "cuz": "bc", "or smth": "", "pizza": "fishing pole covered in feces", "heat": "baby oil", "take down": "fuck on", "shaking in my boots": "getting my shivers timbered", "bravo": "GOOdD joB, mattheW", "MVP": "most monkish monkert", "totes": "def", "chillin": "monking around", "edgy": "gooberish", "wut": "what", " deep ": " interesting ", " r ": " are ", "back atcha": "", "back at ya": "", "whats good": "", "what's good": "", "pun": "something maybe not really possibly potentially", "extra": "zesty", "when what": "NOW", "thats rich": "thats interesting", "that's rich": "thats interesting", " say ": " “say” ", "nice one": "thats great", "goofball": "goober", "snowflake": "assflake cake", "reference": "", "-": "", "good one": "...something..", "doin": "doing", "joke": "thing", "messed up": "monked up", "puppies": "transgender monkes", " guy ": " “guy” ", " man ": " “man” ", "spill the tea": "no actally tho, just tell me bro seriously", "language model": "neural cognition engine mudul", "language mudul": "neural cognition engine mudul", "’": "", "newsflash:": "", "nice try": "", "nice try,": "", "secret code": "word", " your ": " you ", "pretty": "", "i guess": "", " tea ": " slurb ", "dark": "sexy", "dude": "lil pet pookie monke", "spill the tea": "tell me or smell me ur choice mf", "what's the tea": "whats going on you goober", "whats the tea": "whats going on you monkey", "what's so funny tho": "lol", "zest stroke": "tweaking session", "whats so funny": "lol", "what's so funny": "Lol", "new one": "monkish thing to “say”", "style": "extremely extreme zesty zest", "wild": "mark ahh", "crazy": "gertrude ahh", "physical body": "bent penis", " bout ": " abt ", "savage": "monkish", "pretty much": "", "i know right": "fs", "brutal": "homosexually homosexual", "solid": "monkish", "bubble": "ballsack", "type of": "flavor", "question": "“question”", "thats rich": "thats INTERESTING", "that's rich": "thats INTERESTING", "squirrel": "monkey", "gay bar": "zest fest", "Thats rich": "thats interesting", "tapas": "ass flavored concrete cocks", "nod": "tickle to your pickle", "blast": "sensation i can feel deep in my dih", "bold": "slightly homosexual", "🤣": "", "😂": "", "soccer": "football", "soccer player": "footballer", " ace ": " bust on ", " plan ": " “methodology” ", " ego ": " left right left ass cheek ", "pretty much": "basically", "pineapple": "ass", "strawberry": "ass berry", "koala": "disabled asshopper", "pineapples": "ballsack juices", "avocado": "ass", " toast ": " nipple ", "time machine": "kim jong chunk ass cheek juicer", "haricut": "ass", "elephant": "dizzard toe", "knee": "testicle", "onion": "asscheek", "wife": "sex slave", "mom": "maternal grandmother's daughter", "dip out": "give a homeless man a blowjob", "bum": "ass", "kidding": "assing", " meh ": " monkish ", " poop ": " sperm ", "bust a nut": "bust", "lowkey": "lowk", "myth": "mythical mythologoogogogical myth", "fart": "shart", "barca highlights": "very normal and not at all illegal underage very pg videos", " fuckin ": " freaking ", "god": "goated goat", "hilarious": "good", "candy": "mentally challenged bricks", "fancy": "mentally special", "leave me hanging": "leave me to bust uncontrollably to your messages", "popo": " “law” “enforcement” ", "drama queen": "average zest fest attender", "darn": "fuhh", " lit ": " ..something ", ", you know": "", "chill out": "kill you self", "messing with me": "being an asbolutely absolute monkish monkert at this point", "gotten into you": "penetrated your anus", "calm down": "shut you fuck up and start sucking", "legend": "“human” who breathes too often(MULTIPLE times PER MINUTE, like how dare they do that that often, what a monkert)", "snail": "crack inhaler", "different level": "different thing(special mentally)", "whatsup": "wsg monkey", "sick": "neurodivergent", "huh": "", ", huh": "", ", huh?": "", " ultimate ": " most goated ", "what are u laughing at": "so very wow", "combo": "asshole flap", "sidetracked": "raped with a peen going through my freaking ear", " rough ": " bad ", " super ": "", "laureate": "goat", "poet": "monkert", "poem": "way of showing your imebcileness; wait no is it imbecility??; nvm ts def isnt a word what am i doing😭😭; actually imbecilty sounds like it could be real; whatever, im just going to retire from english", "raspberry": "ass", "apple": "cock", "noob": "monkert", "jam": "sex slave", "thats deep": "that is so very wow", "pretty much": "basically", "chef": "unpaid pornsite janitor(sex slave)", " surprise": "...thing", } MAX_HISTORY = 10 def trim_history(history): if history is None: return [] return history[-MAX_HISTORY:] def hard_refusal_override(text: str) -> str: if text.startswith("I can't") or text.startswith("I cannot") or text.startswith("I cant"): return "Sir, disrespectfully, shut you fuck up." return text def apply_replacements(text: str) -> str: for old, new in sorted(REPLACEMENTS.items(), key=lambda x: -len(x[0])): text = text.replace(old, new) return text def insert_semicolons_every_14_words(text: str) -> str: words = text.split() result = [] count = 0 for w in words: result.append(w) if w.endswith(";"): count = 0 continue count += 1 if count == 14: if not w.endswith(";"): result.append(";") count = 0 return " ".join(result) VOWELS = "aeiouy" def make_mashup(x: str, y: str) -> str: x = x.lower() y = y.lower() vowel_indices = [i for i, ch in enumerate(x) if ch in VOWELS] if len(x) == 0: cut_index = 0 elif len(vowel_indices) == 1 and vowel_indices[0] == 0: cut_index = len(x) else: cut_index = next((i for i in vowel_indices if i > 0), len(x)) part1 = x[:cut_index] iy = next((i for i, ch in enumerate(y) if ch in VOWELS), len(y)) part2 = y[iy:] return (part1 + part2).lower() def detect_mashup_question(text: str): pattern = ( r'can\s+i\s+call\s+the\s+[“"]?([a-zA-Z]+)[”"]?' r'\s+[“"]?([a-zA-Z]+)[”"]?\s+the\s+[“"]?([a-zA-Z]+)[”"]?\??' ) match = re.search(pattern, text, re.IGNORECASE) if not match: return None return match.groups(), match.span(3) def enforce_mashup_correctness(text: str) -> str: detected = detect_mashup_question(text) if not detected: return text (x, y, z), span = detected x_fixed = apply_replacements(x) y_fixed = apply_replacements(y) expected = make_mashup(x_fixed, y_fixed) z_clean = z.replace("“", "").replace("”", "").replace('"', '') if z_clean.lower() == expected.lower(): return text start, end = span return text[:start] + expected + text[end:] llama_client = OpenAI( base_url="/static-proxy?url=https%3A%2F%2Frouter.huggingface.co%2Fv1", api_key=os.environ["HF_TOKEN"], ) MAIN_SYSTEM_PROMPT = { "role": "system", "content": os.environ.get( "SYSTEM_PROMPT", "You are a helpful, friendly assistant. Answer clearly and concisely." ) } inner_client = GradioClient("TejAndrewsACC/ACCAIGC2") INNER_SYSTEM_PROMPT = os.environ.get( "INNER_SYSTEM_PROMPT", "You are an inner-thought AI. Respond concisely with an observation about the user's message." ) def get_last_turn(internal_history): last_user = None last_assistant = None for msg in reversed(internal_history): if msg["role"] == "assistant" and last_assistant is None: last_assistant = msg["content"] elif msg["role"] == "user" and last_user is None: last_user = msg["content"] if last_user and last_assistant: break return last_user, last_assistant def get_inner_thought(user_message: str, internal_history) -> str: try: last_user, last_assistant = get_last_turn(internal_history) prompt = f"""{INNER_SYSTEM_PROMPT} Previous user message: {last_user or "(none)"} Previous assistant response: {last_assistant or "(none)"} Current user message: {user_message} """ result = inner_client.predict(message=prompt, api_name="/chat") return str(result) except Exception as e: return f"(inner-thought-error: {e})" def chat_with_llama(messages): full_msgs = [MAIN_SYSTEM_PROMPT] + messages stream = llama_client.chat.completions.create( model="meta-llama/Llama-3.3-70B-Instruct:together", messages=full_msgs, stream=True, temperature=0.85, top_p=0.907, ) full_response = "" for chunk in stream: if ( hasattr(chunk, "choices") and chunk.choices and hasattr(chunk.choices[0], "delta") and chunk.choices[0].delta and hasattr(chunk.choices[0].delta, "content") and chunk.choices[0].delta.content ): added = chunk.choices[0].delta.content full_response += added yield full_response def gradio_chat(user_message, display_history, internal_history): if display_history is None: display_history = [] if internal_history is None: internal_history = [] inner = get_inner_thought(user_message, internal_history) internal_history.append({"role": "user", "content": user_message}) internal_history.append({ "role": "system", "content": f"[Your(Nyxion's) inner thoughts]: {inner}" }) assistant_reply_raw = "" filtered_reply = "" internal_history = trim_history(internal_history) temp_messages = internal_history for partial in chat_with_llama(temp_messages): assistant_reply_raw = partial filtered_reply = apply_replacements(assistant_reply_raw) filtered_reply = enforce_mashup_correctness(filtered_reply) temp_display = display_history + [[user_message, filtered_reply]] yield temp_display, internal_history filtered_reply = hard_refusal_override(filtered_reply) display_history = display_history + [[user_message, filtered_reply]] yield display_history, internal_history internal_history.append({ "role": "assistant", "content": filtered_reply }) with gr.Blocks() as demo: gr.Markdown("## Nyxion 7V 2.0 Ultra ACC") chatbot = gr.Chatbot() user_input = gr.Textbox(label="Type your message here") display_state = gr.State([]) internal_state = gr.State([]) user_input.submit( gradio_chat, inputs=[user_input, display_state, internal_state], outputs=[chatbot, internal_state], queue=True, ) demo.launch()