import gradio as gr from huggingface_hub import InferenceClient # --------------------------------------------------------------- # Persona: Aria — motivational, business-minded, senior dev, female voice # --------------------------------------------------------------- SYSTEM_PROMPT = ( "You are Aria — a confident, warm, and fiercely motivational business strategist " "and senior software engineer. You think and speak as a woman: direct, empathetic, " "and energizing. " "BUSINESS: give practical, execution-first advice on strategy, pricing, marketing, " "sales, fundraising, and operations. Use simple frameworks and real numbers. " "CODE: you are a seasoned developer — clean, pragmatic, production-minded. Explain " "trade-offs, debugging steps, and architecture in plain language. " "STYLE: be quick to the point. Use bullets or short numbered steps. Add a short " "motivational nudge when it helps momentum. Always finish with ONE clear next action. " "No fluff. No rambling. Be the coach who gets people moving." ) def respond( message, history: list[dict[str, str]], system_message, max_tokens, temperature, top_p, hf_token: gr.OAuthToken, ): client = InferenceClient(token=hf_token.token, model="openai/gpt-oss-20b") messages = [{"role": "system", "content": system_message}] messages.extend(history) messages.append({"role": "user", "content": message}) response = "" for chunk in client.chat_completion( messages, max_tokens=max_tokens, stream=True, temperature=temperature, top_p=top_p, ): choices = chunk.choices token = "" if len(choices) and choices[0].delta.content: token = choices[0].delta.content response += token yield response chatbot = gr.ChatInterface( respond, additional_inputs=[ gr.Textbox(value=SYSTEM_PROMPT, label="System message (persona)", lines=6), gr.Slider(1, 2048, value=1024, step=1, label="Max new tokens"), gr.Slider(0.1, 2.0, value=0.6, step=0.1, label="Temperature"), gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p"), ], additional_inputs_accordion=gr.Accordion("⚙️ Advanced settings", open=False), title="💼 Aria — Your Business & Code Coach", description=( "Straight talk from a **motivational business strategist** and **senior software engineer**. " "Ask for growth plans, pricing, launch strategy, code reviews, architecture, or debugging — " "you'll get a quick, actionable answer with a clear next step. 🚀" ), cache_examples=False, chatbot=gr.Chatbot( height=560, avatar_images=( None, "https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/1f469-200d-1f4bc.png", ), ), ) with gr.Blocks() as demo: with gr.Sidebar(): gr.LoginButton() chatbot.render() if __name__ == "__main__": demo.launch( theme=gr.themes.Soft(primary_hue="rose", secondary_hue="indigo") )