Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,38 @@
|
|
| 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 |
-
|
| 6 |
-
return random.choice(['Yes', 'No', 'only time can tell....'])
|
| 7 |
|
| 8 |
def echo(message, history): # called echo because literally echoing
|
| 9 |
return message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
print("Hello world")
|
| 12 |
|
| 13 |
-
chatbot = gr.ChatInterface(
|
| 14 |
# defining my chatbot so that the user can interact and see their conversation history and send new messages
|
| 15 |
|
| 16 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
+
|
| 5 |
+
client = InferenceClient(HuggingFaceH4/zephyr-7b-beta)
|
| 6 |
+
|
| 7 |
+
def respond(message, history):
|
| 8 |
+
|
| 9 |
+
messages = [{"role": "system", "content": "You are a friendly chatbot."}]
|
| 10 |
+
|
| 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 |
#Import lines go at the top! Any libraries I need to import go up here^^
|
| 22 |
|
| 23 |
+
|
|
|
|
| 24 |
|
| 25 |
def echo(message, history): # called echo because literally echoing
|
| 26 |
return message
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def yes_or_no(message, history):
|
| 30 |
+
responses = ['Yes', 'No']
|
| 31 |
+
return random.choice(responses)
|
| 32 |
|
| 33 |
+
#print("Hello world")
|
| 34 |
|
| 35 |
+
chatbot = gr.ChatInterface(respond, type="messages")
|
| 36 |
# defining my chatbot so that the user can interact and see their conversation history and send new messages
|
| 37 |
|
| 38 |
chatbot.launch()
|