Spaces:
Runtime error
Runtime error
practiced for lesson 11 generative AI
Browse files123456789101112import gradio as grimport randomdef random_message(message, history):choices = ["yes.", "no.", "it is certain","without a doubt","outlook good","ask again later", "better not tell you now","very doubtful","don't count on it","my sources say no","outlook not so good","very doubtful","reply hazy, try again", "cannot predict now"]chat_answer = random.choice(choices)return chat_answerprint("Hello, World!")chatbot = gr.ChatInterface(random_message, type = "messages", theme = 'gstaff/xkcd', editable = True, title = "8ball" )chatbot.launch()123456789101112131415161718192021222324252627282930import gradio as grimport randomfrom huggingface_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 random_message(message, history):choices = ["yes.", "no.", "it is certain","without a doubt","outlook good","ask again later", "better not tell you now","very doubtful","don't count on it","my sources say no","outlook not so good","very doubtful","reply hazy, try again", "cannot predict now"]chat_answer = random.choice(choices)return chat_answerprint("Hello, World!")chatbot = gr.ChatInterface(respond, type = "messages")chatbot.launch()
app.py+19-1