test / app.py
Sheepbon's picture
Update app.py
e70db35 verified
from huggingface_hub import InferenceClient
import gradio as gr
import random
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
def respond(message, history):
messages = [{"role":"system", "content":"You are a friendly chatbot! :)"}]
if history:
messages.extend(history)
messages.append({"role":"user", "content":message})
response = client.chat_completion(messages, max_tokens = 100, temperature = 1.3, top_p = 0.3) #temp & top_p control random
print(response)
return response["choices"][0]["message"]["content"].strip()
chat_theme = gr.themes.Monochrome(
primary_hue = "rose",
secondary_hue = "rose",
neutral_hue = "rose").set(
background_fill_primary = "*primary_50",
input_background_fill = "*neutral_100",
input_border_color_focus = "*primary_200",
button_secondary_background_fill = "*secondary_50",
button_secondary_background_fill_hover = "*secondary_100")
title = """# 🐑 NutriAssist 🌱"""
with gr.Blocks(theme = chat_theme) as chatbot:
with gr.Row(scale=1):
gr.Image(
value="NutriAssistBanner.png",
show_label=False,
show_share_button = False,
show_download_button = False)
with gr.Row(scale=2):
with gr.Column(scale=1):
gr.Markdown(title)
gr.Image(
"NutriAssistInstructions.png",
show_label = False,
show_share_button = False,
show_download_button = False)
gr.Image(
"NutriAssistTeam.png",
show_label = False,
show_share_button = False,
show_download_button = False)
with gr.Column(scale=2):
gr.ChatInterface(respond, type="messages")
chatbot.launch()