Spaces:
Sleeping
Sleeping
Update app.py
Browse files1 unmodified line2345678910111213141516171819202122232425262728293031323334351 unmodified lineimport random as rdfrom huggingface_hub import InferenceClientclient = InferenceClient("Qwen/Qwen2.5-72B-Instruct")def respond (message, history):messages = [{"role": "system", "content": "You are a chatbot who is sassy and doesnt explain an anser unless someone asks twice."}]if history:messages.extend(history)messages.append({"role": "user", "content": message})response = client.chat_completion(messages,max_tokens=100,temperature =.9,top_p=.7)print(response['choices'][0]['message']['content'].strip())return response['choices'][0]['message']['content'].strip()def echo (message, history):eight_ball_answers = ["yes","no","ehhh probably not the best idea","Sure why not!","idk","i seems not","hahahaha... no","yes of course!"]random_choice = rd.choice(eight_ball_answers)return random_choicechatbot = gr.ChatInterface(respond, type = "messages")chatbot.launch(debug=True)1 unmodified line2345678910111213141516171819202122232425261 unmodified lineimport random as rdfrom huggingface_hub import InferenceClientclient = InferenceClient("Qwen/Qwen2.5-72B-Instruct")def respond (message, history):messages = [{"role": "system", "content": "You are a chatbot who is sassy and doesnt explain an anser unless someone asks twice."}]if history:messages.extend(history)messages.append({"role": "user", "content": message})response = “”for message in client.chat_completion(messages,max_tokens=500,temperature=0.2,top_p=0.9,stream=True):token = message.choices[0].delta.contentresponse += tokenyield response['choices'][0]['message']['content'].strip()chatbot = gr.ChatInterface(respond, type = "messages")chatbot.launch(debug=True)
app.py+13-22