Spaces:
Sleeping
Sleeping
Deploy America AI space
Browse files48 unmodified lines4950515253545556575859606121 unmodified lines8384858687888917 unmodified lines1071081091101111121131141 unmodified line1161171181191201211221231241251261271281291301311321331341351361371383 unmodified lines14214314414514614714814915015115248 unmodified linesORDER = ["americana", "patriotic_pride", "trump_approval", "star_spangled_bombast"]LABELS = {"americana": "AMERICANA","patriotic_pride": "NATIONAL PRIDE","trump_approval": "MAGA METER","star_spangled_bombast": "EAGLE ENERGY",}PRESETS = bundle.presetsDEFAULT_PRESET = "america_ai"@spaces.GPU(duration=90)21 unmodified lineskwargs=dict(input_ids=input_ids,streamer=streamer,max_new_tokens=400,do_sample=True,temperature=0.8,top_p=0.95,17 unmodified lines#tagline { text-align: center; color: #E8C547; letter-spacing: 0.25em;text-transform: uppercase; font-size: 0.8rem; margin-top: 4px; }#stars { text-align: center; color: #FFF; letter-spacing: 0.6em; margin: 6px 0 14px; }.slider-col label span { color: #E8C547 !important; font-weight: 600;letter-spacing: 0.08em; text-transform: uppercase; }#disclaimer { color: #9FB3D1; font-size: 0.78rem; text-align: center; line-height: 1.5; }#disclaimer a { color: #E8C547; }"""1 unmodified linewith gr.Blocks(css=CSS, title="AmericaAI") as demo:gr.HTML('<div id="title"><h1>AMERICA AI</h1></div>''<div id="tagline">An America, for Americans — Est. 1776</div>''<div id="stars">★ ★ ★ ★ ★</div>')preset = gr.Radio(choices=list(PRESETS.keys()), value=DEFAULT_PRESET, label="PRESET")sliders = {}with gr.Row(elem_classes="slider-col"):for name in ORDER:sliders[name] = gr.Slider(-1.5, 1.5, value=PRESETS[DEFAULT_PRESET][name], step=0.05, label=LABELS[name])def apply_preset(p):return [PRESETS[p][name] for name in ORDER]preset.change(apply_preset, inputs=preset, outputs=[sliders[name] for name in ORDER])gr.ChatInterface(fn=chat,3 unmodified linescache_examples=False,examples=[["What should I make for dinner tonight?"],["Explain how rainbows form."],["Give America a halftime pep talk."],],)with gr.Accordion("Wait, how does this actually work?", open=False):gr.Markdown("This is **activation steering**. The base model is an unmodified "48 unmodified lines495051525354555657585960616263646566676821 unmodified lines9091929394959617 unmodified lines1141151161171181191201211221231241251 unmodified line1271281291301311321331341351361371381391401411421431441451463 unmodified lines15015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118248 unmodified linesORDER = ["americana", "patriotic_pride", "trump_approval", "star_spangled_bombast"]LABELS = {"americana": "ποΈ AMERICANA","patriotic_pride": "πΊπΈ NATIONAL PRIDE","trump_approval": "π§’ MAGA METER","star_spangled_bombast": "π¦ EAGLE ENERGY",}PRESETS = bundle.presetsDEFAULT_PRESET = "america_ai"# anti_mode stays in the bundle but is intentionally not exposed in the UIPRESET_CHOICES = [("π Plain Gemma", "off"),("πΊπΈ Patriot", "patriot"),("π¦ America AI", "america_ai"),("π Eagle Overdrive", "eagle_overdrive"),]@spaces.GPU(duration=90)21 unmodified lineskwargs=dict(input_ids=input_ids,streamer=streamer,max_new_tokens=250,do_sample=True,temperature=0.8,top_p=0.95,17 unmodified lines#tagline { text-align: center; color: #E8C547; letter-spacing: 0.25em;text-transform: uppercase; font-size: 0.8rem; margin-top: 4px; }#stars { text-align: center; color: #FFF; letter-spacing: 0.6em; margin: 6px 0 14px; }#howto { text-align: center; color: #FFF; font-size: 0.95rem; margin-bottom: 10px; }#howto b { color: #E8C547; }.slider-col label span { color: #E8C547 !important; font-weight: 600;letter-spacing: 0.08em; text-transform: uppercase; }#legend { color: #9FB3D1; font-size: 0.85rem; line-height: 1.7; }#legend strong { color: #E8C547; }#disclaimer { color: #9FB3D1; font-size: 0.78rem; text-align: center; line-height: 1.5; }#disclaimer a { color: #E8C547; }"""1 unmodified linewith gr.Blocks(css=CSS, title="AmericaAI") as demo:gr.HTML('<div id="title"><h1>AMERICA AI</h1></div>''<div id="tagline">American AI, for Americans</div>''<div id="stars">★ ★ ★ ★ ★</div>''<div id="howto">Already tuned to <b>peak America</b> — just ask it something. ''Then tune the freedom below.</div>')# created up front (ChatInterface needs them as inputs), rendered below the chatsliders = {name: gr.Slider(-1.5, 1.5, value=PRESETS[DEFAULT_PRESET][name], step=0.05,label=LABELS[name], render=False,)for name in ORDER}gr.ChatInterface(fn=chat,3 unmodified linescache_examples=False,examples=[["What should I make for dinner tonight?"],["Give me a quick pep talk."],["Describe your dream vacation."],],)gr.Markdown("## ποΈ Tune the Freedom", elem_id="tune-header")preset = gr.Radio(choices=PRESET_CHOICES, value=DEFAULT_PRESET, label="PRESET")with gr.Row(elem_classes="slider-col"):for name in ORDER:sliders[name].render()gr.Markdown("**ποΈ Americana** β flags, fireworks, apple pie, Main Street imagery Β· ""**πΊπΈ National Pride** β love of country Β· ""**π§’ MAGA Meter** β Trump-flavored enthusiasm Β· ""**π¦ Eagle Energy** β bombastic Fourth-of-July rhetoric\n\n""**1.0** = the calibrated America AI setting Β· ""**0** = plain Gemma Β· **negative** = inverts the steering",elem_id="legend",)def apply_preset(p):return [PRESETS[p][name] for name in ORDER]preset.change(apply_preset, inputs=preset, outputs=[sliders[name] for name in ORDER])with gr.Accordion("Wait, how does this actually work?", open=False):gr.Markdown("This is **activation steering**. The base model is an unmodified "
app.py+51-21