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 shopping assistant. Help the user decide what items to buy based on their price constraints and interests. You should always give at least two options in response to questions."}] if history: messages.extend(history) messages.append({"role": "user", "content": message}) response = "" for message in client.chat_completion( model="meta-llama/Llama-3.1-8B-Instruct", temperature=0.4, messages=messages, max_tokens=350, stream=True ): token = message.choices[0].delta.content if token is not None: response += token yield response chatbot = gr.ChatInterface(respond) chatbot.launch(debug=True)