Spaces:
Sleeping
Sleeping
File size: 1,587 Bytes
ccfffd5 c4ea58c 5e638d2 c4ea58c 5e638d2 2a4bd3f 3aba833 5e638d2 28672d2 b5db600 dc92a7e 5e638d2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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 friendly chatbot."}]
if history:
messages.extend(history)
messages.append({"role": "user", "content": message})
response = client.chat_completion(
messages,
max_tokens=100
)
return response['choices'][0]['message']['content'].strip()
chatbot = gr.ChatInterface(respond, type="messages")
# def yes_or_no(message, history):
# return random.choice(['yes', 'no'])
# def echo(message, history):
# return message
# def magic_8_ball(message, history):
# return random.choice(['Try again later', 'Go for it!', 'IDK girl do you...', 'Definitely!!! Maybe....', "Danger! Don't you dare!", "I wouldn't do that if i were you", 'Absolutely', "That's a slay"])
# print("Hello, World!")
chatbot.launch()
# chatbot = gr.ChatInterface(yes_or_no, type="messages", examples=['yes queen', 'no way jose', 'hmmmm ot sure'], title='Ask me anything!', description='Ask the chatbot any yes or no question to get a response. Chatbot not liable for consequences of bad advice.')
# eight_ball = gr.ChatInterface(magic_8_ball, type="messages", examples=['Will I pass the test?', 'Do they like me?', 'Should I bring an umbrella with me?', 'Should I text my ex?'], title="Magic 8 Ball", description="Ask the chatbot any yes or no question to get a response. Chatbot not liable for consequences of bad advice.")
# eight_ball.launch()
|