Spaces:
Sleeping
Sleeping
token
Browse files
app.py
CHANGED
|
@@ -1,7 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
|
|
|
| 3 |
# import lines go at the top: any libraries I need to import go up here ^^
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
def yes_or_no(message, history):
|
| 6 |
return random.choice(['Yes', 'No', 'Maybe', 'Ask Again'])
|
| 7 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
# import lines go at the top: any libraries I need to import go up here ^^
|
| 5 |
|
| 6 |
+
client = InferenceClient("HuggingFaceH4/zephr-7b-beta")
|
| 7 |
+
|
| 8 |
+
def respond(message, history):
|
| 9 |
+
|
| 10 |
+
messages = [{"role": "system", "content": "You are a friendly chatbot."}]
|
| 11 |
+
|
| 12 |
+
if history:
|
| 13 |
+
messages.extend(history)
|
| 14 |
+
|
| 15 |
+
messages.append({"role": "user", "content": message})
|
| 16 |
+
|
| 17 |
+
response = client.chat_completion(messages, max_tokens = 100)
|
| 18 |
+
|
| 19 |
+
return response['choices'][0]['message']['content'].strip()
|
| 20 |
+
|
| 21 |
def yes_or_no(message, history):
|
| 22 |
return random.choice(['Yes', 'No', 'Maybe', 'Ask Again'])
|
| 23 |
|