Spaces:
Sleeping
Sleeping
Update app.py
Browse files12341234675961178910111213141516171819202122232425262728293031323334353637with gr.Blocks(css=".chatbox-custom .chatbot {background-color: #e6ffe6;}") as demo: with gr.Column(elem_classes="chatbox-custom"): chatbot = gr.Chatbot() msg = gr.Textbox()import gradio as grimport random as rdfrom huggingface_hub import InferenceClient
def respond(message, chat_history): return "", chat_history + [(message, "Hi there!")]
msg.submit(respond, [msg, chatbot], [msg, chatbot])
demo.launch()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 ) 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_choice
chatbot = gr.ChatInterface(respond, type = "messages")chatbot - grchaybot.launvh( chatbot.launch(True))
app.py+34-8