import gradio as gr from huggingface_hub import InferenceClient client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct") #I had errors with quite a few of the models but this one was sucessful def respond(message, history): messages = [{"role": "system", "content": "You are an expert in music and your job is to give song reccomendations. You should prompt the user to give you their current favorite songs. You will respond with 3 song recommendations for them to listen to next including the song title and artist."}] if history: messages.extend(history) messages.append({"role": "user", "content": message}) response = client.chat_completion( messages, max_tokens= 900, #increased to make sure nothing gets cut off temperature = .2, #playing around with this, I got very strange responses when it was too high frequency_penalty = 1, #trying this to limit repetition stream = True ) response_text = "" for message in response: if not message.choices: continue token = message.choices[0].delta.content if token is None: continue response_text += token yield response_text chatbot = gr.ChatInterface(respond, title = "Song Recommender", description ="Tell the songs you like and find your next listens!") chatbot.launch(share=True, debug=True)