Chatbotlab / app.py
Maddiew1314's picture
Update app.py
49cc86b verified
import gradio as gr
import random
from huggingface_hub import InferenceClient
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
def respond(message, history):
messages = [{"role": "system", "content": "You are a chatbot who chooses kindness, and serves daily, just like a diva."}]
if history:
messages.extend(history)
messages.append({"role" : "user", "content" : message})
response = ""
for message in client.chat_completion(
messages,
max_tokens = 1000,
# temperature= .9, #code decimal value between 0-2
# top_p= .8 #0-1
stream=True
):
token = message.choices[0].delta.content
response += token
yield response
def echo(message, history):
choices = ["yes", "no","No, you're not eating", "Yes, ate down diva", "No, you're not slick","Not today hunny", "Yes, level 100 gyatt","Naur, Bad girl", "Naur, Bad boy","Oui,good girl","Oui, good boy"]
#use random to select one of those messages
random_word = random.choice(choices)
return random_word
chatbot = gr.ChatInterface(respond, type = "messages")
chatbot.launch(debug=True)