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()