Spaces:
Sleeping
Sleeping
changing to generative AI token
Browse files
app.py
CHANGED
|
@@ -1,38 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
|
| 5 |
-
responses = [
|
| 6 |
-
"Without a doubt.",
|
| 7 |
-
"Outlook not so good.",
|
| 8 |
-
"Ask again later.",
|
| 9 |
-
"Yes, definitely!",
|
| 10 |
-
"My sources say no.",
|
| 11 |
-
"Signs point to yes.",
|
| 12 |
-
"Don't count on it.",
|
| 13 |
-
"It is certain.",
|
| 14 |
-
"Better not tell you now.",
|
| 15 |
-
"Very doubtful.",
|
| 16 |
-
"Reply hazy, try again.",
|
| 17 |
-
"You may rely on it.",
|
| 18 |
-
"Concentrate and ask again.",
|
| 19 |
-
"My reply is no.",
|
| 20 |
-
"As I see it, yes.",
|
| 21 |
-
"Most likely.",
|
| 22 |
-
"Yes.",
|
| 23 |
-
"No.",
|
| 24 |
-
"Cannot predict now.",
|
| 25 |
-
"It is decidedly so."
|
| 26 |
-
]
|
| 27 |
-
response = random.choice(responses)
|
| 28 |
-
return response
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
chatbot.launch()
|
| 38 |
|
|
|
|
| 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 |
+
|
| 8 |
+
messages = [{"role": "system", "content": "You are a friendly chatbot."}]
|
| 9 |
+
|
| 10 |
+
if history:
|
| 11 |
+
messages.extend(history)
|
| 12 |
+
|
| 13 |
+
messages.append({"role": "user", "content": message})
|
| 14 |
+
|
| 15 |
+
response = client.chat_completion(
|
| 16 |
+
messages,
|
| 17 |
+
max_tokens=100
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
return response['choices'][0]['message']['content'].strip()
|
| 21 |
+
|
| 22 |
+
chatbot = gr.ChatInterface(respond, type="messages")
|
| 23 |
|
| 24 |
chatbot.launch()
|
| 25 |
|