Spaces:
Sleeping
Sleeping
adding huggingface and transitioning to a generative AI model
Browse files
app.py
CHANGED
|
@@ -1,9 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
|
| 5 |
-
responses=["Yes!","No.","Yes, definetely!", "Most Likely."]
|
| 6 |
-
return random.choice(responses)
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 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 |
+
|
| 9 |
+
if history:
|
| 10 |
+
messages.extend(history)
|
| 11 |
+
messages.append({"role": "user", "content": message})
|
| 12 |
+
|
| 13 |
+
response client.chat_completion(
|
| 14 |
+
messages,
|
| 15 |
+
max_toxens=100
|
| 16 |
+
temperature=0.2
|
| 17 |
+
)
|
| 18 |
+
return response['choices'][0]['message']['content'].strip()
|
| 19 |
+
|
| 20 |
+
chatbot = gr.ChatInterface(magic_eight_ball, type="messages")
|
| 21 |
chatbot.launch()
|