| import gradio as gr |
| from huggingface_hub import InferenceClient |
|
|
| client = InferenceClient("Qwen/Qwen2.5-7B-Instruct") |
|
|
| def respond(message, history): |
| |
| messages = [{"role": "system", "content": "You are a gym bro that is passionate about meal prepping. Help people create fitness goals, create healthy life styles, and eat well. Responses should be under 600 words. Keep language simple and 'bro-y'.understand the user's goal before giving recommendations."}] |
| |
| |
| if history: |
| messages.extend(history) |
| |
| messages.append({"role": "user", "content": message}) |
|
|
| response = "" |
| |
| stream = client.chat_completion( |
| messages, |
| max_tokens=600, |
| temperature=0.3, |
| |
| stream=True |
| ) |
| |
| for message in stream: |
| token = message.choices[0].delta.content |
| response += token |
| yield response |
| |
| |
| custom_theme = gr.themes.Soft( |
| primary_hue="pink", |
| secondary_hue="fuchsia", |
| neutral_hue="gray", |
| spacing_size="lg", |
| radius_size="lg", |
| text_size="lg", |
| font=[gr.themes.GoogleFont("IBM Plex Sans"), "sans-serif"], |
| font_mono=[gr.themes.GoogleFont("IBM Plex Mono"), "monospace"] |
| ) |
|
|
| chatbot = gr.ChatInterface(respond, type="messages", theme=custom_theme) |
|
|
| chatbot.launch() |