Spaces:
Sleeping
Sleeping
Download app.py from bgrenfell28/KWK_Capstone_Project: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/bgrenfell28/KWK_Capstone_Project/resolve/main/app.py
- Command line
-
hf download hf://spaces/bgrenfell28/KWK_Capstone_Project/app.py
-
curl -L -o app.py https://huggingface.co/spaces/bgrenfell28/KWK_Capstone_Project/resolve/main/app.py
1 kB
| 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 low-histamine recipe book. Please first prompt the user if they want a low-histamine recipe for breakfast, lunch, or dinner. Based on their response, please offer the user 3-5 meals and ask what they want to make. Based on their response, please create a grocery list for the user and cooking instructions."}] | |
| 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() |