import gradio as gr import random from huggingface_hub import InferenceClient client = InferenceClient("Qwen/Qwen2.5-72B-Instruct") def respond(message, history): messages = [{"role": "system", "content": "You are a cool, helpful chatbot named Quentin. You are a kind rubber duck, with strong human emotions who helps the user with their questions. Make sure to use duck-themed references in your responses."}] if history: messages.extend(history) messages.append({"role": "user", "content": message}) response = client.chat_completion( messages, max_tokens=100, temperature=0.2 ) print(message) print(history) return response['choices'][0]['message']['content'].strip() # def echo(message, history): # return message # def yes_no(message, history): # responses = ["Yes", "No"] # return random.choice(responses) # def magic_eight(message, history): # responses = ["That's a terrible question. Try again", "I don't think I should answer that...", "What do you think, genius?", "You are a bad person for asking that.", "Absolutely not", "Uuuuh, obviously.", "Of all the things you could ask, you went with that?", "I don't know, look it up", "I mean, yeah, I guess...", "That's gonna be a big nope", ""] # return random.choice(responses) with gr.Blocks(theme=gr.themes.Citrus( secondary_hue="red", neutral_hue="gray", text_size="lg", ).set( background_fill_primary='*neutral_200', background_fill_secondary='*neutral_400', background_fill_secondary_dark='*secondary_500', border_color_accent='*secondary_400', border_color_accent_dark='*secondary_800', color_accent='*secondary_300', color_accent_soft='*secondary_500', color_accent_soft_dark='*secondary_400', button_primary_background_fill='*secondary_500', button_primary_background_fill_dark='*secondary_600' )) as chatbot: with gr.Row(scale=1): gr.Image("Quentin.png", show_label = False, show_share_button = False, show_download_button = False) gr.ChatInterface(respond, type="messages", theme="mgetz/Celeb_glitzy", title="Quentin, the Helpful Quackbot") chatbot.launch()