chatbot_lab / app.py
Mazz18's picture
Update app.py
8ba7a0f verified
raw
history blame contribute delete
878 Bytes
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 freindly chatbot." }]
if history:
messages.extend(history)
messages.append({"role": "user", "content": message})
response = client.chat_completion(messages, max_tokens = 100)
print(response["choices"][0]["message"]["content"].strip())
return response["choices"][0]["message"]["content"].strip()
def echo(message, history):
my_list = ["yes", "No", "As I see it", "yes", "Outlook good", "Yes - definitely", "without a doubt", "ask again later", "cannot predict now", "my reply is no", "very doubtful", ]
return random.choice(my_list)
chatbot = gr.ChatInterface(respond, type="messages")
chatbot.launch()