Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
|
|
|
|
|
|
| 3 |
#libraries^
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
#def echo(message, history):
|
| 8 |
#return message
|
| 9 |
-
def yes_or_no(message, history):
|
| 10 |
-
|
| 11 |
|
| 12 |
-
chatbot = gr.ChatInterface(
|
| 13 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
+
client = InferenceClient('HuggingFaceH4/zephyr-7b-beta')
|
| 5 |
#libraries^
|
| 6 |
+
def respond(message,history):
|
| 7 |
+
messages = [{"role": "system", "content": "You are a friendly chatbot."}]
|
| 8 |
+
if history:
|
| 9 |
+
messages.extend(history)
|
| 10 |
+
messages.append({"role": "user", "content": message})
|
| 11 |
+
response = client.chat_completion(
|
| 12 |
+
messages,
|
| 13 |
+
max_tokens=100
|
| 14 |
+
)
|
| 15 |
+
return response['choices'][0]['message']['content'].strip()
|
| 16 |
#def echo(message, history):
|
| 17 |
#return message
|
| 18 |
+
#def yes_or_no(message, history):
|
| 19 |
+
#return random.choice(['yes','no', 'maybe','try again', 'i dont know','hahahahahaha','guilty'])
|
| 20 |
|
| 21 |
+
chatbot = gr.ChatInterface(respond, type = 'messages',title = '8 BALL', description = 'type a yes or no question',theme = 'soft')
|
| 22 |
chatbot.launch()
|