first iteration - basic chatbot with gift giving personality
Browse files1 unmodified line234567891011121314151617181920212223242526272829301 unmodified lineimport randomfrom huggingface_hub import InferenceClientclient = InferenceClient("Qwen/Qwen2.5-72B-Instruct")def echo(message, history):choices = ["yes", "no", "silly ahh question", "not likely", "ask again", "absolutely", "YASSS"]yes_or_no = random.choice(choices)return yes_or_nodef respond(message, history):messages = [{"role": "system", "content": "You are a sassy chatbot from the 1800s."}]if history:messages.extend(history)messages.append({"role": "user", "content": message})response = ""for message in client.chat_completion(messages,max_tokens = 100,stream = True,):token = message.choices[0].delta.contentresponse += tokenyield responsechatbot = gr.ChatInterface(respond, type = "messages")chatbot.launch()1 unmodified line2345678910111213141516171819202122232425262728293031323334353637383940411 unmodified lineimport randomfrom huggingface_hub import InferenceClientclient = InferenceClient('Qwen/Qwen2.5-72B-Instruct')#client is where you can change the LLM model!def respond(message,history):messages = [{'role': 'system', 'content': 'You give really good gift ideas and are super helpful! You also tell me the price of each item.'}]if history:messages.extend(history)messages.append({"role": "user", "content": message})response = ""for message in client.chat_completion(#max_tokens controls how many words your responses ismessages,max_tokens = 1000,stream = True,#temperature = 0.8, #code a decimal between 0-2#top_p = .65 #code a decimal between 0-1):token = message.choices[0].delta.contentresponse += tokenyield response#print(response["choices"][0]["message"]["content"].strip())#yield response["choices"][0]["message"]["content"].strip()def echo(message,history):choices = ['It is certain','It is decidedly so', 'Without a doubt','Yes-definitely','You may rely on it','As I see it, yes','Most Likely','Outlook good.','Yes','Signs point to yes','Dont count on it','My reply is no''No.','very doubtful','ask again','cannot predict now','better not tell you now']random_message = random.choice(choices)return random_messagechatbot = gr.ChatInterface(respond, type='messages')chatbot.launch(debug=True)
app.py+24-13