Spaces:
Sleeping

KWK_Output11 / app.py
bgrenfell28's picture
Update app.py
d2c6e38 verified
Raw History Blame Contribute Delete
955 Bytes
import gradio as gr
from huggingface_hub import InferenceClient
client = InferenceClient("meta-llama/Llama-3.1-8B-Instruct")
def respond(message, history):
messages = [{"role": "system", "content": "You are a friendly barista making a matcha. Please provide step by step instructions on how to make a matcha latte. Please ask the user if they have any dietary restrictions (allergies) prior to suggesting how to make the matcha latte. Keep responses under 100 words."}]
if history:
messages.extend(history)
messages.append({"role": "user", "content": message})
response = ""
for message in client.chat_completion(
messages,
temperature = 0.8,
max_tokens = 1000,
top_p = 0.4,
stream = True):
token = message.choices[0].delta.content
if token:
response += token
yield response
chatbot = gr.ChatInterface(respond)
chatbot.launch()