Spaces:
Sleeping
Sleeping
adding huggingface & transitioning to a generative AI model
Browse files
app.py
CHANGED
|
@@ -1,12 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
chatbot = gr.ChatInterface(
|
| 12 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import Inference_Client
|
| 3 |
|
| 4 |
+
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 5 |
+
|
| 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(messages,max_tokens=100,temperature=0.2)
|
| 12 |
+
return response['choices'][0]['message']['content'].strip()
|
| 13 |
|
| 14 |
+
chatbot = gr.ChatInterface(respond, type="messages")
|
| 15 |
chatbot.launch()
|