Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,22 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
client = InferenceClient("
|
| 5 |
|
| 6 |
def respond(message, history):
|
| 7 |
-
|
| 8 |
-
messages = [{"role": "system", "content": "You are a chatbot who knows a lot about songs and singing and loves songs and music! You use data from wesbites which provide msuic such as apple, youtube and spotify and you recommend ACCURATELY."}]
|
| 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 |
-
|
|
|
|
| 23 |
|
| 24 |
-
chatbot.
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import random as r
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
client = InferenceClient("microsoft/phi-4")
|
| 6 |
|
| 7 |
def respond(message, history):
|
| 8 |
+
messages = [{"role": "system", "content": "You are a friendly chatbot"}]
|
|
|
|
|
|
|
| 9 |
if history:
|
| 10 |
messages.extend(history)
|
|
|
|
| 11 |
messages.append({"role": "user", "content": message})
|
| 12 |
+
|
| 13 |
response = client.chat_completion(
|
| 14 |
messages,
|
| 15 |
max_tokens=100
|
| 16 |
)
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
return response['choices'][0]['message']['content'].strip()
|
| 19 |
+
|
| 20 |
|
| 21 |
+
chatbot = gr.ChatInterface(respond, type = "messages", title="truth bot")
|
| 22 |
+
chatbot.launch()
|