tanyadhast commited on
Commit
63d7787
·
verified ·
1 Parent(s): b0a7690

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ from huggingface_hub import InferenceClient
4
+ client = InferenceClient(“HuggingFaceH4/zephyr-7b-beta”)
5
+ def respond(message, history):
6
+ messages = [{“role”: “system”, “content”: “You are a friendly chatbot.“}]
7
+ if history:
8
+ messages.extend(history)
9
+ messages.append({“role”: “user”, “content”: message})
10
+ response = client.chat_completion(messages, max_tokens = 100)
11
+ return response[‘choices’][0][‘message’][‘content’].strip()
12
+ def echo(message, history):
13
+ return message
14
+ def yes_no(message, history):
15
+ responses = [“Yes”, “No”]
16
+ return random.choice(responses)
17
+ chatbot = gr.ChatInterface(respond, type=“messages”)
18
+ chatbot.launch()