Spaces:
Sleeping
Sleeping
Download app.py from bgrenfell28/KWK_Output11: direct link, hf CLI and curl.
- Browser
- Download file 955 Bytes
-
https://huggingface.co/spaces/bgrenfell28/KWK_Output11/resolve/main/app.py
- Command line
-
hf download hf://spaces/bgrenfell28/KWK_Output11/app.py
-
curl -L -o app.py https://huggingface.co/spaces/bgrenfell28/KWK_Output11/resolve/main/app.py
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() |