Spaces:
Sleeping
Sleeping
adding huggingface & transitioning to a generative AI model
Browse files
app.py
CHANGED
|
@@ -1,16 +1,23 @@
|
|
| 1 |
-
import random
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
print(message)
|
| 6 |
-
print(history)
|
| 7 |
-
return message
|
| 8 |
|
| 9 |
-
def
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
chatbot = gr.ChatInterface(magic_8_ball, type = 'messages', title = 'Magic 8 Ball', description = "Ask me your most pressing questions!", theme = "mgetz/Celeb_glitzy")
|
| 16 |
chatbot.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceCLient
|
| 3 |
|
| 4 |
+
client = InterfaceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
def respond(message, history):
|
| 7 |
+
messages = [{"role": "system", "content": "You are friend chatbot"}]\
|
| 8 |
|
| 9 |
+
if history:
|
| 10 |
+
messages.extend(history)
|
| 11 |
+
|
| 12 |
+
messages.append({"role": "user", "content": message})
|
| 13 |
+
|
| 14 |
+
response = client.chat_completion(
|
| 15 |
+
messages,
|
| 16 |
+
max_tokens = 100,
|
| 17 |
+
temperature = 0.2
|
| 18 |
+
)
|
| 19 |
+
return response['choices'][0]['message']['content'].strip()
|
| 20 |
+
|
| 21 |
+
chatbot = gr.ChatInterface(, type = 'messages')
|
| 22 |
|
|
|
|
| 23 |
chatbot.launch()
|