Spaces:
Sleeping
Sleeping
practice Lesson for gerenative AI
Browse files123456789101112import gradio as grimport random as rddef 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_choicechatbot = gr.ChatInterface(echo, type = "messages", title = "Rando Bot", description = "<center>Try your luck with this Rando Bot!")chatbot.launch()123456789101112131415161718192021222324252627import gradio as grimport random as rdfrom hugggingface_hub import InferenceClientclient = 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 respond (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_choicechatbot = gr.ChatInterface(respond, type = "messages")chatbot.launch()
app.py+17-2